2020-08-18 14:03:49 +00:00
|
|
|
extends Node2D
|
|
|
|
|
|
|
|
|
|
|
|
func _draw() -> void:
|
|
|
|
var size : Vector2 = Global.current_project.size
|
2020-11-13 18:12:20 +00:00
|
|
|
var positions : Array = get_tile_positions(size)
|
2020-12-30 17:56:28 +00:00
|
|
|
var tilemode_opacity := Global.tilemode_opacity
|
2020-10-25 23:10:14 +00:00
|
|
|
|
2020-11-23 16:53:21 +00:00
|
|
|
var _position := position
|
|
|
|
var _scale := scale
|
|
|
|
if Global.mirror_view:
|
|
|
|
_position.x = _position.x + Global.current_project.size.x
|
|
|
|
_scale.x = -1
|
|
|
|
draw_set_transform(_position, rotation, _scale)
|
|
|
|
|
2021-01-04 17:30:15 +00:00
|
|
|
var modulate_color := Color(tilemode_opacity, tilemode_opacity, tilemode_opacity, tilemode_opacity) # premultiply alpha blending is applied
|
|
|
|
var current_frame_texture: Texture = Global.canvas.currently_visible_frame.get_texture()
|
|
|
|
for pos in positions:
|
|
|
|
draw_texture(current_frame_texture, pos, modulate_color)
|
2020-11-13 18:12:20 +00:00
|
|
|
|
2020-11-23 16:53:21 +00:00
|
|
|
draw_set_transform(position, rotation, scale)
|
|
|
|
|
2020-11-13 18:12:20 +00:00
|
|
|
|
|
|
|
func get_tile_positions(size):
|
2020-11-24 16:53:18 +00:00
|
|
|
match Global.current_project.tile_mode:
|
2021-01-20 14:59:42 +00:00
|
|
|
Global.TileMode.BOTH:
|
2020-11-13 18:12:20 +00:00
|
|
|
return [
|
2021-01-06 15:11:50 +00:00
|
|
|
Vector2(0, size.y), # Down
|
|
|
|
Vector2(-size.x, size.y), # Down left
|
|
|
|
Vector2(-size.x, 0), # Left
|
|
|
|
-size, # Up left
|
|
|
|
Vector2(0, -size.y), # Up
|
|
|
|
Vector2(size.x, -size.y), # Up right
|
|
|
|
Vector2(size.x, 0), # Right
|
|
|
|
size # Down right
|
2020-11-13 18:12:20 +00:00
|
|
|
]
|
2021-01-20 14:59:42 +00:00
|
|
|
Global.TileMode.X_AXIS:
|
2020-11-13 18:12:20 +00:00
|
|
|
return [
|
2021-01-06 15:11:50 +00:00
|
|
|
Vector2(size.x, 0), # Right
|
|
|
|
Vector2(-size.x, 0), # Left
|
2020-11-13 18:12:20 +00:00
|
|
|
]
|
2021-01-20 14:59:42 +00:00
|
|
|
Global.TileMode.Y_AXIS:
|
2020-11-13 18:12:20 +00:00
|
|
|
return [
|
2021-01-06 15:11:50 +00:00
|
|
|
Vector2(0, size.y), # Down
|
|
|
|
Vector2(0, -size.y), # Up
|
2020-11-13 18:12:20 +00:00
|
|
|
]
|
|
|
|
_:
|
|
|
|
return []
|