Skip to content

Commit

Permalink
Enable syntax highlight on JS snippet code.
Browse files Browse the repository at this point in the history
  • Loading branch information
mazulo committed Dec 9, 2015
1 parent 392c76c commit 7e8b6d4
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@ sketch.js lets you get straight to the fun parts of creative coding, without eve
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: function() {
this.r = this.g = this.b = random( 100, 200 );
},
mousemove: function() {
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: function() {
this.fillStyle = 'rgb(' + ~~this.r + ',' + ~~this.g + ',' + ~~this.b + ')';
this.fillRect( 0, 0, this.width, this.height );
}
});
````javascript
Sketch.create({
setup: function() {
this.r = this.g = this.b = random( 100, 200 );
},
mousemove: function() {
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: function() {
this.fillStyle = 'rgb(' + ~~this.r + ',' + ~~this.g + ',' + ~~this.b + ')';
this.fillRect( 0, 0, this.width, this.height );
}
});
````

[See it in action](http://jsfiddle.net/soulwire/7wtbm/)

Expand Down

0 comments on commit 7e8b6d4

Please sign in to comment.