Possible to create optical art with only: for loop, while loops and boolean operators for high school student project?
in
Programming Questions
•
1 month ago
Hello Members,
My name is Margaret Noble and I am an artist and a teacher. I have started a website documenting of my entry level exploration into making art through the practice of computer programming with Processing. It will serve as curriculum that I will implement the following school year with high school students.
I am moving very slowly and methodically with Shiffman's book, Learning Processing. I have only learned (not mastered) basic: for loops, while loops and boolean conditionals. I am trying to design a project to practice these tools that are interesting and fun art projects. This would be for my students later but I want to pilot the project myself now. I was thinking of optical art projects whereby students wrote pseudo code first from a simple 3d graphic image and then used for loops, while loops and boolean operators to make it come alive.
My test case, something like this:
But, I keep failing. My strategy was to just figure out how to code the white quads and then use that knowledge for the green and blue quads. Here's my pseudo code for the white quads:
Declare variables for the white quad points: wx1,wy1,wx2,wy2,wx3,wy3,wx4,wy4.
Start a white quad with vertices (wx1+0,wy1+15,wx2+30,wy2+0,wx3+60,wy3+15,wx4+30,wy4+30);
AND
Repeat this white quad on the horizontal Xaxis (wx1,wx2,wx3,wx4) every 60 pixels and stop when wx3 gets to the width of size().
then
drop down the white quad by 60 pixels vertically on all Yaxis (wy1,wy2,wy3,wy4) points and shift all Xaxis points (wx1,wx2,wx3,wx4) to left by -30 horizontal Xaxis pixels.
And
Repeat this white quad on all horizontal axis points every -60 pixels until you get to 0.
This is as far as I got with code after a few failed attempts, not efficient or really working:
- //TRYING TO JUST GET LIGHT COLORED QUADS TO REPEAT WITH ONLY WHILE LOOPS, FOR LOOPS AND BOOLEAN OPERATORS
- //white vertices
- int wx1 = 0;
- int wy1 = 0;
- int wx2 = 0;
- int wy2 = 0;
- int wx3 = 0;
- int wy3 = 0;
- int wx4 = 0;
- int wy4 = 0;
- void setup () {
- size (400,400);
- background (255);
- }
- void draw () {
- noStroke();
- //green quad
- fill (10,144,51);
- quad (0,15,30,30,30,75,0,60);
- //blue quad
- fill (25,186,191);
- quad (30,30,60,15,60,60,30,75);
- //white quad
- if ((wx1 > width) && (wx1 < 0)){
- }
- fill (247,235,235);
- quad (wx1+0,wy1+15,wx2+30,wy2+0,wx3+60,wy3+15,wx4+30,wy4+30);
- quad (wx1+30,wy1+75,wx2+60,wy2+60,wx3+90,wy3+75,wx4+60,wy4+90);
- quad (wx1+60,wy1+135,wx2+90,wy2+120,wx3+120,wy3+135,wx4+90,wy4+150);
- quad (wx1+90,wy1+195,wx2+120,wy2+180,wx3+150,wy3+195,wx4+120,wy4+210);
- quad (wx1+120,wy1+255,wx2+150,wy2+240,wx3+180,wy3+255,wx4+150,wy4+270);
- quad (wx1+150,wy1+315,wx2+180,wy2+300,wx3+210,wy3+315,wx4+180,wy4+330);
- quad (wx1+180,wy1+375,wx2+210,wy2+360,wx3+240,wy3+375,wx4+210,wy4+390);
- quad (wx1+210,wy1+435,wx2+240,wy2+420,wx3+270,wy3+435,wx4+240,wy4+450);
- wx1+=60;
- wx2+=60;
- wx3+=60;
- wx4+=60;
- }
So, I am hoping to find out if there a solution that only uses for loops, while loops and boolean conditionals?
Hope to get feedback soon from the forum - thank you!!!!!!
1