首页
/ Zajal 0.6 - Atlantic 技术文档

Zajal 0.6 - Atlantic 技术文档

2024-12-20 05:12:37作者:魏侃纯Zoe

1. 安装指南

首先,确保您的系统中已经安装了 Electron

接下来,请按照以下步骤进行操作:

  1. 克隆项目仓库到本地:

    git clone https://github.com/nasser/zajal.git
    
  2. 切换到项目目录,并切换到 atlantic 分支:

    cd zajal
    git checkout atlantic
    
  3. 安装项目依赖:

    npm install
    
  4. 使用 Electron 运行项目:

    electron . zajal/draw/pixi.cljs
    

2. 项目使用说明

Zajal 是一个基于 ClojureScript、Pixi.js、ThreeJS 和 Arcadia 项目的创意编程框架。本项目旨在为初学者和高级程序员提供一个高度表达性、完全实时的创意编程体验。

以下是项目的基本使用方法:

  1. 创建一个 ClojureScript 文件,例如 draw.cljs

  2. 在该文件中,定义你的绘图函数 draw,如下所示:

    (defn draw [t]
      (renderer
        {:width 400
         :height 400}
        [(graphics {:shape (circle 20)
                    :line-width 4 
                    :line-color 0xffffff
                    :x 100
                    :y 100})
         (graphics {:shape (polygon [0 -15 -10 10 0 5 10 10 0 -15])
                    :fill 0
                    :line-width 1
                    :line-color 0xffffff
                    :x 100
                    :y 75
                    :rotation (* 0.05 t)})
         (text {:text "Zajal!"
                :fill "white"
                :x 50})
         (graphics {:shape (polygon [0 -15 -10 10 0 5 10 10 0 -15])
                    :fill 0
                    :line-width 1
                    :line-color 0xffffff
                    :x 100
                    :y 125
                    :rotation (* 0.05 t)
                    })]))
    
  3. draw.cljs 文件中,调用 sketch 函数以启动动画:

    (sketch 0 #'step #'draw)
    

3. 项目API使用文档

本项目提供了以下API供开发者使用:

  • renderer: 用于创建画布并渲染图形。
  • graphics: 用于绘制各种图形,如圆形、多边形等。
  • text: 用于在画布上显示文本。

更多API详情,请参考项目源代码。

4. 项目安装方式

请参考上文“1. 安装指南”中的步骤进行项目安装。

登录后查看全文
热门项目推荐