examples / processing / using-variables / jack-o-lantern


example processing πŸŽƒ

:jack_o_lantern: πŸŽƒ :jack_o_lantern:

This program uses the width and height variables to draw a Jack-o’-lantern that changes size according to the window size.

size(200, 200);

stroke(0, 100, 0);
line(width/2, height/4, width*.6, height*.15);

fill(255, 100, 0);
stroke(120, 60, 0);
ellipse(width/2, height/2, width*.75, height/2);
ellipse(width/2, height/2, width*.625, height/2);
ellipse(width/2, height/2, width*.5, height/2);
ellipse(width/2, height/2, width*.375, height/2);
ellipse(width/2, height/2, width*.25, height/2);
ellipse(width/2, height/2, width*.125, height/2);

triangle(width*.4, height*.35, width*.35, height*.45, width*.45, height*.45);
triangle(width*.6, height*.35, width*.55, height*.45, width*.65, height*.45);

arc(width*.5, height*.65, width*.4, height*.2, 3.14, 2*3.14);
line(width*.3, height*.65, width*.7, height*.65);

Code Editor

See the Pen by Happy Coding (@KevinWorkman) on CodePen.

Try changing the parmaters passed into the size() function to change the size of the window, and the size of the Jack-o’-lantern will change automatically.

πŸŽƒ πŸŽƒ πŸŽƒ

πŸŽƒ :jack_o_lantern: πŸŽƒ

Tweak Ideas