refactor: update spacing for operators and method params

This commit is contained in:
eddex 2020-10-04 15:21:02 +02:00
parent 265e28d1f1
commit a743850f13

View File

@ -221,20 +221,45 @@ func draw_chart():
func draw_outlines():
if boxed:
Outlines.set_default_color(box_color)
OutlinesTween.interpolate_method(Outlines,"add_point",
Vector2(origin.x,0),Vector2(SIZE.x,0),drawing_duration*0.5,Tween.TRANS_QUINT,Tween.EASE_OUT)
OutlinesTween.interpolate_method(
Outlines,
"add_point",
Vector2(origin.x, 0),
Vector2(SIZE.x, 0),
drawing_duration * 0.5,
Tween.TRANS_QUINT,
Tween.EASE_OUT)
OutlinesTween.start()
yield(OutlinesTween, "tween_all_completed")
OutlinesTween.interpolate_method(Outlines,"add_point",
Vector2(SIZE.x,0),Vector2(SIZE.x,origin.y),drawing_duration*0.5,Tween.TRANS_QUINT,Tween.EASE_OUT)
OutlinesTween.interpolate_method(
Outlines,
"add_point",
Vector2(SIZE.x,0),
Vector2(SIZE.x, origin.y),
drawing_duration * 0.5,
Tween.TRANS_QUINT,
Tween.EASE_OUT)
OutlinesTween.start()
yield(OutlinesTween,"tween_all_completed")
OutlinesTween.interpolate_method(Outlines,"add_point",
Vector2(SIZE.x,origin.y),origin,drawing_duration*0.5,Tween.TRANS_QUINT,Tween.EASE_OUT)
OutlinesTween.interpolate_method(
Outlines,
"add_point",
Vector2(SIZE.x,origin.y),
origin,
drawing_duration * 0.5,
Tween.TRANS_QUINT,
Tween.EASE_OUT)
OutlinesTween.start()
yield(OutlinesTween, "tween_all_completed")
OutlinesTween.interpolate_method(Outlines,"add_point",
origin,Vector2(origin.x,0),drawing_duration*0.5,Tween.TRANS_QUINT,Tween.EASE_OUT)
OutlinesTween.interpolate_method(
Outlines,
"add_point",
origin,
Vector2(origin.x, 0),
drawing_duration * 0.5,
Tween.TRANS_QUINT,
Tween.EASE_OUT)
OutlinesTween.start()
yield(OutlinesTween, "tween_all_completed")
@ -246,19 +271,33 @@ func draw_v_grid():
v_grid.set_width(1)
v_grid.set_default_color(v_lines_color)
add_label(point + Vector2(-const_width / 2 * x_chors[p].length(), font_size / 2), x_chors[p])
GridTween.interpolate_method(v_grid,"add_point",point,point-Vector2(0,SIZE.y-OFFSET.y),drawing_duration/(x_chors.size()),Tween.TRANS_EXPO,Tween.EASE_OUT)
GridTween.interpolate_method(
v_grid,
"add_point",
point,
point - Vector2(0, SIZE.y - OFFSET.y),
drawing_duration / (x_chors.size()),
Tween.TRANS_EXPO,
Tween.EASE_OUT)
GridTween.start()
yield(GridTween,"tween_all_completed")
func draw_h_grid():
for p in y_chors.size():
var point: Vector2 = origin-Vector2(0,(p)*y_pass)
var point: Vector2 = origin - Vector2(0, p * y_pass)
var h_grid: Line2D = Line2D.new()
Grid.add_child(h_grid)
h_grid.set_width(1)
h_grid.set_default_color(h_lines_color)
add_label(point-Vector2(y_chors[p].length() * const_width + font_size, font_size / 2), y_chors[p])
GridTween.interpolate_method(h_grid,"add_point",point,Vector2(SIZE.x,point.y),drawing_duration/(y_chors.size()),Tween.TRANS_EXPO,Tween.EASE_OUT)
GridTween.interpolate_method(
h_grid,
"add_point",
point,
Vector2(SIZE.x,point.y),
drawing_duration / (y_chors.size()),
Tween.TRANS_EXPO,
Tween.EASE_OUT)
GridTween.start()
yield(GridTween,"tween_all_completed")
@ -287,17 +326,31 @@ func draw_function(f_index: int, function: Array):
pointv.connect("_mouse_entered", self, "show_data")
pointv.connect("_mouse_exited", self, "hide_data")
pointv.connect("_point_pressed", self, "point_pressed")
pointv.create_point(point_shape, function_colors[f_index], Color.white, function[point],
pointv.create_point(
point_shape,
function_colors[f_index],
Color.white, function[point],
pointv.format_value(point_values[f_index][point], false, false),
y_labels[point if invert_chart else f_index] as String)
if point < function.size() - 1:
FunctionsTween.interpolate_method(line,"add_point",function[point],function[point+1],drawing_duration/function.size(),Tween.TRANS_QUINT,Tween.EASE_OUT)
FunctionsTween.interpolate_method(
line,
"add_point",
function[point],
function[point + 1],
drawing_duration / function.size(),
Tween.TRANS_QUINT,
Tween.EASE_OUT)
FunctionsTween.start()
yield(FunctionsTween, "tween_all_completed")
func construct_line(line: Line2D, backline: Line2D, f_index: int, function: Array):
var midtone = Color(Color(function_colors[f_index]).r,Color(function_colors[f_index]).g,Color(function_colors[f_index]).b,Color(function_colors[f_index]).a/2)
var midtone = Color(
Color(function_colors[f_index]).r,
Color(function_colors[f_index]).g,
Color(function_colors[f_index]).b,
Color(function_colors[f_index]).a / 2)
backline.set_width(3)
backline.set_default_color(midtone)
backline.antialiased = true
@ -380,11 +433,11 @@ func structure_datas(database: Array, are_values_columns: bool, x_values_index:
y_margin_min = to_order_min.pop_front()
v_dist = y_decim * pow(10.0,str(margin).length() - 2)
var multi = 0
var p = (v_dist*multi) + ((y_margin_min) if not origin_at_zero else 0)
var p = (v_dist * multi) + (y_margin_min if not origin_at_zero else 0)
y_chors.append(p as String)
while p < margin:
multi+=1
p = (v_dist*multi) + ((y_margin_min) if not origin_at_zero else 0)
p = (v_dist * multi) + (y_margin_min if not origin_at_zero else 0)
y_chors.append(p as String)
# draw x_labels
@ -398,11 +451,11 @@ func structure_datas(database: Array, are_values_columns: bool, x_values_index:
x_margin_min = to_order.pop_front()
h_dist = x_decim * pow(10.0, str(margin).length() - 2)
multi = 0
p = (h_dist*multi) + ((x_margin_min) if not origin_at_zero else 0)
p = (h_dist * multi) + (x_margin_min if not origin_at_zero else 0)
x_labels.append(p as String)
while p < margin:
multi += 1
p = (h_dist*multi) + ((x_margin_min) if not origin_at_zero else 0)
p = (h_dist * multi) + (x_margin_min if not origin_at_zero else 0)
x_labels.append(p as String)
func build_chart():
@ -467,20 +520,30 @@ func calculate_coordinates():
for function in y_coordinates.size():
for function_value in y_coordinates[function].size():
if are_values_columns:
point_positions[function_value].append(Vector2(x_coordinates[function]+origin.x, origin.y-y_coordinates[function][function_value]))
point_values[function_value].append([x_datas[function_value],y_datas[function_value][function]])
point_positions[function_value].append(Vector2(
x_coordinates[function] + origin.x,
origin.y - y_coordinates[function][function_value]))
point_values[function_value].append(
[x_datas[function_value], y_datas[function_value][function]])
else:
point_positions[function].append(Vector2(x_coordinates[function_value]+origin.x,origin.y-y_coordinates[function][function_value]))
point_values[function].append([x_datas[function_value],y_datas[function_value][function]])
point_positions[function].append(Vector2(
x_coordinates[function_value] + origin.x,
origin.y - y_coordinates[function][function_value]))
point_values[function].append(
[x_datas[function_value], y_datas[function_value][function]])
else:
for cluster in y_coordinates.size():
for y in y_coordinates[cluster].size():
if are_values_columns:
point_values[y].append([x_datas[cluster],y_datas[cluster][y]])
point_positions[y].append(Vector2(x_coordinates[cluster]+origin.x,origin.y-y_coordinates[cluster][y]))
point_positions[y].append(Vector2(
x_coordinates[cluster] + origin.x,
origin.y - y_coordinates[cluster][y]))
else:
point_values[cluster].append([x_datas[y],y_datas[cluster][y]])
point_positions[cluster].append(Vector2(x_coordinates[y]+origin.x,origin.y-y_coordinates[cluster][y]))
point_positions[cluster].append(Vector2(
x_coordinates[y] + origin.x,
origin.y - y_coordinates[cluster][y]))
func redraw():
build_chart()