Java I
Jonah Warrenjonah@parsons.edu
http://a.parsons.edu/~java2004
Lab 1
Complete the following exercises. Use this processing page as reference.
- Draw a line.
- Draw a rectangle.
- Draw an ellipse.
- Use stroke(), noStroke(), fill(), and noFill() before a drawing primitive to see their effects
- Replace a coordinate of your line with mouseX and mouseY. (Be sure you are using setup() and loop() functions.)
Homework 1
(Please email me if you have any questions. Please post hw 1.2, 1.3, and 1.4 your site using the export function in the processing environment.)- Create a simple site to hold your homework assigments (no need to get fancy, text only is fine). Email me the address, so I can link it from the Java homepage.
- Create two static abstract compositions in processing using the drawing primitives we learned in class. Make the drawings express opposite concepts (e.g. aggressive vs. calm, symetrical vs. asymetrical, warm vs. cold,...).
- Using mouseX and / or mouseY, create a simple interactive piece using one drawing primitive. Be sure to include a background() statement in your loop() function.
Example:
// An expanding square
// The setup() function is read once when the program begins
void setup()
{
// setting the canvas size
size(100,100);
}
// The loop() function is read until the program is stopped
// Each statement within loop is read in sequence and after
// the last line is read, the first line is read again.
void loop()
{
// resets the background every time through the loop
background(255,255,255);
// determines fill color
fill(245,245,255);
// no outline on this rectangle
noStroke();
// draws the shape from its center point
rectMode(CENTER_DIAMETER);
// draw a rectangle using the mouse coordinates
rect(50, 50, 25 + (mouseX/2), 25 + (mouseX/2));
}
Example:
// Expanding squares
// The setup() function is read once when the program begins
void setup()
{
// setting the canvas size
size(100,100);
}
// The loop() function is read until the program is stopped
// Each statement within loop is read in sequence and after
// the last line is read, the first line is read again.
void loop()
{
// resets the background every time through the loop
background(255,255,255);
// determines fill color
fill(245,245,255);
// no outline on this rectangle
noStroke();
// draws the shape from its center point
rectMode(CENTER_DIAMETER);
// draws a bunch of rectangles using the mouse x position
rect(15, 15, 30 + (mouseX/2), 30 + (mouseX/2));
rect(15, 85, 30 + (mouseX/2), 30 + (mouseX/2));
rect(85, 15, 30 + (mouseX/2), 30 + (mouseX/2));
rect(85, 85, 30 + (mouseX/2), 30 + (mouseX/2));
// changes the fill color
fill(220,220,2550);
rect(50, 50, 25 + (mouseX/2), 30 + (mouseX/2));
fill(230,230,255);
rect(50, 100, 10 + (mouseX/2), 10 + (mouseX/2));
rect(0, 50, 10 + (mouseX/2), 10 + (mouseX/2));
rect(50, 0, 10 + (mouseX/2), 10 + (mouseX/2));
rect(100, 50, 10 + (mouseX/2), 10 + (mouseX/2));
}