All pastes #797421 Raw Edit

Something

public lua v1 · immutable
#797421 ·published 2007-11-25 23:57 UTC
rendered paste body
function MobileMinimapButtons_Master_OnUpdate(self, elapsed)	if self.isMoving or self.isChangingRadius then		local mouseX, mouseY = GetCursorPosition();		local centerX, centerY = Minimap:GetCenter();		local scale = Minimap:GetEffectiveScale();		mouseX = mouseX / scale;		mouseY = mouseY / scale;		local x = mouseX - centerX;		local y = mouseY - centerY;				local minimapShape = GetMinimapShape and GetMinimapShape() or "ROUND";		local quadTable = MobileMinimapButtons_MinimapShapes[minimapShape];		local quadrantIndex = 1;		if mouseX < centerX then			quadrantIndex = quadrantIndex + 1;	-- bottom		end		if mouseY >= centerY then			quadrantIndex = quadrantIndex + 2;	-- right		end				local frameName = self:GetName();		local radiusMod = self.radiusMod or MobileMinimapButtons_Coords[frameName] and MobileMinimapButtons_Coords[frameName].radiusMod or 1;		local radius, angle;				if self.isMoving and not self.radius or self.isChangingRadius then			local modifier = MobileMinimapButtons_ButtonSizeModifiers[frameName] or MobileMinimapButtons_DefaultButtonSizeModifier;			local mapRadius = ((Minimap:GetRight()-Minimap:GetLeft())/2)			local buttonDiameter = (self:GetRight()-self:GetLeft())*modifier						if self.isMoving then				radius = mapRadius * radiusMod + buttonDiameter;			elseif self.isChangingRadius then				self.isChangingRadius = self.isChangingRadius+1;								if self.angle then					angle = self.angle				else					local buttonX, buttonY = self:GetCenter();					angle = math.atan2(buttonX-centerX, buttonY-centerY);				end				radius = math.cos(angle) * y + math.sin(angle) * x;				if not quadTable[quadrantIndex] then					-- if the quadrent is square modify the radius to represent a circular one					radius = radius * math.cos(math.fmod(math.fmod(angle + PI/4, PI/2) + PI/2, PI/2) - PI/4)					--[[					-- This if statements gives the same result as the previous equation					if (angle < PI*1/4 and angle > -PI*1/4) then						radius = radius*math.cos(angle)					elseif (angle > PI*3/4 or angle < -PI*3/4) then						radius = -radius*math.cos(angle)					elseif (angle < PI*3/4 and angle > PI*1/4) then						radius = radius*math.sin(angle)					elseif (angle > -PI*3/4 and angle < -PI*1/4) then						radius = -radius*math.sin(angle)					end					]]--				end				radius = max(radius, 20);				radiusMod = (radius - buttonDiameter) / mapRadius;			end					elseif self.isMoving then			radius = self.radius;		end				if self.isMoving then			self.isMoving = self.isMoving+1;			angle = math.atan2(x,y);		end				if quadTable[quadrantIndex] then			x = math.sin(angle)*radius;			y = math.cos(angle)*radius;		else			local diagRadius = sqrt(2*(radius)^2) - MobileMinimapButtons_SquareCornerRounding*radiusMod			x = math.max(-radius, math.min(math.sin(angle)*diagRadius, radius))			y = math.max(-radius, math.min(math.cos(angle)*diagRadius, radius))		end				self.angle = angle		self.radius = radius		self.radiusMod = radiusMod		self.currentX = x;		self.currentY = y;		self:ClearAllPoints();		self:SetPoint("CENTER", "Minimap", "CENTER", self.currentX, self.currentY);	else		return true;	endend