Last active
October 13, 2015 04:57
-
-
Save dethe/4142529 to your computer and use it in GitHub Desktop.
Simplest example of a Waterbear script (for Javascript canvas)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local.count_1 = 0; | |
(function() { | |
setInterval(function() { | |
local.count_1++; | |
var point_2 = { | |
x: randint(0, global.stage_width), | |
y: randint(0, global.stage_height) | |
}; | |
var radius_2 = randint(20, 50); | |
var color_2 = "rgb(" + randint(0, 255) + "," + randint(0, 255) + "," + randint(0, 255) + ")"; | |
local.ctx.save(); | |
local.ctx.fillStyle = color_2; | |
local.ctx.beginPath(); | |
local.ctx.arc(point_2.x, point_2.y, radius_2, 0, Math.PI * 2, true); | |
local.ctx.closePath(); | |
local.ctx.fill(); | |
local.ctx.restore(); | |
}, 1000 / 30) | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"title":"","description":"","date":1353822097063,"scripts":{"waterbearVersion":"1.0","plugins":["javascript","canvas","sprite"],"workspace":"default","blocks":[{"signature":"eventhandler: repeat [number] times a second","blocktype":"eventhandler","id":1,"values":[{"type":"number","value":30}],"contained":[{"signature":"step: fill circle at point [point] with radius [number] and color [color]","blocktype":"step","id":2,"values":[{"type":"point","value":{"signature":"expression: random point","blocktype":"expression","id":3}},{"type":"number","value":{"signature":"expression: pick random [number] to [number]","blocktype":"expression","id":4,"values":[{"type":"number","value":20},{"type":"number","value":50}]}},{"type":"color","value":{"signature":"expression: random color","blocktype":"expression","id":5}}]}]}]}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment