Skip to content

Instantly share code, notes, and snippets.

View bevchou's full-sized avatar

Beverly Chou bevchou

View GitHub Profile
@bevchou
bevchou / ICM_W2_Cloud_Loop
Last active September 19, 2017 03:43
ICM Week 2 Kite Drawing
//position clouds horizontally across the sky
for(horiz = -100; horiz <= width+100; horiz += 200){
//position clouds vertically along top 40% of sky
for(vert = -50; vert <= height*0.60; vert += 120){
//creating the cloud shape
for (i = -20; i <= 20; i += 20) {
fill(230, 237, 235, 170);
//r1 and r2 are random numbers that make the clouds different each time the sketch is run
ellipse(cloud.x+i+horiz, cloud.y+vert, r1, r2);
ellipse(cloud.x+5+horiz, cloud.y+i+vert, r1, r2);
//move clouds
cloud.x += 0.5;
//loop clouds
if (cloud.x > width/3){
cloud.x = 0;
}
ellipse(cloud.x, cloud.y, 50, 40);
ellipse(cloud.x+20, cloud.y-20, 30, 30);
ellipse(cloud.x+30, cloud.y+20, 50, 40);
ellipse(cloud.x+40, cloud.y, 60, 30);
//only change the color when not dragging and when it passes the stop angle
if (mouseAngle >= stopAngle || !dragging) {
changeCol = false;
} else {
changeCol = true;
}
//when slider position hits stop angle
if (angle > stopAngle) {
//change the color
if (changeCol) {
//all the boolean values started as false at the beginning of the sketch
//if slider reaches the area after the stop angle
if (angle > stopAngle || angle < 0) {
//reset arc rotation
angle = 0;
//define when to change color
//if hasn't passed the stop angle before
if (!passedStop) {
//flip boolean value
changeCol = !changeCol;
for (let i = 0; i < height + 20; i += 20) {
for (let m = 0; m < x + 20; m += 20) {
if (colorOn){
r = random (100, 240);
g = random (100, 240);
c = random (100, 240);
fill(r, g, c);
} else {
fill(random(110, 220))
}
colorMode(HSL);
fill(h, s, l);
ellipse(a, b, 30, 30);
if (a >= width - 15 || a <= x + 30) {
directiona = -directiona;
h += random(20, 200);
}
if (b >= height - 15 || b <= 15) {
directionb = -directionb;
h -= random(20,70);
@bevchou
bevchou / PComp HW 3 9_26 Light Up LED Switch
Created September 27, 2017 01:36
First iteration of code to get LED to light up
int LED1Pin = 4;
int switchPin = 7;
void setup(){
pinMode(switchPin, INPUT);
pinMode(LED1Pin, OUTPUT);
Serial.println(switchPin);
}
void loop(){
@bevchou
bevchou / PComp HW 3 9_26 Light Level
Last active September 27, 2017 02:25
Second iteration with light level
//connect LEDs based on pins
//the light sensor must be connected to A5
int LED1Pin = 3;
int LED2Pin = 4;
int LED3Pin = 5;
int LED4Pin = 6;
void setup(){
Serial.begin(9600);
function setup() {
createCanvas(400, 600);
numLayers = 50;
layerHeight = height/numLayers;
startCol = color(177, 233, 239);
endCol = color(26, 33, 68);
colIncr = 1/numLayers;
}
function draw() {