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

Compare commits

...

3 commits

Author SHA1 Message Date
Emmanouil Papadeas ac950dafae [skip ci] Update CHANGELOG.md 2024-01-31 02:53:16 +02:00
Emmanouil Papadeas e648d0d612 Some code improvements in DrawingAlgos
Should also result in minor optimizations
2024-01-31 02:26:49 +02:00
Emmanouil Papadeas 399fc8dfbd Make similar_colors() in DrawingAlgos faster
We finally found some use for Godot 4's new Vector4, let Godot's built-in functions handle the math, since they run in native C++.
2024-01-31 01:41:58 +02:00
2 changed files with 39 additions and 67 deletions

View file

@ -11,9 +11,13 @@ Fayez Akhtar ([@Variable-ind](https://github.com/Variable-ind)), Clara Hobbs ([R
Built using Godot 4.2.1
### Added
- Support for multiple layer blend modes are finally here! [#911](https://github.com/Orama-Interactive/Pixelorama/pull/911)
- Multiple layer blend modes are finally here! [#911](https://github.com/Orama-Interactive/Pixelorama/pull/911)
- Non-destructive layer effects have been implemented. [#940](https://github.com/Orama-Interactive/Pixelorama/pull/940)
- An extension explorer has been integrated into Pixelorama, allowing for easy extension downloading from the internet. [#910](https://github.com/Orama-Interactive/Pixelorama/pull/910)
- Export to video formats. FFMPEG is required to be installed in the device in order for video exporting to work. [#980](https://github.com/Orama-Interactive/Pixelorama/pull/980)
- Export to webp and jpeg file formats. Webp is currently only for static images and does not support animations.
- Native file dialogs are now supported and can be enabled from the Preferences!
- Dialog popups can now be native OS windows instead of embedded within Pixelorama's main window. This can be changed from the Preferences.
- Added some missing shortcuts for buttons. [#900](https://github.com/Orama-Interactive/Pixelorama/pull/900)
- Palette colors can now be sorted.
- The brush increment/decrement shortcuts can now be changed. [#900](https://github.com/Orama-Interactive/Pixelorama/pull/900)
@ -44,6 +48,7 @@ Built using Godot 4.2.1
### Fixed
- Performance when drawing and doing operations such as bucket area fill should be better now. [#900](https://github.com/Orama-Interactive/Pixelorama/pull/900)
- Selections now scale properly when they are not transforming any image content. [#774](https://github.com/Orama-Interactive/Pixelorama/issues/774)
- Dividing by zero in value sliders and spinboxes no longer crashes the program.
## [v0.11.4] - Unreleased
@ -69,9 +74,11 @@ Built using Godot 3.5.2
- Tool shortcuts can now work with <kbd>Control</kbd>. [#935](https://github.com/Orama-Interactive/Pixelorama/issues/935)
- Optimize canvas drawing by only updating it when the image(s) have changed. [ac6a4db43d9296ebc03e639d8199dd3878a25d86](https://github.com/Orama-Interactive/Pixelorama/commit/ac6a4db43d9296ebc03e639d8199dd3878a25d86)
- Fix bug where using shortcuts to switch between frames also moved the selection, causing deletions.
- Pxo files can now be loaded from the Open menu option in the Web version. [3dcc51705a999145e53a8e6d4de217dc03b0f147](https://github.com/Orama-Interactive/Pixelorama/commit/3dcc51705a999145e53a8e6d4de217dc03b0f147)
- The ellipse tool no longer produces gaps with large sizes. [4f3a7a305a264e0d2fe86c201af76eca4b2fea0a](https://github.com/Orama-Interactive/Pixelorama/commit/4f3a7a305a264e0d2fe86c201af76eca4b2fea0a)
- Fix "visible layers" option on the export dialog producing wrong results. [346d1f071a8c6b1defb1072d39aea9c642f1ef59](https://github.com/Orama-Interactive/Pixelorama/commit/346d1f071a8c6b1defb1072d39aea9c642f1ef59)
- Random brushes now work again. [1317e40ffa5e9f01a9d214221bb5133db20a1de9](https://github.com/Orama-Interactive/Pixelorama/commit/1317e40ffa5e9f01a9d214221bb5133db20a1de9)
- The gizmo in the rotation image effect dialog is now accurately following the mouse.
## [v0.11.3] - 2023-10-30
This update has been brought to you by the contributions of:
@ -85,7 +92,6 @@ Built using Godot 3.5.2
### Fixed
- Fixed undo/redo history not working when the tool changes. [#916](https://github.com/Orama-Interactive/Pixelorama/pull/916)
- Pixelorama no longer closes when the project fails to be saved if "Save & Exit" is selected. [#920](https://github.com/Orama-Interactive/Pixelorama/pull/920)
- Projects with 3D cels saved in 1.x can now be opened in 0.11.3. [#928](https://github.com/Orama-Interactive/Pixelorama/pull/928)
## [v0.11.2] - 2023-08-31
This update has been brought to you by the contributions of:

View file

@ -156,36 +156,22 @@ func scale_3x(sprite: Image, tol := 50.0) -> Image:
var scaled := Image.create(
sprite.get_width() * 3, sprite.get_height() * 3, false, Image.FORMAT_RGBA8
)
var a: Color
var b: Color
var c: Color
var d: Color
var e: Color
var f: Color
var g: Color
var h: Color
var i: Color
var width_minus_one := sprite.get_width() - 1
var height_minus_one := sprite.get_height() - 1
for x in range(0, sprite.get_width()):
for y in range(0, sprite.get_height()):
var xs := 3 * x
var ys := 3 * y
a = sprite.get_pixel(maxi(x - 1, 0), maxi(y - 1, 0))
b = sprite.get_pixel(mini(x, sprite.get_width() - 1), maxi(y - 1, 0))
c = sprite.get_pixel(mini(x + 1, sprite.get_width() - 1), maxi(y - 1, 0))
d = sprite.get_pixel(maxi(x - 1, 0), mini(y, sprite.get_height() - 1))
e = sprite.get_pixel(mini(x, sprite.get_width() - 1), mini(y, sprite.get_height() - 1))
f = sprite.get_pixel(
mini(x + 1, sprite.get_width() - 1), mini(y, sprite.get_height() - 1)
)
g = sprite.get_pixel(maxi(x - 1, 0), mini(y + 1, sprite.get_height() - 1))
h = sprite.get_pixel(
mini(x, sprite.get_width() - 1), mini(y + 1, sprite.get_height() - 1)
)
i = sprite.get_pixel(
mini(x + 1, sprite.get_width() - 1), mini(y + 1, sprite.get_height() - 1)
)
var a := sprite.get_pixel(maxi(x - 1, 0), maxi(y - 1, 0))
var b := sprite.get_pixel(mini(x, width_minus_one), maxi(y - 1, 0))
var c := sprite.get_pixel(mini(x + 1, width_minus_one), maxi(y - 1, 0))
var d := sprite.get_pixel(maxi(x - 1, 0), mini(y, height_minus_one))
var e := sprite.get_pixel(mini(x, width_minus_one), mini(y, height_minus_one))
var f := sprite.get_pixel(mini(x + 1, width_minus_one), mini(y, height_minus_one))
var g := sprite.get_pixel(maxi(x - 1, 0), mini(y + 1, height_minus_one))
var h := sprite.get_pixel(mini(x, width_minus_one), mini(y + 1, height_minus_one))
var i := sprite.get_pixel(mini(x + 1, width_minus_one), mini(y + 1, height_minus_one))
var db: bool = similar_colors(d, b, tol)
var dh: bool = similar_colors(d, h, tol)
@ -223,7 +209,7 @@ func scale_3x(sprite: Image, tol := 50.0) -> Image:
func rotxel(sprite: Image, angle: float, pivot: Vector2) -> void:
# If angle is simple, then nn rotation is the best
if angle == 0 || angle == PI / 2 || angle == PI || angle == 2 * PI:
if angle == 0 || angle == PI / 2 || angle == PI || angle == 3.0 * PI / 2.0 || angle == TAU:
nn_rotate(sprite, angle, pivot)
return
@ -231,7 +217,6 @@ func rotxel(sprite: Image, angle: float, pivot: Vector2) -> void:
aux.copy_from(sprite)
var ox: int
var oy: int
var p: Color
for x in sprite.get_size().x:
for y in sprite.get_size().y:
var dx := 3 * (x - pivot.x)
@ -269,27 +254,19 @@ func rotxel(sprite: Image, angle: float, pivot: Vector2) -> void:
ox = roundi((ox - 1) / 3.0)
oy = roundi((oy - 1) / 3.0)
var a: Color
var b: Color
var c: Color
var d: Color
var e: Color
var f: Color
var g: Color
var h: Color
var i: Color
var p: Color
if ox == 0 || ox == sprite.get_width() - 1 || oy == 0 || oy == sprite.get_height() - 1:
p = aux.get_pixel(ox, oy)
else:
a = aux.get_pixel(ox - 1, oy - 1)
b = aux.get_pixel(ox, oy - 1)
c = aux.get_pixel(ox + 1, oy - 1)
d = aux.get_pixel(ox - 1, oy)
e = aux.get_pixel(ox, oy)
f = aux.get_pixel(ox + 1, oy)
g = aux.get_pixel(ox - 1, oy + 1)
h = aux.get_pixel(ox, oy + 1)
i = aux.get_pixel(ox + 1, oy + 1)
var a := aux.get_pixel(ox - 1, oy - 1)
var b := aux.get_pixel(ox, oy - 1)
var c := aux.get_pixel(ox + 1, oy - 1)
var d := aux.get_pixel(ox - 1, oy)
var e := aux.get_pixel(ox, oy)
var f := aux.get_pixel(ox + 1, oy)
var g := aux.get_pixel(ox - 1, oy + 1)
var h := aux.get_pixel(ox, oy + 1)
var i := aux.get_pixel(ox + 1, oy + 1)
match index:
0:
@ -414,9 +391,7 @@ func rotxel(sprite: Image, angle: float, pivot: Vector2) -> void:
func fake_rotsprite(sprite: Image, angle: float, pivot: Vector2) -> void:
var selected_sprite := Image.new()
selected_sprite.copy_from(sprite)
selected_sprite.copy_from(scale_3x(selected_sprite))
var selected_sprite := scale_3x(sprite)
nn_rotate(selected_sprite, angle, pivot * 3)
selected_sprite.resize(
selected_sprite.get_width() / 3, selected_sprite.get_height() / 3, Image.INTERPOLATE_NEAREST
@ -429,12 +404,12 @@ func nn_rotate(sprite: Image, angle: float, pivot: Vector2) -> void:
return
var aux := Image.new()
aux.copy_from(sprite)
var ox: int
var oy: int
var angle_sin := sin(angle)
var angle_cos := cos(angle)
for x in range(sprite.get_width()):
for y in range(sprite.get_height()):
ox = (x - pivot.x) * cos(angle) + (y - pivot.y) * sin(angle) + pivot.x
oy = -(x - pivot.x) * sin(angle) + (y - pivot.y) * cos(angle) + pivot.y
var ox := (x - pivot.x) * angle_cos + (y - pivot.y) * angle_sin + pivot.x
var oy := -(x - pivot.x) * angle_sin + (y - pivot.y) * angle_cos + pivot.y
if ox >= 0 && ox < sprite.get_width() && oy >= 0 && oy < sprite.get_height():
sprite.set_pixel(x, y, aux.get_pixel(ox, oy))
else:
@ -442,19 +417,10 @@ func nn_rotate(sprite: Image, angle: float, pivot: Vector2) -> void:
func similar_colors(c1: Color, c2: Color, tol := 100.0) -> bool:
var dist := color_distance(c1, c2)
return dist <= tol
func color_distance(c1: Color, c2: Color) -> float:
return sqrt(
(
pow((c1.r - c2.r) * 255, 2)
+ pow((c1.g - c2.g) * 255, 2)
+ pow((c1.b - c2.b) * 255, 2)
+ pow((c1.a - c2.a) * 255, 2)
)
)
var v1 := Vector4(c1.r, c1.g, c1.b, c1.a)
var v2 := Vector4(c2.r, c2.g, c2.b, c2.a)
var dist := v2.distance_to(v1)
return dist <= (tol / 255.0)
# Image effects