Stop
Continue
Go
/* Random Functions This example demonstrates how to use an array to call random functions. The array theFunctions will hold the names of two functions which will be called randomly to place objects at random locations on the canvas. We use the animation loop to draw many shapes */ function drawCircle(x,y){ //Draw a circle with radius 10 at (x,y) fillcolor('red'); circle(x,y,10); fill(); } function drawSquare(x,y){ //Draw a 20x20 square at (x,y) fillcolor('blue'); rect(x-10,y-10,20,20); fill(); } //An array with the function names var theFunctions=[drawCircle, drawSquare]; function setup(){ loop(); //start the animation loop } function draw(){ //variables for center of shape var x,y; /* A variable for the name of a random function. This is not necessary, but it saves some awkward parentheses. */ var f; //get random coordinates x=width*random(); y=height*random(); //call random function f=theFunctions.random(); f(x,y); }
default
3024-day
3024-night
ambiance
base16-dark
base16-light
blackboard
cobalt
eclipse
elegant
erlang-dark
lesser-dark
mbo
mdn-like
midnight
monokai
neat
night
paraiso-dark
paraiso-light
pastel-on-dark
rubyblue
solarized dark
solarized light
the-matrix
tomorrow-night-eighties
twilight
vibrant-ink
xq-dark
xq-light