1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Fix all of linter errors

This commit is contained in:
Manolis Papadeas 2021-11-29 18:58:40 +02:00
parent e2a68c4ba4
commit 3835a3f0da
3 changed files with 19 additions and 18 deletions

View file

@ -89,24 +89,24 @@ func find_transparency_color_index(color_table: Dictionary) -> int:
return -1 return -1
func change_colors_to_codes(image: Image, color_palette: Dictionary, transparency_color_index: int) -> PoolByteArray: func colors_to_codes(img: Image, col_palette: Dictionary, transp_color_index: int) -> PoolByteArray:
image.lock() img.lock()
var image_data: PoolByteArray = image.get_data() var image_data: PoolByteArray = img.get_data()
var result: PoolByteArray = PoolByteArray([]) var result: PoolByteArray = PoolByteArray([])
for i in range(0, image_data.size(), 4): for i in range(0, image_data.size(), 4):
var color: Array = [image_data[i], image_data[i + 1], image_data[i + 2], image_data[i + 3]] var color: Array = [image_data[i], image_data[i + 1], image_data[i + 2], image_data[i + 3]]
if color in color_palette: if color in col_palette:
if color[3] == 0 and transparency_color_index != -1: if color[3] == 0 and transp_color_index != -1:
result.append(transparency_color_index) result.append(transp_color_index)
else: else:
result.append(color_palette[color]) result.append(col_palette[color])
else: else:
result.append(0) result.append(0)
push_warning("change_colors_to_codes: color not found! [%d, %d, %d, %d]" % color) push_warning("colors_to_codes: color not found! [%d, %d, %d, %d]" % color)
image.unlock() img.unlock()
return result return result
@ -152,7 +152,7 @@ func add_frame(image: Image, frame_delay: float, quantizator: Script) -> int:
if transparency_color_index == -1 and found_color_table.size() <= 255: if transparency_color_index == -1 and found_color_table.size() <= 255:
found_color_table[[0, 0, 0, 0]] = found_color_table.size() found_color_table[[0, 0, 0, 0]] = found_color_table.size()
transparency_color_index = found_color_table.size() - 1 transparency_color_index = found_color_table.size() - 1
image_converted_to_codes = change_colors_to_codes( image_converted_to_codes = colors_to_codes(
image, found_color_table, transparency_color_index image, found_color_table, transparency_color_index
) )
color_table = make_proper_size(found_color_table.keys()) color_table = make_proper_size(found_color_table.keys())

View file

@ -147,6 +147,7 @@ func compress_lzw(image: PoolByteArray, colors: PoolByteArray) -> Array:
return [binary_code_stream.pack(), min_code_size] return [binary_code_stream.pack(), min_code_size]
# gdlint: ignore=max-line-length
func decompress_lzw(code_stream_data: PoolByteArray, min_code_size: int, colors: PoolByteArray) -> PoolByteArray: func decompress_lzw(code_stream_data: PoolByteArray, min_code_size: int, colors: PoolByteArray) -> PoolByteArray:
var code_table: CodeTable = initialize_color_code_table(colors) var code_table: CodeTable = initialize_color_code_table(colors)
var index_stream: PoolByteArray = PoolByteArray([]) var index_stream: PoolByteArray = PoolByteArray([])

View file

@ -443,26 +443,26 @@ func import_palette(path: String) -> void:
file.open(path, File.READ) file.open(path, File.READ)
var text = file.get_as_text() var text = file.get_as_text()
file.close() file.close()
palette = import_gpl(path, text) palette = _import_gpl(path, text)
"pal": "pal":
var file = File.new() var file = File.new()
if file.file_exists(path): if file.file_exists(path):
file.open(path, File.READ) file.open(path, File.READ)
var text = file.get_as_text() var text = file.get_as_text()
file.close() file.close()
palette = import_pal_palette(path, text) palette = _import_pal_palette(path, text)
"png", "bmp", "hdr", "jpg", "jpeg", "svg", "tga", "webp": "png", "bmp", "hdr", "jpg", "jpeg", "svg", "tga", "webp":
var image := Image.new() var image := Image.new()
var err := image.load(path) var err := image.load(path)
if !err: if !err:
palette = import_image_palette(path, image) palette = _import_image_palette(path, image)
"json": "json":
var file = File.new() var file = File.new()
if file.file_exists(path): if file.file_exists(path):
file.open(path, File.READ) file.open(path, File.READ)
var text = file.get_as_text() var text = file.get_as_text()
file.close() file.close()
palette = import_json_palette(text) palette = _import_json_palette(text)
if palette: if palette:
var palette_path := _save_palette(palette) var palette_path := _save_palette(palette)
@ -472,7 +472,7 @@ func import_palette(path: String) -> void:
Global.palette_panel.select_palette(palette_path) Global.palette_panel.select_palette(palette_path)
func import_gpl(path: String, text: String) -> Palette: func _import_gpl(path: String, text: String) -> Palette:
# Refer to app/core/gimppalette-load.c of the GIMP for the "living spec" # Refer to app/core/gimppalette-load.c of the GIMP for the "living spec"
var result: Palette = null var result: Palette = null
var lines = text.split("\n") var lines = text.split("\n")
@ -522,7 +522,7 @@ func import_gpl(path: String, text: String) -> Palette:
return result return result
func import_pal_palette(path: String, text: String) -> Palette: func _import_pal_palette(path: String, text: String) -> Palette:
var result: Palette = null var result: Palette = null
var colors := PoolColorArray() var colors := PoolColorArray()
var lines = text.split("\n") var lines = text.split("\n")
@ -548,7 +548,7 @@ func import_pal_palette(path: String, text: String) -> Palette:
return result return result
func import_image_palette(path: String, image: Image) -> Palette: func _import_image_palette(path: String, image: Image) -> Palette:
var colors := [] var colors := []
var height: int = image.get_height() var height: int = image.get_height()
var width: int = image.get_width() var width: int = image.get_width()
@ -571,7 +571,7 @@ func import_image_palette(path: String, image: Image) -> Palette:
# Import of deprecated older json palette format # Import of deprecated older json palette format
func import_json_palette(text: String): func _import_json_palette(text: String) -> Palette:
var result: Palette = Palette.new() var result: Palette = Palette.new()
var result_json = JSON.parse(text) var result_json = JSON.parse(text)