@@ -46,74 +46,44 @@ func _set_shift_bottom(new_shift_bottom):
46
46
queue_redraw ()
47
47
48
48
49
- func float_array_to_Vector2Array (coords : Array ) -> PackedVector2Array :
50
- # Convert the array of floats into a PackedVector2Array.
51
- var array : PackedVector2Array = []
52
- for coord in coords :
53
- array .append (Vector2 (coord [0 ], coord [1 ]))
54
- return array
55
-
56
-
57
49
func _draw ():
58
50
outline_color = color .darkened (0.2 )
59
51
60
- var fill_polygon = [[0.0 , 0.0 ]]
52
+ var fill_polygon : PackedVector2Array
53
+ fill_polygon .append (Vector2 (0.0 , 0.0 ))
61
54
if show_top :
62
- fill_polygon += [
63
- [Constants .KNOB_X + shift_top , 0.0 ],
64
- [Constants .KNOB_X + Constants .KNOB_Z + shift_top , Constants .KNOB_H ],
65
- [Constants .KNOB_X + Constants .KNOB_Z + Constants .KNOB_W + shift_top , Constants .KNOB_H ],
66
- [Constants .KNOB_X + Constants .KNOB_Z * 2 + Constants .KNOB_W + shift_top , 0.0 ],
67
- ]
68
- fill_polygon += [
69
- [size .x , 0.0 ],
70
- [size .x , size .y ],
71
- [Constants .KNOB_X + Constants .KNOB_Z * 2 + Constants .KNOB_W + shift_bottom , size .y ],
72
- [Constants .KNOB_X + Constants .KNOB_Z + Constants .KNOB_W + shift_bottom , size .y + Constants .KNOB_H ],
73
- [Constants .KNOB_X + Constants .KNOB_Z + shift_bottom , size .y + Constants .KNOB_H ],
74
- [Constants .KNOB_X + shift_bottom , size .y ],
75
- [0.0 , size .y ],
76
- [0.0 , 0.0 ],
77
- ]
78
-
79
- var stroke_polygon = []
80
- if shift_top == 0 :
81
- stroke_polygon += [
82
- [0.0 , 0.0 ],
83
- ]
84
- else :
85
- stroke_polygon += [
86
- [shift_top , 0.0 ],
87
- ]
55
+ fill_polygon .append (Vector2 (Constants .KNOB_X + shift_top , 0.0 ))
56
+ fill_polygon .append (Vector2 (Constants .KNOB_X + Constants .KNOB_Z + shift_top , Constants .KNOB_H ))
57
+ fill_polygon .append (Vector2 (Constants .KNOB_X + Constants .KNOB_Z + Constants .KNOB_W + shift_top , Constants .KNOB_H ))
58
+ fill_polygon .append (Vector2 (Constants .KNOB_X + Constants .KNOB_Z * 2 + Constants .KNOB_W + shift_top , 0.0 ))
59
+
60
+ fill_polygon .append (Vector2 (size .x , 0.0 ))
61
+ fill_polygon .append (Vector2 (size .x , size .y ))
62
+ fill_polygon .append (Vector2 (Constants .KNOB_X + Constants .KNOB_Z * 2 + Constants .KNOB_W + shift_bottom , size .y ))
63
+ fill_polygon .append (Vector2 (Constants .KNOB_X + Constants .KNOB_Z + Constants .KNOB_W + shift_bottom , size .y + Constants .KNOB_H ))
64
+ fill_polygon .append (Vector2 (Constants .KNOB_X + Constants .KNOB_Z + shift_bottom , size .y + Constants .KNOB_H ))
65
+ fill_polygon .append (Vector2 (Constants .KNOB_X + shift_bottom , size .y ))
66
+ fill_polygon .append (Vector2 (0.0 , size .y ))
67
+ fill_polygon .append (Vector2 (0.0 , 0.0 ))
68
+
69
+ var stroke_polygon : PackedVector2Array
70
+ stroke_polygon .append (Vector2 (shift_top , 0.0 ))
88
71
if show_top :
89
- stroke_polygon += [
90
- [Constants .KNOB_X + shift_top , 0.0 ],
91
- [Constants .KNOB_X + Constants .KNOB_Z + shift_top , Constants .KNOB_H ],
92
- [Constants .KNOB_X + Constants .KNOB_Z + Constants .KNOB_W + shift_top , Constants .KNOB_H ],
93
- [Constants .KNOB_X + Constants .KNOB_Z * 2 + Constants .KNOB_W + shift_top , 0.0 ],
94
- ]
95
- stroke_polygon += [
96
- [size .x , 0.0 ],
97
- [size .x , size .y ],
98
- [Constants .KNOB_X + Constants .KNOB_Z * 2 + Constants .KNOB_W + shift_bottom , size .y ],
99
- [Constants .KNOB_X + Constants .KNOB_Z + Constants .KNOB_W + shift_bottom , size .y + Constants .KNOB_H ],
100
- [Constants .KNOB_X + Constants .KNOB_Z + shift_bottom , size .y + Constants .KNOB_H ],
101
- [Constants .KNOB_X + shift_bottom , size .y ],
102
- ]
103
- if shift_bottom == 0 :
104
- stroke_polygon += [
105
- [0.0 , size .y ],
106
- ]
107
- else :
108
- stroke_polygon += [
109
- [shift_bottom , size .y ],
110
- ]
72
+ stroke_polygon .append (Vector2 (Constants .KNOB_X + shift_top , 0.0 ))
73
+ stroke_polygon .append (Vector2 (Constants .KNOB_X + Constants .KNOB_Z + shift_top , Constants .KNOB_H ))
74
+ stroke_polygon .append (Vector2 (Constants .KNOB_X + Constants .KNOB_Z + Constants .KNOB_W + shift_top , Constants .KNOB_H ))
75
+ stroke_polygon .append (Vector2 (Constants .KNOB_X + Constants .KNOB_Z * 2 + Constants .KNOB_W + shift_top , 0.0 ))
76
+
77
+ stroke_polygon .append (Vector2 (size .x , 0.0 ))
78
+ stroke_polygon .append (Vector2 (size .x , size .y ))
79
+ stroke_polygon .append (Vector2 (Constants .KNOB_X + Constants .KNOB_Z * 2 + Constants .KNOB_W + shift_bottom , size .y ))
80
+ stroke_polygon .append (Vector2 (Constants .KNOB_X + Constants .KNOB_Z + Constants .KNOB_W + shift_bottom , size .y + Constants .KNOB_H ))
81
+ stroke_polygon .append (Vector2 (Constants .KNOB_X + Constants .KNOB_Z + shift_bottom , size .y + Constants .KNOB_H ))
82
+ stroke_polygon .append (Vector2 (Constants .KNOB_X + shift_bottom , size .y ))
83
+
84
+ stroke_polygon .append (Vector2 (shift_bottom , size .y ))
111
85
if shift_top + shift_bottom == 0 :
112
- stroke_polygon += [
113
- [0.0 , 0.0 ],
114
- ]
115
-
116
- var packed_fill_polygon = float_array_to_Vector2Array (fill_polygon )
117
- var packed_stroke_polygon = float_array_to_Vector2Array (stroke_polygon )
118
- draw_colored_polygon (packed_fill_polygon , color )
119
- draw_polyline (packed_stroke_polygon , outline_color , Constants .OUTLINE_WIDTH )
86
+ stroke_polygon .append (Vector2 (0.0 , 0.0 ))
87
+
88
+ draw_colored_polygon (fill_polygon , color )
89
+ draw_polyline (stroke_polygon , outline_color , Constants .OUTLINE_WIDTH )
0 commit comments