Ass­i­g­n­m­e­n­t 1

BRITTANY KLAASSENS BKLA6281 450172744 DECO1012 ASSIGNMENT 1

I chose the topic "Motion and energy" for my assignment. Researching about space and stars and how the stars produce energy was my inspiration for this assignment. The way my assignment is designed is that there is simply a star and a house. the amount of points or "spikes" that a star has symbolises how much energy that star has produced. The way I have shown this is that if the star has less than ten points or "spikes" then there will be no lights on in the house. However, when there is more than ten points on the star, you will be able to see the lights in the house on through the window. And for the motion aspect I have also shown that when the energy levels are up, I.E when the points are greater than ten, there is a visual representation of "sparkly particles of energy" moving towards the house. To add a bit of variation to my design I have also included different ways that stars are perceived. This design was made to be included on a series of posters, hence the variation of the design.
THINGS TO IMPROVE FOR NEXT TIME
spend more time researching rather then diving streight into code. Make sure I have a solid idea before i start. Don't try and complete it all at once, complete it periodically.
PLEASE NOTE: MY CODE DOESNT RUN ON PEEP BECAUSE OF THE BUILT IN VARIABLES I HAVE USED

• Show Sketch
``````/** @peep sketchcode */
// DECLARING FLOATS, PSHAPE INT AND PVECTOR
PShape house, houseBorder, roof, leftWindow, rightWindow, hWindowLeft, vWindowLeft, hWindowRight, vWindowRight, door, knob;
int spikes = int(random(4, 20));
PVector[] tips = new PVector[ spikes * 2 ];

void setup(){
size(400,400);
smooth();
background( 0, 0, 50 );

//DECLARING HOUSE VARIABLE AS PSHAPE
house = createShape(GROUP);
//CREATING THE SHAPE OF THE HOUSE BY USING DIFFERENT ELEMENTS
houseBorder = createShape(RECT, 220,240,170,150);
houseBorder.setFill(color(random(204, 255), 204, 255));
roof = createShape(TRIANGLE, 220,240,390,240,305,190);
roof.setFill(color(random(205, 255), random(0, 51), random(127, 153)));
leftWindow = createShape(RECT,235,270,25,80);
// IF THE STAR HAS LESS THAN 10 SPIKES, THEN TURN THE LEFT WINDOW LIGHTS OFF
if(spikes < 10){
leftWindow.setFill(color(0, 0, 50));
//OTHERWISE, TURN THE WINDOW LIGHTS ON
} else{
leftWindow.setFill(color(255, 255, 0));
}
leftWindow.setStroke(color(255));
rightWindow = createShape(RECT, 350,270,25,80);
// IF THE STAR HAS LESS THAN 10 SPIKES, THEN TURN THE RIGHT WINDOW LIGHTS OFF
if(spikes < 10){
rightWindow.setFill(color(0, 0, 50));
//OTHERWISE, TURN THE WINDOW LIGHTS ON
} else{
rightWindow.setFill(color(255, 255, 0));
}
rightWindow.setStroke(color(255));
hWindowLeft = createShape(LINE, 235,310,260,310);
hWindowLeft.setStroke(color(255));
vWindowLeft = createShape(LINE, 247,270,247,350);
vWindowLeft.setStroke(color(255));
hWindowRight = createShape(LINE, 350,310,375,310);
hWindowRight.setStroke(color(255));
vWindowRight = createShape(LINE, 363,270,363,350);
vWindowRight.setStroke(color(255));
door = createShape(RECT, 290,310,30,80);
door.setStroke(color(0));
door.setFill(color(random(76, 153), random(0, 51), random(153, 255)));
knob = createShape(ELLIPSE, 300,343,5,5);
knob.setFill(color(random(205, 255), random(0, 51), random(127, 153)));

// ADD ALL ELEMENTS OF SHAPES TOGETHER TO MAKE ONE SHAPE

//CALLS THE SHAPE SO IT DISPLAYS
shape(house);

float angleOfStar = TWO_PI / tips.length;

// FOR WHEN T IS LESS THAN THE LENGTH OF TIPS, CREATE THE FLOAT X AND Y
for ( int t = 0; t < tips.length; t++ ) {

float x, y;
// IF 2 MODULUS T IS EQUAL TO 0 THEN MAKE X EQUAL TO THE COS OF THE ANGLE TIMES T ALL TIMESED BY THE OUTER RADIUS
// AND MAKE Y EQUAL THE SIN OF THE ANGLE TIMES T ALL TIMESED BY THE OUTER RADIUS
if ( t % 2 == 0 ) {
x = cos( angleOfStar * t ) * outerRadius;
y = sin( angleOfStar * t ) * outerRadius;
//ELSE DO THE EXACTLY THE SAME THING BUT ALL TIMESED BY THE INNER RADIUS
} else {
x = cos( angleOfStar * t ) * innerRadius;
y = sin( angleOfStar * t ) * innerRadius;
}

tips[t] = new PVector( x, y );
}
noLoop();

translate( width/3.5, height/4 );
fill( random(204, 255), random(128, 255) ,51 );
noStroke();

// CREATE THE STAR
beginShape();
for (int t = 0; t < tips.length; t++) {
vertex( tips[t].x, tips[t].y );
}
endShape(CLOSE);
fill(255);

// IF THE SPIKES ARE GREATER THAN TEN, SHOW THE SPARKLY LIGHTS
if(spikes > 10){
stroke(128,255,0);
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));
point(random(500),random(100));

//strokeWeight(10);
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
point(random(500),random(50));
}

}``````