PROJECT 3:
"Yes, But Is It
Art?"
CSE100/INFO100 Fluency with Information Technology
Autumn 2001
Introduction
Art has always been
considered a form of self-expression and creative imagination that is expressed
in a musical, literary, visual,
or performance context.
When we think of visual art as in painting or drawing, we think of a
series of shapes, colors, lines, etc. placed on some tangible medium to be
viewed either by artist or community.
One way we often think of art is as a form of visual communication: an experience that might be aesthetic, emotional, intellectual, or a
combination of these qualities.
Historically, new
technologies have presented new opportunities for visual communication and
artistic expression. Photography is a case in point. Originally, rejected as an
artistic medium, photography is now embraced as an accepted art form.
Similarly, plastics have found their place as a medium in sculpture. And
acrylics stand along side of oils as a viable painting
medium. Each medium brings with it its own interactions with the basic elements
of color, line, shape, and form, and poses its own challenges for expression.
In this vein, computer technologies can be seen as yet another "new
medium".
In this project you will explore the potential of this
“new medium” and form opinions on the ability of computer technologies as a
viable medium for true artistic expression.
How creative can you be? How creative can you program the computer to
be? Note that these are two very different questions and reflect two different
approaches to exploring creativity with computation.
Visual Basic 6.0 was not designed as a graphics package, or even intended for
use in any serious graphics applications. But with a little imagination, almost
any general purpose programming facility can be used to do interesting things
graphically. Our goal is not to push the limits of graphics; we want to push
the limits of VB 6.0. What can you think of? How creative can you be?
You many choose any
visual design problem for your project, as long as it is in good taste and
permits comfortable viewing by everyone in the course. Here are some possible
ideas you may wish to incorporate:
Objectives
Part I: Due Wednesday, November 14,
Plan on constructing two separate
designs, one for Part I of this assignment and one for Part II. The second can be an
embellishment of the first, or it can be entirely different. One strategy might
be to accomplish the technical requirements listed below for Part I and
concentrate on aesthetics exclusively for Part II. At a minimum, Part II must be embellished in
a significant way if you are using Part I and extending it.
What To Do:
a.
First of all, writing procedures is the purpose of the project.
b.
Secondly, and more importantly, procedures allow you to organize the
development, encapsulating effects that you can then compose into more complex
images.
c.
Therefore, the Form_Click()event procedure should not be a very long
piece of code, but rather it should merely orchestrate the calling of
procedures that do the work, probably by calling other procedures.
· A procedure with two or more parameters
·
A procedure you write that calls
another procedure of yours
·
A procedure that is called more than five times
·
A Do While
· The use of a random number
Grading Criteria:
A VB6 program that contains the technical elements in number 4 above.
How to Turn in Your Project…
Turn in your VB6 code using Electronic Submission. Be sure to turn in the VB6 project, form and
executable.
In addition, turn in a hardcopy of your project, as
follows:
Turn in the paper copy to the
Part II: Due Wednesday, November 21,
What to do:
Grading Criteria:
1. A VB6 program that is visually
interesting.
2. The thoughtfulness of your discussion on
about creativity and computation.
How to Turn in Your Project…
Turn in your VB6 code using Electronic Submission. Be sure to turn in the VB6 project, form and
executable.
In addition, turn in a hardcopy of your project, as
follows:
Turn in the paper copy to the
Appendix to Project 3: VB6 Resources
VB6 is not a graphics programming system, but there are
many things that can be done with the basic primitives that it supplies. Chapter 15 holds information on iteration as
well as shape generation procedures. You can find information about random
numbers at the following web site:
·
Random
Numbers and Visual Basic
http://www.vbexplorer.com/random/random_numbers_1.asp
In an effort to provide some additional useful raw
material for creating interesting images, consider the following resources.
1.
The size of the window that you have to work with is given
by the ScaleWidth and ScaleHeight properties.
Form1.WindowState
= 2
After
this, ScaleWidth and ScaleHeight will be huge. Find out by running
this version of the Form_Click() procedure from a normal size window:
Private Sub
Form_Click()
MsgBox "The initial size is
" & ScaleWidth & " x "
& ScaleHeight
Form1.WindowState
= 2
MsgBox "The new size is
" & ScaleWidth & " x "
& ScaleHeight
End Sub
Form1.BackColor
= RGB(221,31,203)
which turns the background to "Husky purple". Of
course, it is possible to change these values dynamically.
4.
It is possible to develop the code discussed in the book
to find the proper R-G-B values for your desired colors, but that kind of code
is already running in many applications. So, to find the R-G-B values for a
given color, go to some "More Colors" window from some other application,
e.g. Word. (From Word go Format>Background>More
Colors>Custom to
get to one of the places where the color palette is available; there are many
others, of course.)
When you set the color you want, read off the R-G-B numbers that define for the
color you want, and then use them in your program when calling the RBG() procedure.
5.
To draw a box on , use the line drawing facilities
as follows:
FillColor = RGB(_,_,_)
‘ Say
what color is inside the rectangle
Form1.Line
(valueforboxLeft, valueforboxTop)
– (valueforboxLeft + boxWidth, _
valueforboxTop
+ boxHeight), RGB(_,_,_),B
where you must put everything after the first line on a single
line in your program. Also, fill in the blank R-G-B values with numbers or
variable values from 0 through 255. Remember the key points about this call,
namely the facts that you are specifying two corners of a rectangle, the "—" is required between the two
corners, and the "B," which means "box," is
required. If you don’t put in the second RGB()call shown, then the line around
the rectangle is black.
Drawing
a circle is even easier:
FillColor = RGB(_,_,_)
Form1.Circle
(centerLeft, centerTop), radiusValue, RGB(_,_,_)
If
the RGB() is omitted, the line around the circle is
black. Of course, (centerLeft,
centerTop) is the center point of the circle, and radius is the radius.
6.
An interesting technique is a splatter painting or
background. Here’s one way to do this:
Private Sub
Form_Click()
Dim
count As Integer ‘ define an iteration variable
Dim
nXCoord As Integer
Dim
nYCoord As Integer
Dim
nRed As Integer
Dim
nGreen As Integer
Dim
nBlue As Integer
Randomize
' Set up random number generator
count
= 0
Do While
count < 10000
count
= count + 1
nXCoord = Int(Rnd(1) * Form1.ScaleWidth)
nYCoord
= Int(Rnd(1) * Form1.ScaleHeight)
nRed = Int(Rnd(1) * 255)
nGreen
= Int(Rnd(1) * 255)
nBlue = Int(Rnd(1) * 255)
PSet (nXCoord,
nYCoord), RGB(nRed, nGreen, nBlue)
End Sub
The
form starts out with a white background. It enters a loop in which it generates
on each cycle a random (x, y) coordinate and a random color as an RGB triple,
and sets the pixel at that position to that color. The loop goes through 10,000
iterations. It is not possible to go through more than 32,767 using a standard Integer. So, to do more iterations of
splattering, you will need to enclose the basic loop shown in another, outer
loop.
A key
idea in this example is random numbers. Computers cannot generate true random
numbers, because they follow instructions faithfully. But, they can generate
number sequences that "look" random and that can be verified
scientifically to have the same properties as random numbers. To use random
numbers, you need to do two things: First, you must put the Randomize command at the start of your
program so the computer sets up the randomization. Second, when you want a
random number, just write the function Rnd(1). The result is a random number
between 0 and 1. So, the procedure above finds a random color value between 0
and 255 by the code:
Int(Rnd(1)*255)
Suppose
the random number from Rnd(1) was 0.5 (which doesn’t seem too
random, I suppose!), then the product would yield 127.5 Since this must be
converted into a whole number, the Int function is applied to the result
to throw away the fractional digits, giving 127.
Note:
The splatters will normally cover the form, including any letters you might
already have on the form. If you want to avoid covering up black letters,
change the form’s drawing technique DrawMode to 9, Mask Pen. The DrawMode gives different effects, so you might want to experiment with them.
7.
Recall in your first VB6 lab how we got the clock to
"run" by redisplaying it whenever the time event went off? That same
idea can be used for animations, too. Place a timer control on your form as we
did before. (Don’t worry about where you place it, because it will disappear
when the program starts running.)
Next, declare a global variable at the top of your form code:
Dim
tickTime As Integer
Dim yDim
As Integer
so that it is global to the timer routine. Next, initialize the tickTime variable in the Form_Load() event procedure:
Private Sub
Form_Load()
tickTime
= 0
End Sub
Finally, write some code to draw
on each time tick:
Private Sub
tmrMyClock_Timer()
FillStyle = 0 ‘Set style
to opaque
FillColor = RGB(221,
31, 203) ‘Husky
purple
If
tickTime * 200 > ScaleWidth
Then
yDim
= yDim + 200
tickTime
= 0
End If
Line (200
+ tickTime * 200, yDim)-(400
+ tickTime * 200, yDim + _
200), RGB(221, 31, 203), B
tickTime
= tickTime + 1
End Sub
Remember
the line drawing command must be on a single line. Then, whenever the timer
goes off, the box is drawn in the next position. Run it. Nothing happen? Did
you set the Interval on the timer? Experiment with different
"speeds", smaller numbers make the timer go off more frequently,
speeding up the image drawn. How does it stop from running off the form?