/
Gbezier.pde
73 lines (58 loc) · 1.35 KB
/
Gbezier.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
class Gbezier{
PVector Start;
PVector StartCon;
PVector End;
PVector EndCon;
PVector Target;
float bezierstrokeWeight;
float strokecolor;
Gbezier(PVector Start, PVector StartCon, PVector EndCon, PVector End){
this.Start= Start;
this.StartCon = StartCon;
this.End = End;
this.EndCon = EndCon;
}
void display(){
strokeCap(SQUARE);
strokeWeight(bezierstrokeWeight);
stroke(strokecolor,200);
noFill();
bezier(Start.x,Start.y,StartCon.x,StartCon.y,EndCon.x,EndCon.y,End.x,End.y);
}
void setweight(float bezierstrokeWeight){
this.bezierstrokeWeight = bezierstrokeWeight;
}
void setcolor(float strokecolor){
this.strokecolor = strokecolor;
}
void transall(PVector Start1, PVector StartCon1, PVector EndCon1, PVector End1){
update(Start, Start1);
update(StartCon,StartCon1);
update(End, End1);
update(EndCon,EndCon1);
}
void transhalf(PVector Start1, PVector StartCon1, PVector EndCon1, PVector End1){
Start = Start1;
update(StartCon,StartCon1);
update(End, End1);
update(EndCon,EndCon1);
}
void transend(PVector End1, PVector EndCon1){
update(End, End1);
update(EndCon,EndCon1);
}
void update(PVector pos, PVector target){
float vel = 0.05;
PVector v= PVector.div((PVector.sub(target,pos)),1/vel);
if(pos==target){
}else{
pos.add(v);
}
}
PVector getEnd(){
return End;
}
PVector getEndcon(){
return EndCon;
}
}