Currently I have a drawing feature in my game where it places a frame at the mouse position, and it works great if I’m just using offset. Problem is, I’ll need to take that drawing, and be able to render it on many different frames (same aspect ratio, different sizes). So, I was thinking that I would need to convert the positional value to scale.
I’ve tried dividing by the viewport, but the problem is, this is relative to the screen, rather than the frame (see video below).
function Signing:_offsetToScale(x, y)
local viewport = workspace.Camera.ViewportSize
return x / viewport.X, y / viewport.Y
end
Is it possible to make it relative to the frame, or should I take a different approach in how I use offset so I can render the drawing on different scales?
I think that’s what I am currently doing, but I don’t get what you mean
Use the mouse/viewport scale or something else?
function Signing:_offsetToScale(x, y, canvas)
local viewport = canvas.AbsoluteSize
return x / viewport.X, y / viewport.Y
end
function Signing:_drawAt(x, y, canvas)
local point = Instance.new("Frame")
--x & y come from the mouse pos
x, y = Signing:_offsetToScale(x, y, canvas)
point.Position = UDim2.fromScale(x, y)
point.Parent = canvas
-- code is truncated, but this is the part you are referring to
end
If your frame is in the exact center of the screen, you could possibly apply an offset of the mouse relative to the center of the frame as the position of the points.