Skip to content

Instantly share code, notes, and snippets.

@dethe
Last active October 13, 2015 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dethe/4142529 to your computer and use it in GitHub Desktop.
Save dethe/4142529 to your computer and use it in GitHub Desktop.
Simplest example of a Waterbear script (for Javascript canvas)
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)
})();
{"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