October 6, 2016

example processing pretty

:sunflower: :hibiscus: :tulip: :bouquet: :cherry_blossom:

size(200, 300);

//draw green stem
stroke(0, 128, 0);
line(100, 100, 100, 300);

ellipse(105, 200, 10, 10);
ellipse(95, 225, 10, 10);

//change stroke back to thin black line

//draw petals
fill(255, 100, 0);
ellipse(50, 50, 100, 100);
ellipse(150, 50, 100, 100);
ellipse(50, 150, 100, 100);
ellipse(150, 150, 100, 100);

//draw middle part
fill(255, 128, 0);
ellipse(100, 100, 100, 100);

This code calls a series of functions do draw a flower:


Code Editor

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

:sunflower: :hibiscus: :tulip: :bouquet: :cherry_blossom:

Tweak Ideas

  • Draw a more realistic flower.
  • Draw a whole vine of flowers.
  • Use a piece of paper and a pen to draw a flower by hand. Try to recreate that using code!

Calling Functions Examples


Happy Coding is a community of folks just like you learning about coding.
Do you have a comment or question? Post it here!

Comments are powered by the Happy Coding forum. This page has a corresponding forum post, and replies to that post show up as comments here. Click the button above to go to the forum to post a comment!