11json = require (" json" );
22require (" util" );
33
4- version = " 0.2 " ;
4+ version = " 0.3 " ;
55love .window .setTitle (love .window .getTitle () .. " v" .. version );
66
77function love .load ()
@@ -20,7 +20,12 @@ function love.load()
2020 {text = " Alternate Mode" , type = " boolean" , var = " alternateMode" },
2121 {text = " Export Format" , type = " list" , var = " exportFormat" },
2222 {text = " Alpha Mask Fill Mode" , type = " list" , var = " alphaFillMode" },
23+
24+ {text = " " , type = " label" },
25+
2326 {text = " Render Mode" , type = " list" , var = " combinedRenderMode" },
27+ {text = " Render Aspect Ratio" , type = " list" , var = " aspectRatio" },
28+ {text = " Display Image Dimensions" , type = " boolean" , var = " showDimensions" },
2429
2530 {text = " " , type = " label" },
2631
@@ -50,6 +55,12 @@ function love.load()
5055 .makeList (" transparent_light" , " transparent_dark" , " alpha_mask" , " premultiplied" , " selfillum" )
5156 :appendReference (" Transparent (Light)" , " Transparent (Dark)" , " Highlight Alpha Mask" , " Premultiplied" , " Emissive ($selfillum)" );
5257
58+ aspectRatio = util
59+ .makeList (" square" , " 4_3" , " source" )
60+ :appendReference (" Square (1:1)" , " 4:3 (Label-friendly)" , " Source" );
61+
62+ showDimensions = true ;
63+
5364 readSettings ();
5465
5566 backgroundColor = {41 / 255 , 49 / 255 , 52 / 255 }
@@ -122,6 +133,15 @@ function love.draw()
122133 local imgs = {baseImagePreview , alphaImagePreview , combinedImagePreview };
123134
124135 local texts = {" Base Image" , " Alpha Image" , " Combined Image" };
136+ if (baseImageData and showDimensions ) then
137+ texts [1 ] = texts [1 ] .. " - " .. baseImageData :getWidth () .. " x" .. baseImageData :getHeight ();
138+ end
139+ if (alphaImageData and showDimensions ) then
140+ texts [2 ] = texts [2 ] .. " - " .. alphaImageData :getWidth () .. " x" .. alphaImageData :getHeight ();
141+ end
142+ if (combinedImageData and showDimensions ) then
143+ texts [3 ] = texts [3 ] .. " - " .. combinedImageData :getWidth () .. " x" .. combinedImageData :getHeight ();
144+ end
125145 for i , v in ipairs (imgSlots ) do
126146 if (imgs [i ]) then
127147 if (i == 3 ) then -- Only the combined view uses all this fancy tech
@@ -161,9 +181,23 @@ function love.draw()
161181 end
162182 end
163183
184+ -- aspectRatio = {"square", "4_3", "source"}
185+ local scalex = v .width / imgs [i ]:getWidth ();
186+ local scaley = v .height / imgs [i ]:getHeight ();
187+
188+ if (aspectRatio .current == " 4_3" ) then
189+ scaley = (v .height * 3 / 4 )/ imgs [i ]:getHeight ();
190+ elseif (aspectRatio .current == " source" ) then
191+ scalex = math.min (scalex , scaley );
192+ scaley = math.min (scalex , scaley );
193+ end
194+
195+ local px = v .x + v .width / 2 - imgs [i ]:getWidth ()* scalex / 2 ;
196+ local py = v .y + v .height / 2 - imgs [i ]:getHeight ()* scaley / 2 ;
197+
164198 love .graphics .setColor (1 , 1 , 1 , 1 );
165199 love .graphics .draw (imgs [i ],
166- v . x , v . y , 0 , v . width / imgs [ i ]: getWidth (), v . height / imgs [ i ]: getHeight () );
200+ px , py , 0 , scalex , scaley );
167201 end
168202
169203 local dropSpot ;
@@ -608,7 +642,13 @@ function renderCombinedImage()
608642 -- We ignore alpha here because it is premultiplied in the receiveAlpha step
609643 local r2 , g2 , b2 = 0 , 0 , 0 ;
610644 if (alphaFillMode .current == " stretch" ) then
611- local px , py = x / (combinedWidth - 1 ), y / (combinedHeight - 1 );
645+ local px , py = 0 , 0 ;
646+ if (combinedWidth > 1 ) then
647+ px = x / (combinedWidth - 1 );
648+ end
649+ if (combinedHeight > 1 ) then
650+ py = y / (combinedHeight - 1 );
651+ end
612652 px = px * (alphaWidth - 1 );
613653 py = py * (alphaHeight - 1 );
614654
759799function getCurrentSettings ()
760800 local _settings = {
761801 [" alternateMode" ] = alternateMode ,
802+ [" showDimensions" ] = showDimensions ,
762803 [" exportFormat" ] = exportFormat .idx ,
763804 [" alphaFillMode" ] = alphaFillMode .idx ,
764805 [" combinedRenderMode" ] = combinedRenderMode .idx ,
806+ [" aspectRatio" ] = aspectRatio .idx ,
765807 [" windowWidth" ] = windowWidth ,
766808 [" windowHeight" ] = windowHeight ,
767809 [" windowMaximized" ] = love .window .isMaximized (),
@@ -777,9 +819,11 @@ function applyCurrentSettings(_settings)
777819 end
778820
779821 alternateMode = settings [" alternateMode" ];
822+ showDimensions = settings [" showDimensions" ];
780823 exportFormat :setIdx (settings [" exportFormat" ]);
781824 alphaFillMode :setIdx (settings [" alphaFillMode" ]);
782825 combinedRenderMode :setIdx (settings [" combinedRenderMode" ]);
826+ aspectRatio :setIdx (settings [" aspectRatio" ]);
783827 local _oldWidth , _oldHeight = windowWidth , windowHeight ;
784828 windowWidth = settings [" windowWidth" ];
785829 windowHeight = settings [" windowHeight" ];
0 commit comments