From 54cfecacc47ea95687826e04e44570c84851cb61 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Wed, 30 Sep 2020 13:12:01 +0300 Subject: [PATCH] Guides now move with a step of 0.5 pixels --- CHANGELOG.md | 1 + src/UI/Canvas/Rulers/Guide.gd | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85c5b944f..887d837ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - A new purple theme. ### Changed +- Guides now move with a step of 0.5 pixels. That makes it possible to have guides (and symmetry guides) to be in the middle of pixels. - Changed how Dark, Gray, Caramel and Light themes look. All theme elements now have the same spacing and margins. ### Fixed diff --git a/src/UI/Canvas/Rulers/Guide.gd b/src/UI/Canvas/Rulers/Guide.gd index a205e0f78..a08c71517 100644 --- a/src/UI/Canvas/Rulers/Guide.gd +++ b/src/UI/Canvas/Rulers/Guide.gd @@ -35,11 +35,13 @@ func _input(_event : InputEvent): if has_focus and visible: if Input.is_action_pressed("left_mouse"): if type == Types.HORIZONTAL: - points[0].y = round(mouse_pos.y) - points[1].y = round(mouse_pos.y) + var yy = stepify(mouse_pos.y, 0.5) + points[0].y = yy + points[1].y = yy else: - points[0].x = round(mouse_pos.x) - points[1].x = round(mouse_pos.x) + var xx = stepify(mouse_pos.x, 0.5) + points[0].x = xx + points[1].x = xx if Input.is_action_just_released("left_mouse"): Global.has_focus = true has_focus = false @@ -53,10 +55,10 @@ func _draw() -> void: var zoom: Vector2 = Global.camera.zoom if type == Types.HORIZONTAL: draw_set_transform(Vector2(Global.camera.offset.x - (viewport_size.x / 2) * zoom.x, points[0].y + font.get_height() * zoom.x * 2), rotation, zoom * 2) - draw_string(font, Vector2.ZERO, "%spx" % str(round(mouse_pos.y))) + draw_string(font, Vector2.ZERO, "%spx" % str(stepify(mouse_pos.y, 0.5))) else: draw_set_transform(Vector2(points[0].x + font.get_height() * zoom.y, Global.camera.offset.y - (viewport_size.y / 2.25) * zoom.y), rotation, zoom * 2) - draw_string(font, Vector2.ZERO, "%spx" % str(round(mouse_pos.x))) + draw_string(font, Vector2.ZERO, "%spx" % str(stepify(mouse_pos.x, 0.5))) func outside_canvas() -> bool: