generated from SACHSTech/ProcessingTask6-CreatingMethods
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSketch.java
More file actions
104 lines (82 loc) · 2.14 KB
/
Sketch.java
File metadata and controls
104 lines (82 loc) · 2.14 KB
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
/**
* Name: Processing Task - 6
* Purpose: Create methods
* Author: A. Ng
*/
import processing.core.PApplet;
public class Sketch extends PApplet {
/**
* Called once at the beginning of execution, put your size all in this method
*/
public void settings() {
size(400, 400);
}
public void setup() {
background(255);
}
public void draw() {
// Draws UnknownShape
intDrawUnknownShape(200, 100);
// Draws house
intDrawHouse(30, 200, 30, 50, 100);
//Draws sun
intSun(0);
}
/**
* draws the sun
*
* @param UnknownShapeX: x coordinate of UnknownShape
* @param UnknownShapeY: y coordinate of UnknownShape
*
*/
public void intDrawUnknownShape(int intUnknownShapeX, int intUnknownShapeY) {
stroke(0);
translate(intUnknownShapeX, intUnknownShapeY);
for (int i = 0; i <= 8; i += 1) {
fill(0, 0, 0);
ellipse(0, 0, width/10, height/3);
}
fill(0, 0, 0);
ellipse(0, 0, width/6, height/6);
}
/**
* Draws the house
*
* @param intR: Red value for rgb
* @param intG: Green value for rgb
* @param intB: Blue value for rgb
* @param intHouseX: x coordinate for house and roof
* @param intHouseY: y coordinate for house and roof
*
*/
public void intDrawHouse(int intR, int intG, int intB, int intHouseX, int intHouseY) {
// draw house body
fill(intR, intG, intB);
rect(intHouseX, intHouseY, 150, 125);
// draw house roof
fill(intR, intG, intB);
triangle(intHouseX - 35, intHouseY, intHouseX + 180, intHouseY, intHouseX + 70, intHouseY - 70);
}
/**
* draws the sun
*
* @param intSunX: x coordinate of sun
*
*/
public void intSun(int intSunX) {
intSunX = intReturnSun(intSunX);
fill(255, 255, 0);
ellipse(intSunX, 50, width/6, height/6);
}
/**
* takes the value of intReturnSunX and returns it 50 to the right
*
* @param intReturnSunX: x value of sun
*
*/
public int intReturnSun(int intReturnSunX) {
intReturnSunX = intReturnSunX + 50;
// return value of intSunX and intSunY
return intReturnSunX;
}
}