Professional Documents
Culture Documents
Week
2
Subsection
2:
Example
1:
size(120,300);
int
y
=
20;
int
distance
=
10;
int
h
=
10;
rect(10,y,100,h);
y
=
y
+
distance
+
h;
h
=
h
*
2;
rect(10,y,100,h);
y
=
y
+
distance
+
h;
h
=
h
*
2;
rect(10,y,100,h);
y
=
y
+
distance
+
h;
h
=
h
*
2;
rect(10,y,100,h);
Week
2
Subsection
3:
These
programs
are
used
throughout
the
videos
and
are
often
re-used
with
minor
changes
to
things
like
the
size
of
the
canvas.
Ive
split
the
second
program
into
two
separate
examples
to
show
you
what
I
mean
by
this.
Example
1:
size(200,200);
background(120,40,40);
rect(90,80,20,40);
Example
2a:
size(200,200);
background(120,40,40);
rect(width/2-20,height/2-20,20,40);
Example
2b:
size(300,300);
background(120,40,40);
rect(width/2-20,height/2-20,20,40);
Example
3:
size(200,200);
background(120,40,40);
rect(width/2-20,height/2-20,width/10,height/5);
Example
4:
size(200,200);
background(120,40,40);
int
hwid=width/2;
int
hhei=height/2;
int
woffset=width/10;
int
hoffset=height/5;
rect(hwid-(woffset/2),hhei-(hoffset/2),woffset,hoffset);