-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsliders.pde
85 lines (71 loc) · 2.75 KB
/
sliders.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
class Slider{
// -----------------------------ATRIBUTOS--------------------------
PVector
slideR_position,
slideR_target_position,
slideR_hide_position,
slideR_show_position,
slideL_position,
slideL_target_position,
slideL_hide_position,
slideL_show_position;
float
slide_w,
slide_h;
boolean
hover_slideL , hover_slideR;
//----------------------------------CONSTRUCTOR-------------------------------------------
Slider(){
slide_w = ui.thickness;
slide_h = slide_w * 2;
slideR_position = new PVector( width + slide_w * .25 , height * .5 );
slideR_hide_position = new PVector( width + slide_w * .25 , height * .5 );
slideR_show_position = new PVector( width - slide_w * .5, height * .5 );
slideR_target_position = new PVector( width + slide_w * .25 , height * .5 );
slideL_position = new PVector( - slide_w * .25, height * .5 );
slideL_hide_position = new PVector( - slide_w * .25 , height * .5 );
slideL_show_position = new PVector( slide_w * .5, height * .5 );
slideL_target_position = new PVector( - slide_w * .25 , height * .5 );
}
//-------------------------------------------------UPDATE--------------------------------------------------
void update(){
//posicion y auto-hide sliders
if(rectHover(slideL_position , slide_w, slide_h, 20)){
slideL_target_position.set(slideL_show_position) ;
hover_slideL = true;
}
else{
slideL_target_position.set(slideL_hide_position) ;
hover_slideL = false;
}
slideL_position.lerp(slideL_target_position, 0.1);
if(rectHover(slideR_position , slide_w, slide_h, 20)){
slideR_target_position.set(slideR_show_position) ;
hover_slideR = true;
}
else{
slideR_target_position.set(slideR_hide_position) ;
hover_slideR = false;
}
slideR_position.lerp(slideR_target_position, 0.1);
}
//------------------------------------RENDER-----------------------------------------
void render(){
rectMode( CENTER );
noStroke();
fill(c2);
rect( slideR_position.x , slideR_position.y , slide_w , slide_h , ui.corners_radius , 0 , 0 , ui.corners_radius );
rect( slideL_position.x , slideL_position.y , slide_w , slide_h , 0 , ui.corners_radius , ui.corners_radius , 0 );
fill(c4);
triangle(
slideR_position.x - slide_w / 4 , slideR_position.y - slide_w / 3 ,
slideR_position.x - slide_w / 4 , slideR_position.y + slide_w / 3 ,
slideR_position.x + slide_w / 3 , slideR_position.y
);
triangle(
slideL_position.x + slide_w / 4 , slideL_position.y - slide_w / 3 ,
slideL_position.x + slide_w / 4 , slideL_position.y + slide_w / 3 ,
slideL_position.x - slide_w / 3 , slideL_position.y
);
}
}