Created
March 4, 2013 13:30
-
-
Save bilalsavas/5082256 to your computer and use it in GitHub Desktop.
week 04
This file contains hidden or 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
class ciz | |
{ | |
void Ciz(int a) | |
{ | |
switch (a) | |
{ | |
case 0: | |
//line örnek | |
smooth(); | |
stroke(color(255, 210, 0)); | |
line(lastX2, lastY2, lastX, lastY); | |
lastX2=lastX; | |
lastY2=lastY; | |
break; | |
case 1: | |
//point örnek | |
noSmooth(); | |
point(lastX, lastY); | |
break; | |
case 2: | |
//ellipse | |
smooth(); | |
fill(color(255, 0, 0)); | |
ellipse(lastX, lastY, 20, 20); | |
break; | |
case 3: | |
// svg filedan | |
imaj.disableStyle(); | |
stroke(0); | |
fill(251, 255, 85); | |
shape(imaj, lastX, lastY); | |
break; | |
case 4: | |
myFont = loadFont("Aharoni-Bold-48.vlw"); | |
textFont(myFont, 48); | |
textAlign(CENTER); | |
fill(random(100)); | |
stroke(244); | |
text("HEY", lastX, lastY); | |
break; | |
default: | |
break; | |
} | |
} | |
} |
This file contains hidden or 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
import java.awt.event.*; | |
ciz c; | |
int lastX, lastY; | |
int jumpPixelRate=1; | |
int sayi; | |
PFont myFont; | |
PShape imaj; | |
void setup() | |
{ | |
c = new ciz(); | |
imaj = loadShape("yildiz.svg"); | |
addMouseWheelListener(new MouseWheelListener() { | |
public void mouseWheelMoved(MouseWheelEvent mwe) { | |
mouseWheel(mwe.getWheelRotation()); | |
} | |
} | |
); | |
size(1920, 1080); | |
frameRate(500); | |
lastX=width/2; | |
lastY=height/2; | |
lastX2=width/2; | |
lastY2=height/2; | |
background(#111111); | |
} | |
void draw() | |
{ | |
sayi = int(random(1, 9)); | |
switch(sayi) { | |
case 1: // Yukarı | |
lastY+=jumpPixelRate; | |
c.Ciz(4); | |
break; | |
case 2: // Yukarı ve sağa | |
lastY+=jumpPixelRate; | |
lastX+=jumpPixelRate; | |
c.Ciz(4); | |
break; | |
case 3: // sağ | |
lastX+=jumpPixelRate; | |
c.Ciz(4); | |
break; | |
case 4: // sağ aşağı | |
lastX+=jumpPixelRate; | |
lastY-=jumpPixelRate; | |
c.Ciz(4); | |
break; | |
case 5: // aşağı | |
lastY-=jumpPixelRate; | |
c.Ciz(4); | |
break; | |
case 6: // Sol aşağı | |
lastX-=jumpPixelRate; | |
lastY-=jumpPixelRate; | |
c.Ciz(4); | |
break; | |
case 7: // sol | |
lastX-=jumpPixelRate; | |
c.Ciz(4); | |
break; | |
case 8: // sol üst | |
lastX-=jumpPixelRate; | |
lastY+=jumpPixelRate; | |
c.Ciz(4); | |
break; | |
default: | |
break; | |
} | |
} | |
int lastX2, lastY2; | |
void mousePressed() | |
{ | |
lastX=mouseX; | |
lastY=mouseY; | |
} | |
void mouseWheel(int delta) { | |
if (delta==-1) | |
{ | |
jumpPixelRate+=1; | |
} | |
else if (delta==1) | |
{ | |
if (jumpPixelRate>1) | |
{ | |
jumpPixelRate-=1; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment