flamendless / Slab

An immediate mode GUI for the Love2D framework.
MIT License
286 stars 25 forks source link

Slab.Image outline not matching the image #154

Closed pakeke-constructor closed 1 year ago

pakeke-constructor commented 1 year ago

repro:

function love.update(dt)
    -- in this image, the outline size does not match the image size.
    Slab.Image("my_image.png", {  UseOutline = true },  W = 64, H = 64})
end

Doing some digging into this rn.

pakeke-constructor commented 1 year ago

update: the issue occurs when W H values are specified.

Inside the Image.Begin code, the rectangle width/height is scaled down twice, whereas the image is scaled down once. Can be fixed by dividing the W,H by the scale first, like so:


    if options.UseOutline then
        DrawCommands.Rectangle(
            'line',
            x,
            y,
            useSubImage and subW or w / scaleX,
            useSubImage and subH or h / scaleY,
            options.OutlineColor or BLACK,
            nil,
            nil,
            options.OutlineW or 1
        )
    end
pakeke-constructor commented 1 year ago

I'll make a pr for this rn.

flamendless commented 1 year ago

Thanks!

pakeke-constructor commented 1 year ago

ty.