-
-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a way to see index of color (plus bugfixes) (#1143)
* add a way to see indices * fix some things * Fixed more than one swatch selected if there is the same color available in an earlier swatch * fixed wrong index drawn when moved to an smpty swatch * make active_button public * fixed wrong color getting stored in array (similar fix to #1108.) * If the color selected in the palette is the same then it should take prioity. * formatting * hide 0 index
- Loading branch information
1 parent
7f4c7a6
commit 31981a1
Showing
12 changed files
with
132 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
extends Node2D | ||
|
||
const FONT_SIZE = 16 | ||
|
||
var users := 1 | ||
var enabled: bool = false: | ||
set(value): | ||
enabled = value | ||
queue_redraw() | ||
|
||
|
||
func _ready() -> void: | ||
Global.camera.zoom_changed.connect(queue_redraw) | ||
|
||
|
||
func _draw() -> void: | ||
if not enabled: | ||
return | ||
# when we zoom out there is a visual issue that inverts the text | ||
# (kind of how you look through a magnifying glass) | ||
# so we should restrict the rendering distance of this preview. | ||
var zoom_percentage := 100.0 * Global.camera.zoom.x | ||
if zoom_percentage < Global.pixel_grid_show_at_zoom: | ||
return | ||
var project = ExtensionsApi.project.current_project | ||
var cel: BaseCel = project.frames[project.current_frame].cels[project.current_layer] | ||
if not cel is PixelCel: | ||
return | ||
var index_image: Image = cel.image.indices_image | ||
if index_image.get_size() != project.size or not cel.image.is_indexed: | ||
return | ||
|
||
var used_rect: Rect2i = cel.image.get_used_rect() | ||
if used_rect.size != Vector2i.ZERO: | ||
# use smaller image for optimization | ||
index_image = index_image.get_region(used_rect) | ||
|
||
var font: Font = ExtensionsApi.theme.get_theme().default_font | ||
var offset = position + Vector2(used_rect.position) | ||
draw_set_transform(offset, rotation, Vector2(0.05, 0.05)) | ||
for x in range(index_image.get_size().x): | ||
for y in range(index_image.get_size().y): | ||
var index := index_image.get_pixel(x, y).r8 | ||
if index == 0: | ||
continue | ||
draw_string( | ||
font, | ||
Vector2(x, y) * 20 + Vector2.DOWN * 16, | ||
str(index), | ||
HORIZONTAL_ALIGNMENT_LEFT, | ||
-1, | ||
FONT_SIZE if (index < 100) else int(FONT_SIZE / 1.5) | ||
) | ||
draw_set_transform(position, rotation, scale) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters