mouse press to change

mouse hover to change

The tangram puzzle consists of 7 geometric pieces which are normally boxed in the shape of a square. The pieces are used to create different patterns including animals, people, numbers, geometric shapes and many more. I tried to use the “function” syntax and slide bars in P5 to make these different patterns.
u3821439241631545356fm21gp0hi-quality-educational-brain-teaser-jigsaw-puzzle-games-iq-wooden-tangram-for-kids

At first, I thought it would be eaiser to make it by using “rotate()” syntax, but I’m a little confused about its parameters. I can’t make each triangle or rectangle rotated at the relative coordinate of itself.

So, finally I use the (x ,y) as variable for each group of pattern. It took a lot of time to draw every seven pieces of each pattern.

BUT…

When I tried to modify the switch effect of the slide bars this morning, I just clicked “Ctrl+Z”, then suddenly my code totally disappeared. The saved version also changed to a new sketch automatically.

This is the last screenshot of my sketch…

qq%e6%88%aa%e5%9b%be20161006051340

Finally, I finished the coding after I learnt about how to use rotate(a), push() and pop(). It’s easier to draw the seven pieces and make them up into different patterns. My codes are here: hover  press