Last active
October 22, 2015 14:05
-
-
Save pyeseul/63ac1168263d494e2de6 to your computer and use it in GitHub Desktop.
Processing Exercise 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int letterHeight = 100; | |
int letterWidth = letterHeight/2; | |
int y = 20; | |
void setup() { | |
size(800, 600, P2D); | |
background(255); | |
fill(0); | |
smooth(); | |
strokeWeight(0.5); | |
noLoop(); | |
} | |
void draw() { | |
drawString("yeseul"); | |
} | |
void drawString(String s) { | |
for (int i = 0; i < s.length(); i++) { | |
switch(s.charAt(i)) { | |
case 'y': | |
myDrawY(i*letterWidth, y); | |
break; | |
case 'e': | |
myDrawE(i*letterWidth, y); | |
break; | |
case 's': | |
myDrawS(i*letterWidth, y); | |
break; | |
case 'u': | |
myDrawU(i*letterWidth, y); | |
break; | |
case 'l': | |
myDrawL(i*letterWidth, y); | |
break; | |
} | |
} | |
} | |
void myDrawY(int x, int y){ | |
stroke(0); | |
triangle(x, y, x+letterWidth, y, x+letterWidth/2, y+letterHeight/2); | |
line(x+letterWidth/2, y+letterHeight/2, x, y+letterHeight); | |
} | |
void myDrawE(int x, int y){ | |
ellipse(x+letterWidth/2, y+letterWidth/2, letterWidth, letterHeight/2); | |
stroke(255); | |
line(x, y+letterWidth/2, x+letterWidth, y+letterWidth/2); | |
} | |
void myDrawS(int x, int y){ | |
arc(x+letterWidth/2, y+letterWidth/2, letterWidth, letterWidth, HALF_PI, PI+HALF_PI); | |
arc(x+letterWidth/2, y+letterWidth*3/2, letterWidth, letterWidth, PI+HALF_PI, TWO_PI+HALF_PI); | |
} | |
void myDrawU(int x, int y){ | |
stroke(0); | |
triangle(x, y, x+letterWidth, y, x+letterWidth/2, y+letterHeight/2); | |
} | |
void myDrawL(int x, int y){ | |
stroke(0); | |
line(x, y, x, y+letterHeight); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment