]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Displacement Map Visualizer QoL (#27392)
authorEd <96445749+TheShuEd@users.noreply.github.com>
Sat, 27 Apr 2024 14:55:28 +0000 (17:55 +0300)
committerGitHub <noreply@github.com>
Sat, 27 Apr 2024 14:55:28 +0000 (16:55 +0200)
* Update Displacement Map Visualizer.lua

* Add files via upload

* Fix background layer being offset

This was caused by not taking the cel's own bounds into account.
Aseprite doesn't make an image layer "full size" if it only covers a
small part of the sprite.

---------

Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
Tools/SS14 Aseprite Plugins/Displacement Map Visualizer.lua
Tools/SS14 Aseprite Plugins/Displacement Map.png [new file with mode: 0644]

index b16ab797e7f32b7c54561b0238b6607900f3bba9..468636c07d813b016e2ddd7bc00ff4c152b3bd79 100644 (file)
@@ -88,17 +88,45 @@ dialog:canvas{
 
         local layerDisplacement = findLayer(sprite, dialog.data["displacement-select"])
         local layerTarget = findLayer(sprite, dialog.data["reference-select"])
+        local layerBackground = findLayer(sprite, dialog.data["background-select"])
         -- print(layerDisplacement.name)
         -- print(layerTarget.name)
+
         local celDisplacement = layerDisplacement:cel(1)
         local celTarget = layerTarget:cel(1)
+        local celBackground = layerBackground:cel(1)
+
+        -- Draw background
+        context:drawImage(
+            -- srcImage
+            celBackground.image,
+            -- srcPos
+            0, 0,
+            -- srcSize
+            celBackground.image.width, celBackground.image.height,
+            -- dstPos
+            celBackground.position.x * scale, celBackground.position.y * scale,
+            -- dstSize
+            celBackground.image.width * scale, celBackground.image.height * scale)
+
+        -- Apply displacement map and draw
         local image = applyDisplacementMap(
             sprite.width, sprite.height,
             dialog.data["size"],
             celDisplacement.image, celDisplacement.bounds,
             celTarget.image, celTarget.bounds)
 
-        context:drawImage(image, 0, 0, image.width, image.height, 0, 0, image.width * scale, context.width, context.height)
+        context:drawImage(
+            -- srcImage
+            image,
+            -- srcPos
+            0, 0,
+            -- srcSize
+            image.width, image.height,
+            -- dstPos
+            0, 0,
+            -- dstSize
+            image.width * scale, image.height * scale)
     end
 }
 
@@ -120,6 +148,14 @@ dialog:combobox{
     end
 }
 
+dialog:combobox{
+    id = "background-select",
+    label = "background layer",
+    options = layers,
+    onchange = function(ev)
+        dialog:repaint()
+    end
+}
 
 dialog:slider{
     id = "size",
diff --git a/Tools/SS14 Aseprite Plugins/Displacement Map.png b/Tools/SS14 Aseprite Plugins/Displacement Map.png
new file mode 100644 (file)
index 0000000..50744ce
Binary files /dev/null and b/Tools/SS14 Aseprite Plugins/Displacement Map.png differ