Refactored draw code

This commit is contained in:
Luke Hubmayer-Werner 2020-05-20 17:16:36 +09:30
parent c8ab4d077b
commit 38ff9c03b7
1 changed files with 13 additions and 13 deletions

View File

@ -58,38 +58,38 @@ func _draw() -> void:
for col in cols: for col in cols:
var color = COLORS[cell_colors.get_cell(row, col)] var color = COLORS[cell_colors.get_cell(row, col)]
if color != null: if color != null:
draw_rect(Rect2(Vector2(h0+col*h_space, v0+row*v_space), Vector2(h_space, v_space)), color, true) draw_rect(Rect2(grid_corner(row, col), Vector2(h_space, v_space)), color, true)
# Lines # Lines
for row in rows: for row in rows:
for col in cols: for col in cols:
if corner_marks.get_flag(row, col, CornerMark.L_RIGHT): if corner_marks.get_flag(row, col, CornerMark.L_RIGHT):
draw_line(Vector2(h0+col*h_space, v0+row*v_space), Vector2(h0+(col+1)*h_space, v0+row*v_space), Color.blue) draw_line(grid_corner(row, col), grid_corner(row, col+1), Color.blue)
elif corner_marks.get_flag(row, col, CornerMark.X_RIGHT): elif corner_marks.get_flag(row, col, CornerMark.X_RIGHT):
draw_line(Vector2(h0+(col+0.4)*h_space, v0+row*v_space), Vector2(h0+(col+0.6)*h_space, v0+row*v_space), Color.red) draw_line(grid_corner(row, col+0.4), grid_corner(row, col+0.6), Color.red)
else: else:
draw_line(Vector2(h0+col*h_space, v0+row*v_space), Vector2(h0+(col+1)*h_space, v0+row*v_space), Color.white) draw_line(grid_corner(row, col), grid_corner(row, col+1), Color.white)
if corner_marks.get_flag(row, col, CornerMark.L_DOWN): if corner_marks.get_flag(row, col, CornerMark.L_DOWN):
draw_line(Vector2(h0+col*h_space, v0+row*v_space), Vector2(h0+col*h_space, v0+(row+1)*v_space), Color.blue) draw_line(grid_corner(row, col), grid_corner(row+1, col), Color.blue)
elif corner_marks.get_flag(row, col, CornerMark.X_DOWN): elif corner_marks.get_flag(row, col, CornerMark.X_DOWN):
draw_line(Vector2(h0+col*h_space, v0+(row+0.4)*v_space), Vector2(h0+col*h_space, v0+(row+0.6)*v_space), Color.red) draw_line(grid_corner(row+0.4, col), grid_corner(row+0.6, col), Color.red)
else: else:
draw_line(Vector2(h0+col*h_space, v0+row*v_space), Vector2(h0+col*h_space, v0+(row+1)*v_space), Color.white) draw_line(grid_corner(row, col), grid_corner(row+1, col), Color.white)
for col in cols: for col in cols:
if corner_marks.get_flag(rows, col, CornerMark.L_RIGHT): if corner_marks.get_flag(rows, col, CornerMark.L_RIGHT):
draw_line(Vector2(h0+col*h_space, v0+rows*v_space), Vector2(h0+(col+1)*h_space, v0+rows*v_space), Color.blue) draw_line(grid_corner(rows, col), grid_corner(rows, col+1), Color.blue)
elif corner_marks.get_flag(rows, col, CornerMark.X_RIGHT): elif corner_marks.get_flag(rows, col, CornerMark.X_RIGHT):
draw_line(Vector2(h0+(col+0.4)*h_space, v0+rows*v_space), Vector2(h0+(col+0.6)*h_space, v0+rows*v_space), Color.red) draw_line(grid_corner(rows, col+0.4), grid_corner(rows, col+0.6), Color.red)
else: else:
draw_line(Vector2(h0+col*h_space, v0+rows*v_space), Vector2(h0+(col+1)*h_space, v0+rows*v_space), Color.white) draw_line(grid_corner(rows, col), grid_corner(rows, col+1), Color.white)
for row in rows: for row in rows:
if corner_marks.get_flag(row, cols, CornerMark.L_DOWN): if corner_marks.get_flag(row, cols, CornerMark.L_DOWN):
draw_line(Vector2(h0+cols*h_space, v0+row*v_space), Vector2(h0+cols*h_space, v0+(row+1)*v_space), Color.blue) draw_line(grid_corner(row, cols), grid_corner(row+1, cols), Color.blue)
elif corner_marks.get_flag(row, cols, CornerMark.X_DOWN): elif corner_marks.get_flag(row, cols, CornerMark.X_DOWN):
draw_line(Vector2(h0+cols*h_space, v0+(row+0.4)*v_space), Vector2(h0+cols*h_space, v0+(row+0.6)*v_space), Color.red) draw_line(grid_corner(row+0.4, cols), grid_corner(row+0.6, cols), Color.red)
else: else:
draw_line(Vector2(h0+cols*h_space, v0+row*v_space), Vector2(h0+cols*h_space, v0+(row+1)*v_space), Color.white) draw_line(grid_corner(row, cols), grid_corner(row+1, cols), Color.white)
# Numbers # Numbers
for row in rows: for row in rows: