mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-07 19:09:50 +00:00
* Add preferences for tile mode basis vectors Each tile is offset according to the x and y basis. For example, a tile (1,1) would be at basis_x + basis_y * Update tools for custom tile modes Show the indicator in the correct position, and only draw on the nearest tile. * Fix style issues * Move tile functionality to own class to prevent bloating Project * Fix error in Tiles bounding box logic * Make tile mode offsets project settings Since the desired tile mode offsets depends on the tile being drawn, the tile mode offsets should be a project specific setting which is persisted in the project file. * Update TileMode object immediately after closing dialog * Don't draw center tile by default in TileMode * Move tile mode offsets to view menu * Move tile mode offsets dialog out of ImageEffects
32 lines
1.1 KiB
GDScript
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.tiles.get_bounding_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)
|