GithubHelp home page GithubHelp logo

hhy5277 / sketch.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from soulwire/sketch.js

0.0 2.0 0.0 573 KB

Cross-Platform JavaScript Creative Coding Framework

License: MIT License

HTML 5.93% JavaScript 89.57% CSS 4.50%

sketch.js's Introduction

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.

sketch.js's People

Contributors

soulwire avatar jsteunou avatar amilajack avatar olexpono avatar filr avatar nitriques avatar dmnsgn avatar isaksky avatar jasonstorey avatar mazulo avatar saschageyer avatar ddsol avatar

Watchers

haiyang avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.