28. Condi%onals
Condi;onals
control
the
program
flow.
Each
condi;on
can
be
either
true
or
false.
It
checks
if
a
condi;on
is
true.
If
condi;on
is
true,
the
inner
statements
are
executed.
29. Condi%onals
int
a
=
10;
int
b
=
20;
if
(a
>
10)
{
line(10,
10,
100,
10);
}
if
(b
>=
20)
{
line(10,
20,
100,
20);
}
30. Condi%onals
int
a
=
10;
int
b
=
20;
if
(a
>
10)
{
line(10,
10,
100,
10);
}
if
(b
>
20)
{
line(10,
20,
100,
20);
}
31. Condi%onals
int
a
=
10;
int
b
=
20;
if
(a
>=
10)
{
line(10,
10,
100,
10);
b
=
b
+
1;
}
if
(b
>
20)
{
line(10,
20,
100,
20);
}
32. Comparison
operators
>
greater
than
<
less
than
>=
greater
than
or
equal
to
<=
less
than
or
equal
to
==
equal
to
!=
not
equal
to
34. Exercises
E6:
Download
and
modify
sketch
to
create
different
paPerns.
hTp://%llnagel.com/iuav/PaTernTemplate.zip
Varia%on:
Make
it
interac;ve
so
that
the
results
depends
on
mouse
movements.
Varia%on:
Use
random()
to
randomize
the
graphic.
43. Exercises
E8:
Create
a
simple
drawing
program.
A
visual
element
should
be
drawn
at
the
mouse
posi;on
if
the
user
has
pressed
a
mouse
buPon.
Varia%on:
Use
mouseButton
to
draw
different
shapes
dependent
on
which
mouse
buPon
the
user
has
pressed.
E9:
Draw
an
ellipse
which
increases
its
size
as
long
as
the
mouseBuPon
is
pressed.
Varia%on:
Make
other
visual
variables
dependent
on
the
size
(strokeWeight,
colour,
transparency…)
44. Exercises
E10:
Create
a
buPon
with
two
states:
When
the
mouse
is
over
and
when
it
is
out,
again.
Varia%on:
Implement
mouse
click,
too.
Varia%on:
Use
this
buPon
to
ac;vate
a
behaviour.
45. Assignment
A1:
Create
three
buPons.
Each
of
it
should
trigger
some
ac;on.
-‐
As
group
of
2
students
-‐
Make
sketches
(on
paper)
to
discuss
about
your
idea
-‐
Thursday:
brief
presenta;on
46. boolean
active
=
false;
if
(mousePressed)
{
active
=
true;
}
if
(active)
{
ellipse(x,
y,
10,
10);
}
47. Thank
you.
Copyright
Till
Nagel,
FH
Potsdam,
10/2010