-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLesson 5 - Loops.js
114 lines (75 loc) · 2.22 KB
/
Lesson 5 - Loops.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
function setup() {
//Setting up background and canvas
createCanvas(550, 800);
background(200);
}
function draw() {
//TRIANGLE
//triangleX is the bottom left
let triangleX = 100;
while(triangleX < 500){
//the colour of the trianlge
//triangle x will always be a multiple of 100
//if you divide by 100 you can find how many traingles you have drew
//63.75 is the inital blue and if you times it by how many triangles you can increase it
fill(0, 0, 63.75 * (triangleX / 100));
//Drawing the triangles
triangle(triangleX, 100, triangleX + 25, 25, triangleX + 50, 100);
//Distance between the different triangles
triangleX += 100;
}
//SQUARES & LINES
//Initial square variables
//Colour
let squareRed = 0;
//Y coord
let squareY = 25;
//Inital line values
let lineColour = 0;
for(let rectangleCount = 7; rectangleCount > 0; rectangleCount--){
//reseting the stroke colour
stroke(0);
//Setting the colour
fill(squareRed, 0, 0);
//Drawing the squares
//Square on the left
square(30, squareY, 50);
//Square on the right (math makes sure its the same distance away from the border as the left square)
square(width - 50 - 30, squareY, 50);
//Changing values
squareY += 50;
squareRed += 36;
//Line part
stroke(lineColour);
//X will be the same as the square + its width for all the left lines
//X will be the same as the square for the right lines
//Y will be the same as the square but minus its width
//Line on the left
line(width/2, height, 80, squareY - 50);
//Line on the right
line(width/2, height, width - 50 - 30, squareY - 50);
//Changing the colour
lineColour += 36;
}
//resets the stroke colour
stroke(0);
//CIRCLES
//Setting intial variables
let circleCount = 5;
//Colour
let circleGreen = 55;
//X coord
let circleX = 225;
while(circleCount > 0){
//Setting the circle colours
fill(0, circleGreen, 0);
//Drawing the circles
circle(circleX, 150, 25);
//Changing the amount of circles left to draw
circleCount--;
//Changine the coordanites
circleX += 25;
//Changing the colour
circleGreen += 50;
}
}