@@ -69,19 +69,6 @@ function display_array_pillars(arr) {
69
69
ctx . stroke ( ) ;
70
70
}
71
71
}
72
- function display_array_pillar_spiral ( arr ) {
73
- ctx . clearRect ( 0 , 0 , canvas . width , canvas . height ) ;
74
-
75
- for ( let i = 360 / ( arr . length - 1 ) , c = 0 ; i < 360 ; i += 360 / ( arr . length - 1 ) , c ++ ) {
76
- ctx . beginPath ( ) ;
77
- ctx . strokeStyle = glob_themes [ glob_theme ] [ "color" ] ;
78
- ctx . lineWidth = 4 ;
79
-
80
- ctx . moveTo ( canvas . width / 2 , canvas . height / 2 ) ;
81
- ctx . lineTo ( ( canvas . width / 2 ) + arr [ c ] * Math . cos ( Math . PI * i / 180.0 ) , ( canvas . height / 2 ) + arr [ c ] * Math . sin ( Math . PI * i / 180.0 ) ) ;
82
- ctx . stroke ( ) ;
83
- }
84
- }
85
72
86
73
function draw_pillar ( x1 , y1 , x2 , y2 , color , thickness ) {
87
74
color = color || glob_themes [ glob_theme ] [ "color" ] ;
@@ -97,50 +84,21 @@ function draw_pillar(x1, y1, x2, y2, color, thickness) {
97
84
ctx . stroke ( ) ;
98
85
}
99
86
function display_pillars ( arr , cu_el_i , l , r , cu_el_color , f_area_color ) {
100
- cu_el_color = cu_el_color || "tomato " ;
87
+ cu_el_color = cu_el_color || "#f00 " ;
101
88
f_area_color = f_area_color || "#ffcccc" ;
102
89
103
90
ctx . clearRect ( 0 , 0 , canvas . width , canvas . height ) ;
104
91
let scale = canvas . height / Math . max ( ...arr ) ;
105
92
106
- // -- DRAW NOT FOCUSED -- //
107
- for ( let i = canvas . width / ( arr . length + 1 ) ; i <= ( l + 1 ) * ( canvas . width / ( arr . length + 1 ) ) ; i += canvas . width / ( arr . length + 1 ) ) {
108
- draw_pillar ( i , canvas . height , i , canvas . height - ( arr [ Math . floor ( i / ( canvas . width / ( arr . length + 1 ) ) ) - 1 ] * scale ) ) ;
109
- }
110
- for ( let i = ( r + 2 ) * ( canvas . width / ( arr . length + 1 ) ) ; i <= canvas . width ; i += canvas . width / ( arr . length + 1 ) ) {
111
- draw_pillar ( i , canvas . height , i , canvas . height - ( arr [ Math . floor ( i / ( canvas . width / ( arr . length + 1 ) ) ) - 1 ] * scale ) ) ;
112
- }
93
+ for ( let i = canvas . width / ( arr . length + 1 ) ; i <= canvas . width ; i += canvas . width / ( arr . length + 1 ) ) {
94
+ let index = Math . floor ( ( i / ( canvas . width / ( arr . length + 1 ) ) ) ) - 1 ,
95
+ c = index == cu_el_i ? cu_el_color : index >= l && index <= r ? f_area_color : glob_themes [ glob_theme ] [ "color" ] ,
96
+ t = index == cu_el_i || ( index >= l && index <= r ) ? 5 : 4 ;
113
97
114
- // -- DRAW FOCUSED -- //
115
- for ( let i = ( l + 1 ) * ( canvas . width / ( arr . length + 1 ) ) ; i <= ( r + 2 ) * ( canvas . width / ( arr . length + 1 ) ) ; i += canvas . width / ( arr . length + 1 ) ) {
116
- draw_pillar ( i , canvas . height , i , canvas . height - ( arr [ Math . floor ( i / ( canvas . width / ( arr . length + 1 ) ) ) - 1 ] * scale ) , f_area_color ) ;
117
- }
118
-
119
- // -- DRAW CURRENT ELEMENT(S) -- //
120
- if ( cu_el_i ) {
121
- if ( typeof cu_el_i == "number" ) {
122
- cu_x = ( cu_el_i + 1 ) * ( canvas . width / ( arr . length + 1 ) ) ;
123
- draw_pillar ( cu_x , canvas . height , cu_x , canvas . height - ( arr [ cu_el_i ] * scale ) , cu_el_color , 4 ) ;
124
- } else {
125
- cu_el_i . forEach ( v => {
126
- cu_x = ( v + 1 ) * ( canvas . width / ( arr . length + 1 ) ) ;
127
- draw_pillar ( cu_x , canvas . height , cu_x , canvas . height - ( arr [ v ] * scale ) , cu_el_color , 4 ) ;
128
- } ) ;
129
- }
98
+ draw_pillar ( i , canvas . height , i , canvas . height - ( arr [ Math . floor ( i / ( canvas . width / ( arr . length + 1 ) ) ) - 1 ] * scale ) ,
99
+ c , t ) ;
130
100
}
131
101
}
132
- // function display_pillar_spiral(arr, cu_el_i, l, r, cu_el_color, f_area_color) {
133
- // ctx.clearRect(0, 0, canvas.width, canvas.height);
134
-
135
- // for (let i = 360/(arr.length-1), c = 0; i < 360; i+=360/(arr.length-1), c++) {
136
- // ctx.beginPath();
137
- // ctx.strokeStyle = "black";
138
- // ctx.moveTo(canvas.width/2, canvas.height/2);
139
- // ctx.lineTo((canvas.width/2) + arr[c] *Math.cos(Math.PI*i/180.0), (canvas.height/2) + arr[c] *Math.sin(Math.PI*i/180.0));
140
- // ctx.stroke();
141
- // }
142
- // }
143
-
144
102
145
103
async function doSearchingAlgo ( f ) {
146
104
document . getElementById ( 'algorithm_settings' ) . style . display = "none" ;
0 commit comments