Draw Grid only over Canvas. Added PixelGrid. (#427)

* Draw grid only over the Canvas (when in tiling mode)

* Replace some magic numbers with enums.

It's too easy to break something when adding something new in here. Should be a little harder now.

* Added Pixel Grid.

- Pixel grid is shown only when it's enabled and camera is zoomed close enough.
- Settings: pixel_grid_show_at_zoom (as a percentage because that's what's shown in the settings panel), pixel_grid_color. Default values might need changing.
- To distinguish between grid and pixel grid default settings for grid width, grid height are changed.
- Now both grid and pixel grid are drawn above (after) tile mode. Grid is drawn above (after) pixel grid.
This commit is contained in:
kleonc 2021-01-16 19:24:46 +01:00 committed by GitHub
parent 4da4f4ebb8
commit db9980a883
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 239 additions and 98 deletions

View file

@ -23,21 +23,17 @@ func _on_TransparentChecker_resized() -> void:
material.set_shader_param("rect_size", rect_size)
func _init_position(id : int) -> void:
match id:
0:
Global.current_project.tile_mode = Global.Tile_Mode.NONE
func _init_position(tile_mode : int) -> void:
match tile_mode:
Global.Tile_Mode.NONE:
Global.transparent_checker.set_size(Global.current_project.size)
Global.transparent_checker.set_position(Vector2.ZERO)
1:
Global.current_project.tile_mode = Global.Tile_Mode.BOTH
Global.Tile_Mode.BOTH:
Global.transparent_checker.set_size(Global.current_project.size*3)
Global.transparent_checker.set_position(-Global.current_project.size)
2:
Global.current_project.tile_mode = Global.Tile_Mode.XAXIS
Global.Tile_Mode.XAXIS:
Global.transparent_checker.set_size(Vector2(Global.current_project.size.x*3, Global.current_project.size.y*1))
Global.transparent_checker.set_position(Vector2(-Global.current_project.size.x, 0))
3:
Global.current_project.tile_mode = Global.Tile_Mode.YAXIS
Global.Tile_Mode.YAXIS:
Global.transparent_checker.set_size(Vector2(Global.current_project.size.x*1, Global.current_project.size.y*3))
Global.transparent_checker.set_position(Vector2(0, -Global.current_project.size.y))