mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 15:44:42 -04:00
Added a new brush type - Random Brushes
They're like File brushes, but each time you draw, expect to see something different! To make a random brush, just put the images you want in the same folder (under the main Brushes folder of course), and make sure their filename starts with "%". I also changed _process() to _input() in Canvas.gd, so there may be some unexpected behavior.
This commit is contained in:
parent
aa4a769088
commit
3a20b3e073
13 changed files with 66 additions and 23 deletions
|
@ -14,18 +14,28 @@ func import_brushes(path : String) -> void:
|
|||
|
||||
func find_brushes(brushes_dir : Directory, path : String) -> Array:
|
||||
var subdirectories := []
|
||||
var found_random_brush := 0
|
||||
brushes_dir.open(path)
|
||||
brushes_dir.list_dir_begin(true)
|
||||
var file := brushes_dir.get_next()
|
||||
while file != "":
|
||||
print(file)
|
||||
if file.get_extension().to_upper() == "PNG":
|
||||
var image := Image.new()
|
||||
var err := image.load(path.plus_file(file))
|
||||
if err == OK:
|
||||
image.convert(Image.FORMAT_RGBA8)
|
||||
Global.custom_brushes.append(image)
|
||||
Global.create_brush_button(image, Global.BRUSH_TYPES.FILE, file.trim_suffix(".png"))
|
||||
if "%" in file:
|
||||
if found_random_brush == 0:
|
||||
found_random_brush = Global.file_brush_container.get_child_count()
|
||||
image.convert(Image.FORMAT_RGBA8)
|
||||
Global.custom_brushes.append(image)
|
||||
Global.create_brush_button(image, Global.BRUSH_TYPES.RANDOM_FILE, file.trim_suffix(".png"))
|
||||
else:
|
||||
var brush_button = Global.file_brush_container.get_child(found_random_brush)
|
||||
brush_button.random_brushes.append(image)
|
||||
else:
|
||||
image.convert(Image.FORMAT_RGBA8)
|
||||
Global.custom_brushes.append(image)
|
||||
Global.create_brush_button(image, Global.BRUSH_TYPES.FILE, file.trim_suffix(".png"))
|
||||
elif file.get_extension() == "": # Probably a directory
|
||||
var subdir := "./%s" % [file]
|
||||
if brushes_dir.dir_exists(subdir): # If it's an actual directory
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue