WeakAuras

WeakAuras

206M Downloads

Add icon offset options for rectangular icons.

Mistrick opened this issue ยท 0 comments

commented

Is your feature request related to a problem? Please describe.
Sometimes cropped icons look weird but can be made better by moving them up or down

Describe the solution you'd like
Add icon offset options. Move icon right or left, up or down.

Describe alternatives you've considered
I found this code in someone's WA on wago.
In init section.

--- OPTIONS ---
aura_env.icon_crop = 0.05-- The abound of Icon zoom (crop of its borders) Can me any value from 0 to 1 but more than 0.3 hardly makes much sence.
aura_env.icon_offset_X = 0.5  -- Horizontal position of the shown texture (0 - shows the leftmost part, 1 shows the rightmost part)
aura_env.icon_offset_Y = 0.0  -- Vertical position of the shown texture (0 - shows the topmost part, 1 shows the bottommost part)
--- DON'T EDIT BELOW ---

aura_env.set_coord = function()
    local X = aura_env.region.width
    local Y = aura_env.region.height
    local length_X = (1 - aura_env.icon_crop) * (X / math.max(X,Y))
    local length_Y = (1 - aura_env.icon_crop) * (Y / math.max(X,Y))
    local axis_X = (aura_env.icon_crop + length_X) * 0.5 + aura_env.icon_offset_X * (1 - aura_env.icon_crop - length_X)
    local axis_Y = (aura_env.icon_crop + length_Y) * 0.5 + aura_env.icon_offset_Y * (1 - aura_env.icon_crop - length_Y)
    
    local X1 = axis_X - length_X * 0.5
    local X2 = axis_X + length_X * 0.5
    local Y1 = axis_Y - length_Y * 0.5
    local Y2 = axis_Y + length_Y * 0.5

    aura_env.region.icon:SetTexCoord(X1, X2, Y1, Y2)
end

aura_env.set_coord ()

Additional context
Before
Screenshot 2022-11-18 121251
After
Screenshot 2022-11-18 121316