changed brush prefabs, now separate panel, added brush size
@ -19,3 +19,88 @@ const list = [
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
enum Type {
|
||||
V_LINE,
|
||||
H_LINE,
|
||||
RECT,
|
||||
CIRCLE,
|
||||
}
|
||||
|
||||
static func get_brush(type, size: int):
|
||||
var pixels = []
|
||||
if size < 1:
|
||||
size = 1
|
||||
|
||||
match type:
|
||||
Type.CIRCLE:
|
||||
size += 1
|
||||
var center = Vector2.ZERO
|
||||
var last = center
|
||||
var radius = size / 2.0
|
||||
for x in range(size):
|
||||
for y in range(size):
|
||||
if Vector2(x - radius, y - radius).length() < size / 3.0:
|
||||
pixels.append(Vector2(x, y))
|
||||
|
||||
var avg = Vector2(size / 2, size / 2)
|
||||
avg = Vector2(floor(avg.x), floor(avg.y))
|
||||
|
||||
for i in range(pixels.size()):
|
||||
pixels[i] -= avg
|
||||
|
||||
Type.RECT:
|
||||
var center = Vector2.ZERO
|
||||
var last = center
|
||||
for x in range(size):
|
||||
for y in range(size):
|
||||
pixels.append(Vector2(x, y))
|
||||
|
||||
var avg = Vector2.ZERO
|
||||
for cell in pixels:
|
||||
avg += cell
|
||||
|
||||
avg.x /= pixels.size()
|
||||
avg.y /= pixels.size()
|
||||
|
||||
avg = Vector2(floor(avg.x), floor(avg.y))
|
||||
|
||||
for i in range(pixels.size()):
|
||||
pixels[i] -= avg
|
||||
|
||||
Type.V_LINE:
|
||||
var center = Vector2.ZERO
|
||||
var last = center
|
||||
pixels.append(Vector2.ZERO)
|
||||
|
||||
for i in range(size - 1):
|
||||
var sig = sign(last.y)
|
||||
if sig == 0:
|
||||
sig = 1
|
||||
|
||||
if last.y < 0:
|
||||
center.y = abs(last.y) * -sig
|
||||
else:
|
||||
center.y = abs(last.y+1) * -sig
|
||||
last = center
|
||||
pixels.append(center)
|
||||
Type.H_LINE:
|
||||
var center = Vector2.ZERO
|
||||
var last = center
|
||||
pixels.append(Vector2.ZERO)
|
||||
|
||||
for i in range(size - 1):
|
||||
var sig = sign(last.x)
|
||||
if sig == 0:
|
||||
sig = 1
|
||||
|
||||
if last.x < 0:
|
||||
center.x = abs(last.x) * -sig
|
||||
else:
|
||||
center.x = abs(last.x+1) * -sig
|
||||
last = center
|
||||
pixels.append(center)
|
||||
|
||||
return pixels
|
||||
|
||||
|
||||
|
@ -112,6 +112,8 @@ func _ready():
|
||||
_connect_layer_buttons()
|
||||
highlight_layer(paint_canvas.get_active_layer().name)
|
||||
|
||||
find_node("BrushSizeLabel").text = str(int(find_node("BrushSize").value))
|
||||
|
||||
paint_canvas.update()
|
||||
|
||||
|
||||
@ -233,6 +235,12 @@ func _draw_tool_brush():
|
||||
pixel -= _cut_pos + _cut_size / 2
|
||||
pixel += cell_mouse_position
|
||||
paint_canvas._set_pixel_v(paint_canvas.tool_layer, pixel, color)
|
||||
Tools.BRUSH:
|
||||
var pixels = BrushPrefabs.get_brush(selected_brush_prefab, find_node("BrushSize").value)
|
||||
for pixel in pixels:
|
||||
|
||||
paint_canvas._set_pixel(paint_canvas.tool_layer,
|
||||
cell_mouse_position.x + pixel.x, cell_mouse_position.y + pixel.y, selected_color)
|
||||
|
||||
Tools.RAINBOW:
|
||||
paint_canvas._set_pixel(paint_canvas.tool_layer,
|
||||
@ -326,11 +334,13 @@ func brush_process():
|
||||
_current_action = get_action()
|
||||
if brush_mode == Tools.COLORPICKER:
|
||||
_current_action = null
|
||||
|
||||
match brush_mode:
|
||||
Tools.PAINT:
|
||||
do_action([cell_mouse_position, last_cell_mouse_position, selected_color])
|
||||
Tools.BRUSH:
|
||||
do_action([cell_mouse_position, last_cell_mouse_position, selected_color, selected_brush_prefab])
|
||||
do_action([cell_mouse_position, last_cell_mouse_position, selected_color,
|
||||
selected_brush_prefab, find_node("BrushSize").value])
|
||||
Tools.LINE:
|
||||
do_action([cell_mouse_position, last_cell_mouse_position, selected_color])
|
||||
Tools.RECT:
|
||||
@ -360,7 +370,8 @@ func brush_process():
|
||||
Tools.PAINT:
|
||||
do_action([cell_mouse_position, last_cell_mouse_position, Color.transparent])
|
||||
Tools.BRUSH:
|
||||
do_action([cell_mouse_position, last_cell_mouse_position, Color.transparent, selected_brush_prefab])
|
||||
do_action([cell_mouse_position, last_cell_mouse_position, Color.transparent,
|
||||
selected_brush_prefab, find_node("BrushSize").value])
|
||||
else:
|
||||
if _current_action and _current_action.can_commit():
|
||||
commit_action()
|
||||
@ -533,15 +544,7 @@ func _on_RainbowTool_pressed():
|
||||
|
||||
|
||||
func _on_BrushTool_pressed():
|
||||
var prev_mode = brush_mode
|
||||
set_brush(Tools.BRUSH)
|
||||
if prev_mode != brush_mode:
|
||||
return
|
||||
selected_brush_prefab += 1
|
||||
selected_brush_prefab = selected_brush_prefab % BrushPrefabs.list.size()
|
||||
var value = float(selected_brush_prefab) / BrushPrefabs.list.size()
|
||||
|
||||
find_node("BrushTool").get("custom_styles/normal").set("bg_color", Color(value, value, value, 1.0))
|
||||
|
||||
|
||||
func _on_LineTool_pressed():
|
||||
@ -736,3 +739,39 @@ func is_any_menu_open() -> bool:
|
||||
$SaveFileDialog.visible or \
|
||||
find_node("Navbar").is_any_menu_open()
|
||||
|
||||
|
||||
|
||||
func _on_LockAlpha_pressed():
|
||||
var checked = find_node("LockAlpha").pressed
|
||||
paint_canvas.active_layer.toggle_alpha_locked()
|
||||
for i in range(find_node("Layer").get_popup().get_item_count()):
|
||||
if find_node("Layer").get_popup().get_item_text(i) == "Toggle Alpha Locked":
|
||||
find_node("Layer").get_popup().set_item_checked(i, not find_node("Layer").get_popup().is_item_checked(i))
|
||||
|
||||
|
||||
func _on_BrushRect_pressed():
|
||||
if brush_mode != Tools.BRUSH:
|
||||
set_brush(Tools.BRUSH)
|
||||
selected_brush_prefab = BrushPrefabs.Type.RECT
|
||||
|
||||
|
||||
func _on_BrushCircle_pressed():
|
||||
if brush_mode != Tools.BRUSH:
|
||||
set_brush(Tools.BRUSH)
|
||||
selected_brush_prefab = BrushPrefabs.Type.CIRCLE
|
||||
|
||||
|
||||
func _on_BrushVLine_pressed():
|
||||
if brush_mode != Tools.BRUSH:
|
||||
set_brush(Tools.BRUSH)
|
||||
selected_brush_prefab = BrushPrefabs.Type.V_LINE
|
||||
|
||||
|
||||
func _on_BrushHLine_pressed():
|
||||
if brush_mode != Tools.BRUSH:
|
||||
set_brush(Tools.BRUSH)
|
||||
selected_brush_prefab = BrushPrefabs.Type.H_LINE
|
||||
|
||||
|
||||
func _on_BrushSize_value_changed(value: float):
|
||||
find_node("BrushSizeLabel").text = str(int(value))
|
||||
|
@ -70,6 +70,7 @@ func handle_layer_menu(pressed_item: String, id):
|
||||
"Toggle Alpha Locked":
|
||||
owner.paint_canvas.active_layer.toggle_alpha_locked()
|
||||
$Buttons/Layer.get_popup().set_item_checked(id, not $Buttons/Layer.get_popup().is_item_checked(id))
|
||||
owner.find_node("LockAlpha").pressed = $Buttons/Layer.get_popup().is_item_checked(id)
|
||||
|
||||
|
||||
func handle_grid_menu(pressed_item: String, id):
|
||||
|
@ -6,7 +6,7 @@ func do_action(canvas: GECanvas, data: Array):
|
||||
.do_action(canvas, data)
|
||||
|
||||
for pixel in GEUtils.get_pixels_in_line(data[0], data[1]):
|
||||
for off in BrushPrefabs.list[data[3]]:
|
||||
for off in BrushPrefabs.get_brush(data[3], data[4]):
|
||||
var p = pixel + off
|
||||
|
||||
if p in action_data.undo.cells or canvas.get_pixel_v(p) == null:
|
||||
|
44
addons/Godoxel/actions/MultiLine.gd
Normal file
@ -0,0 +1,44 @@
|
||||
extends GEAction
|
||||
class_name GEMultiLine
|
||||
|
||||
|
||||
func can_commit() -> bool:
|
||||
return false
|
||||
|
||||
|
||||
func update_action(canvas, data: Array):
|
||||
.update_action(canvas, data)
|
||||
|
||||
var pixels = GEUtils.get_pixels_in_line(data[0], data[1])
|
||||
for pixel in pixels:
|
||||
if pixel in action_data.undo.cells or canvas.get_pixel_v(pixel) == null or canvas.is_alpha_locked():
|
||||
continue
|
||||
action_data.undo.colors.append(canvas.get_pixel_v(pixel))
|
||||
action_data.undo.cells.append(pixel)
|
||||
canvas.set_pixel_v(pixel, data[2])
|
||||
|
||||
action_data.redo.cells.append(pixel)
|
||||
action_data.redo.colors.append(data[2])
|
||||
|
||||
|
||||
func commit_action(canvas):
|
||||
var cells = action_data.redo.cells
|
||||
var colors = action_data.redo.colors
|
||||
return []
|
||||
|
||||
|
||||
func undo_action(canvas):
|
||||
var cells = action_data.undo.cells
|
||||
var colors = action_data.undo.colors
|
||||
for idx in range(cells.size()):
|
||||
canvas._set_pixel_v(action_data.layer, cells[idx], colors[idx])
|
||||
|
||||
|
||||
func redo_action(canvas):
|
||||
var cells = action_data.redo.cells
|
||||
var colors = action_data.redo.colors
|
||||
for idx in range(cells.size()):
|
||||
canvas._set_pixel_v(action_data.layer, cells[idx], colors[idx])
|
||||
|
||||
|
||||
|
BIN
addons/Godoxel/assets/BrushCircle.png
Normal file
After Width: | Height: | Size: 195 B |
34
addons/Godoxel/assets/BrushCircle.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/BrushCircle.png-dd250909fee7964ffc38f7e4fcfe9c07.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/Godoxel/assets/BrushCircle.png"
|
||||
dest_files=[ "res://.import/BrushCircle.png-dd250909fee7964ffc38f7e4fcfe9c07.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
addons/Godoxel/assets/BrushCircle_Hovered.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
34
addons/Godoxel/assets/BrushCircle_Hovered.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/BrushCircle_Hovered.png-ae1a4d835af51e8a293b71d6a241b71c.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/Godoxel/assets/BrushCircle_Hovered.png"
|
||||
dest_files=[ "res://.import/BrushCircle_Hovered.png-ae1a4d835af51e8a293b71d6a241b71c.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
addons/Godoxel/assets/BrushHLine.png
Normal file
After Width: | Height: | Size: 127 B |
34
addons/Godoxel/assets/BrushHLine.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/BrushHLine.png-9182ec8ac804af16d356bf911782e299.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/Godoxel/assets/BrushHLine.png"
|
||||
dest_files=[ "res://.import/BrushHLine.png-9182ec8ac804af16d356bf911782e299.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
addons/Godoxel/assets/BrushHLine_Hovered.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
34
addons/Godoxel/assets/BrushHLine_Hovered.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/BrushHLine_Hovered.png-e51d5f3c1628c510a225057f3ed60d5a.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/Godoxel/assets/BrushHLine_Hovered.png"
|
||||
dest_files=[ "res://.import/BrushHLine_Hovered.png-e51d5f3c1628c510a225057f3ed60d5a.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
addons/Godoxel/assets/BrushRect.png
Normal file
After Width: | Height: | Size: 128 B |
34
addons/Godoxel/assets/BrushRect.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/BrushRect.png-2b2d0ae4889c1fbc5c7bee7ae5515663.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/Godoxel/assets/BrushRect.png"
|
||||
dest_files=[ "res://.import/BrushRect.png-2b2d0ae4889c1fbc5c7bee7ae5515663.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
addons/Godoxel/assets/BrushRect_Hovered.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
34
addons/Godoxel/assets/BrushRect_Hovered.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/BrushRect_Hovered.png-b09066b673d6082ce887a03a19f17977.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/Godoxel/assets/BrushRect_Hovered.png"
|
||||
dest_files=[ "res://.import/BrushRect_Hovered.png-b09066b673d6082ce887a03a19f17977.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
addons/Godoxel/assets/BrushVLine.png
Normal file
After Width: | Height: | Size: 129 B |
34
addons/Godoxel/assets/BrushVLine.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/BrushVLine.png-022220d888fe2fe2f8a081bcca62b4b2.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/Godoxel/assets/BrushVLine.png"
|
||||
dest_files=[ "res://.import/BrushVLine.png-022220d888fe2fe2f8a081bcca62b4b2.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
addons/Godoxel/assets/BrushVLine_Hovered.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
34
addons/Godoxel/assets/BrushVLine_Hovered.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/BrushVLine_Hovered.png-104e29757699756f1b44bd32a622df2c.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/Godoxel/assets/BrushVLine_Hovered.png"
|
||||
dest_files=[ "res://.import/BrushVLine_Hovered.png-104e29757699756f1b44bd32a622df2c.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|