-
Notifications
You must be signed in to change notification settings - Fork 0
/
BikeGearing.pde
87 lines (71 loc) · 1.84 KB
/
BikeGearing.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
void setup() {
size(1600,900);
smooth();
}
void draw() {
background(30);
// Fix co-ordinate system
translate(0,height);
scale(1,-1);
drawBike(50,11);
noLoop();
// save("Big Wheel.png");
}
void drawWheel(float size, float xpos) {
pushMatrix();
translate(xpos, size/2);
ellipse(0,0,size,size);
popMatrix();
}
void drawFrame(float wheelSize, float wheelBase) {
pushMatrix();
pushStyle();
strokeWeight(20);
noFill();
stroke(255);
beginShape();
vertex(wheelBase, wheelSize/2);
quadraticVertex(wheelBase-100,wheelSize/2+100,wheelBase-120,wheelSize/2+200);
vertex(wheelBase-150,wheelSize+175);
vertex(wheelBase-100, wheelSize+175);
bezierVertex(wheelBase+30, wheelSize+175, wheelBase+30, wheelSize+25, wheelBase-100, wheelSize+25);
endShape();
// stroke(255,0,0);
beginShape();
vertex(0,wheelSize/2);
vertex(wheelSize/2+100, wheelSize/2-40);
vertex(wheelBase-141, wheelSize+75);
vertex(wheelBase-145, wheelSize+120);
vertex(wheelSize/2-75,wheelSize+50);
endShape(CLOSE);
beginShape();
vertex(wheelSize/2+100,wheelSize/2-40);
vertex(wheelSize/2-150,wheelSize+250);
endShape();
// stroke(0);
beginShape();
vertex(wheelSize/2-220,wheelSize+275);
bezierVertex(wheelSize/2-150,wheelSize+250,wheelSize/2-80,wheelSize+280,wheelSize/2-50,wheelSize+240);
endShape();
popMatrix();
popStyle();
}
void drawBike() {
drawBike(50,11);
}
void drawBike( float chainring, float sprocket ) {
float wheelSize = 700;
float wheelBase = 1000;
float rearWheelSize = wheelSize * chainring / sprocket;
pushMatrix();
noStroke();
fill(200,150);
scale(min(0.5, height/rearWheelSize));
translate(rearWheelSize/2,0);
drawWheel(wheelSize, 0);
drawWheel(wheelSize, wheelBase);
fill(10,200,200,100);
drawWheel(rearWheelSize, 0);
drawFrame(wheelSize, wheelBase);
popMatrix();
}