sketch.js

Cross-Platform JavaScript Creative Coding Framework

  • 所有者: soulwire/sketch.js
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

sketch.js

A tiny (~2kb gzipped) platform for JavaScript creative coding.

A few examples from the showcase

Start Coding Faster

sketch.js lets you get straight to the fun parts of creative coding, without ever having to worry about shims or boilerplate code.

It gives you a graphics context, an animation loop, normalised input events and a host of useful callbacks to hook into.

Here's an example:

Sketch.create({
  setup() {
    this.r = this.g = this.b = random(100, 200)
  },
  mousemove() {
    this.r = 255 * (this.mouse.x / this.width)
    this.g = 255 * (this.mouse.y / this.height)
    this.b = 255 * abs(cos(PI * this.mouse.y / this.width))
  },
  draw() {
    this.fillStyle = `rgb(${~~this.r},${~~this.g},${~~this.b})`
    this.fillRect(0, 0, this.width, this.height)
  }
})

See it in action

The Highlights

  • A sketch is an augmented drawing context (CanvasRenderingContext2D, WebGLRenderingContext or HTMLElement) so it has all the expected drawing methods built in.
  • The mouse property is also the first element of the touches array and vice versa, so you can code to one standard and get touch and multi-touch support for free.
  • The update and draw loops run on the browser animation frame and can stop and start whenever you like.
  • You get fast access to Math functions and constants, plus extras like range and array enabled random, map and lerp.
  • Simple and configurable. You can even bring your own context, so it works well with libraries like THREE.

The Rest

For more information, check out the getting started guide, the API, the many examples in the showcase and the full source.

主要指標

概覽
名稱與所有者soulwire/sketch.js
主編程語言JavaScript
編程語言CSS (語言數: 3)
平台
許可證MIT License
所有者活动
創建於2012-07-10 01:55:55
推送於2023-09-16 03:41:59
最后一次提交2017-01-03 07:29:24
發布數2
最新版本名稱v1.1 (發布於 2013-05-28 15:52:01)
第一版名稱v1.0 (發布於 2013-02-24 14:31:41)
用户参与
星數4.1k
關注者數144
派生數433
提交數149
已啟用問題?
問題數80
打開的問題數27
拉請求數15
打開的拉請求數9
關閉的拉請求數6
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?