Stop
Continue
Go
/* Implicit Line This example uses an implicit representation of a line to draw a picture. 5000 circles are placed at random locations. Circles above the line are filled red. Circles below the line are filled blue. Colors include transparency to give a blending effect. */ /* This function uses the imlicit definition of a line (y-y1)*(x2-x1)-(x-x1)*(y2-y1)=0 connecting (x1,y1) and (x2,y2). A positive return value puts (x,y) on one side of the line. A negative value puts it on the other. */ function impLine(x,y,x1,y1,x2,y2){ return((y-y1)*(x2-x1)-(x-x1)*(y2-y1)); } function setup(){ color(0,0,0,0); //this makes the outline of the //circles invisible } function draw(){ var x,y; //coordinates of circle var d; //value from implicit function var i; //index for for loop //repeat 5000 times for (i=0;i<5000;i=i+1){ //random point x=width*random(); y=height*random(); //we call impLine with the line //connecting (0,300) and (400,100) d=impLine(x,y,0,300,400,100); if (d<0) //above the line fillcolor(255,0,0,0.1); else //below or on the line fillcolor(0,0,255,0.1); circle(x,y,10); fill(); } }
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