1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-07 19:09:50 +00:00
Pixelorama/src/UI/Canvas/PixelGrid.gd
Manolis Papadeas c6b9a1fb82
Format code and add static checks (#599)
* gdformat .

* Lint code - Part 1

* Format code - Part 2

* Lint code - Part 2

Trying to fix the max allowed line length errors

* Add normal_map_invert_y to the image .import files

Because of Godot 3.4

* Do not call private methods outside of the script's scope

Lint code - Part 3

* Format code - Part 3

* Fixed more line length exceeded errors - Lint code Part 3

* Export array of licenses - Lint code part 4

* Clean hint_tooltip code from Global

Removes a lot of lines of code

* Create static-checks.yml

* Fix FreeType's license
2021-11-25 14:48:30 +02:00

32 lines
1.1 KiB
GDScript

extends Node2D
func _draw() -> void:
if not Global.draw_pixel_grid:
return
var zoom_percentage := 100.0 / Global.camera.zoom.x
if zoom_percentage < Global.pixel_grid_show_at_zoom:
return
var target_rect: Rect2 = Global.current_project.get_tile_mode_rect()
if target_rect.has_no_area():
return
# Using Array instead of PoolVector2Array to avoid kinda
# random "resize: Can't resize PoolVector if locked" errors.
# See: https://github.com/Orama-Interactive/Pixelorama/issues/331
# It will be converted to PoolVector2Array before being sent to be rendered.
var grid_multiline_points := []
for x in range(ceil(target_rect.position.x), floor(target_rect.end.x) + 1):
grid_multiline_points.push_back(Vector2(x, target_rect.position.y))
grid_multiline_points.push_back(Vector2(x, target_rect.end.y))
for y in range(ceil(target_rect.position.y), floor(target_rect.end.y) + 1):
grid_multiline_points.push_back(Vector2(target_rect.position.x, y))
grid_multiline_points.push_back(Vector2(target_rect.end.x, y))
if not grid_multiline_points.empty():
draw_multiline(grid_multiline_points, Global.pixel_grid_color)