From 3835a3f0da9a94986621a5306328231a13c3ca0b Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Mon, 29 Nov 2021 18:58:40 +0200 Subject: [PATCH] Fix all of linter errors --- addons/gdgifexporter/exporter.gd | 20 ++++++++++---------- addons/gdgifexporter/gif-lzw/lzw.gd | 1 + src/Autoload/Palettes.gd | 16 ++++++++-------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/addons/gdgifexporter/exporter.gd b/addons/gdgifexporter/exporter.gd index c561a4b7d..d0ba28302 100644 --- a/addons/gdgifexporter/exporter.gd +++ b/addons/gdgifexporter/exporter.gd @@ -89,24 +89,24 @@ func find_transparency_color_index(color_table: Dictionary) -> int: return -1 -func change_colors_to_codes(image: Image, color_palette: Dictionary, transparency_color_index: int) -> PoolByteArray: - image.lock() - var image_data: PoolByteArray = image.get_data() +func colors_to_codes(img: Image, col_palette: Dictionary, transp_color_index: int) -> PoolByteArray: + img.lock() + var image_data: PoolByteArray = img.get_data() var result: PoolByteArray = PoolByteArray([]) 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]] - if color in color_palette: - if color[3] == 0 and transparency_color_index != -1: - result.append(transparency_color_index) + if color in col_palette: + if color[3] == 0 and transp_color_index != -1: + result.append(transp_color_index) else: - result.append(color_palette[color]) + result.append(col_palette[color]) else: 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 @@ -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: found_color_table[[0, 0, 0, 0]] = found_color_table.size() 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 ) color_table = make_proper_size(found_color_table.keys()) diff --git a/addons/gdgifexporter/gif-lzw/lzw.gd b/addons/gdgifexporter/gif-lzw/lzw.gd index 719f483ac..9140e7cb7 100644 --- a/addons/gdgifexporter/gif-lzw/lzw.gd +++ b/addons/gdgifexporter/gif-lzw/lzw.gd @@ -147,6 +147,7 @@ func compress_lzw(image: PoolByteArray, colors: PoolByteArray) -> Array: 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: var code_table: CodeTable = initialize_color_code_table(colors) var index_stream: PoolByteArray = PoolByteArray([]) diff --git a/src/Autoload/Palettes.gd b/src/Autoload/Palettes.gd index 6fff00eb9..053e4d682 100644 --- a/src/Autoload/Palettes.gd +++ b/src/Autoload/Palettes.gd @@ -443,26 +443,26 @@ func import_palette(path: String) -> void: file.open(path, File.READ) var text = file.get_as_text() file.close() - palette = import_gpl(path, text) + palette = _import_gpl(path, text) "pal": var file = File.new() if file.file_exists(path): file.open(path, File.READ) var text = file.get_as_text() file.close() - palette = import_pal_palette(path, text) + palette = _import_pal_palette(path, text) "png", "bmp", "hdr", "jpg", "jpeg", "svg", "tga", "webp": var image := Image.new() var err := image.load(path) if !err: - palette = import_image_palette(path, image) + palette = _import_image_palette(path, image) "json": var file = File.new() if file.file_exists(path): file.open(path, File.READ) var text = file.get_as_text() file.close() - palette = import_json_palette(text) + palette = _import_json_palette(text) if palette: var palette_path := _save_palette(palette) @@ -472,7 +472,7 @@ func import_palette(path: String) -> void: 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" var result: Palette = null var lines = text.split("\n") @@ -522,7 +522,7 @@ func import_gpl(path: String, text: String) -> Palette: 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 colors := PoolColorArray() var lines = text.split("\n") @@ -548,7 +548,7 @@ func import_pal_palette(path: String, text: String) -> Palette: return result -func import_image_palette(path: String, image: Image) -> Palette: +func _import_image_palette(path: String, image: Image) -> Palette: var colors := [] var height: int = image.get_height() 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 -func import_json_palette(text: String): +func _import_json_palette(text: String) -> Palette: var result: Palette = Palette.new() var result_json = JSON.parse(text)