WoW:USERAPI GetMinimapShape: Difference between revisions

m
Move page script moved page USERAPI GetMinimapShape to WoW:USERAPI GetMinimapShape without leaving a redirect
mNo edit summary
m (Move page script moved page USERAPI GetMinimapShape to WoW:USERAPI GetMinimapShape without leaving a redirect)
 
(One intermediate revision by one other user not shown)
Line 114: Line 114:
  local MinimapShapes = {
  local MinimapShapes = {
  -- quadrant booleans (same order as SetTexCoord)
  -- quadrant booleans (same order as SetTexCoord)
  -- {upper-left, lower-left, upper-right, lower-right}
  -- {bottom-right, bottom-left, top-right, top-left}
  -- true = rounded, false = squared
  -- true = rounded, false = squared
  ["ROUND"] = {true, true, true, true},
  ["ROUND"] = {true, true, true, true },
  ["SQUARE"] = {false, false, false, false},
  ["SQUARE"] = {false, false, false, false},
  ["CORNER-TOPLEFT"] = {true, false, false, false},
  ["CORNER-TOPLEFT"] = {false, false, false, true },
  ["CORNER-TOPRIGHT"] = {false, false, true, false},
  ["CORNER-TOPRIGHT"] = {false, false, true, false},
  ["CORNER-BOTTOMLEFT"] = {false, true, false, false},
  ["CORNER-BOTTOMLEFT"] = {false, true, false, false},
  ["CORNER-BOTTOMRIGHT"] = {false, false, false, true},
  ["CORNER-BOTTOMRIGHT"] = {true,  false, false, false},
  ["SIDE-LEFT"] = {true, true, false, false},
  ["SIDE-LEFT"] = {false, true, false, true },
  ["SIDE-RIGHT"] = {false, false, true, true},
  ["SIDE-RIGHT"] = {true, false, true, false},
  ["SIDE-TOP"] = {true, false, true, false},
  ["SIDE-TOP"] = {false, false, true, true },
  ["SIDE-BOTTOM"] = {false, true, false, true},
  ["SIDE-BOTTOM"] = {true, true, false, false},
  ["TRICORNER-TOPLEFT"] = {true, true, true, false},
  ["TRICORNER-TOPLEFT"] = {false, true, true, true },
  ["TRICORNER-TOPRIGHT"] = {true, false, true, true},
  ["TRICORNER-TOPRIGHT"] = {true, false, true, true },
  ["TRICORNER-BOTTOMLEFT"] = {true, true, false, true},
  ["TRICORNER-BOTTOMLEFT"] = {true, true, false, true },
  ["TRICORNER-BOTTOMRIGHT"] = {false, true, true, true},
  ["TRICORNER-BOTTOMRIGHT"] = {true, true, true, false},
  }
  }
   
   
  function UpdateButtonPosition(position, radius, rounding)
  function UpdateButtonPosition(position, radius, rounding)
  if not radius then rounding = 80 end
  if not radius then radius = 80 end
  if not rounding then rounding = 10 end
  if not rounding then rounding = 10 end
  local angle = math.rad(position) -- determine position on your own
  local angle = math.rad(position) -- determine position on your own
  local x = math.sin(angle)
  local x, y
  local y = math.cos(angle)
local cos = math.cos(angle)
  local sin = math.sin(angle)
  local q = 1;
  local q = 1;
  if x < 0 then
  if cos < 0 then
  q = q + 1; -- lower
  q = q + 1; -- lower
  end
  end
  if y > 0 then
  if sin > 0 then
  q = q + 2; -- right
  q = q + 2; -- right
  end
  end
Line 148: Line 149:
  local quadTable = MinimapShapes[minimapShape];
  local quadTable = MinimapShapes[minimapShape];
  if quadTable[q] then
  if quadTable[q] then
  x = x*radius;
  x = cos*radius;
  y = y*radius;
  y = sin*radius;
  else
  else
  local diagRadius = math.sqrt(2*(radius)^2)-rounding
  local diagRadius = math.sqrt(2*(radius)^2)-rounding
  x = math.max(-radius, math.min(x*diagRadius, radius))
  x = math.max(-radius, math.min(cos*diagRadius, radius))
  y = math.max(-radius, math.min(y*diagRadius, radius))
  y = math.max(-radius, math.min(sin*diagRadius, radius))
  end
  end
  frame:SetPoint("CENTER", Minimap, "CENTER", x, y)
  frame:SetPoint("CENTER", Minimap, "CENTER", x, y)
  end
  end
Anonymous user