Jump to content

Context::SetScale breaks some drawing commands

Recommended Posts



I wanted to scale my GUI using the setscale command and found some of the drawing commands do not function correctly.


The drawrect command works properly.


The plot command does not scale at all.


The line command does not work properly in straight lines horizontally or vertically, but it does diagonally.


Hear is code to test and explain:


--This function will be called once when the program starts
function App:Start()

--Initialize Steamworks (optional)

--Set the application title

--Create a window
local windowstyle = window.Titlebar
if System:GetProperty("fullscreen")=="1" then windowstyle=windowstyle+window.FullScreen end

--Create the graphics context
if self.context==nil then return false end

return true

--This is our main program loop and will be called continuously until the program ends
function App:Loop()

--If window has been closed, end the program
if self.window:Closed() or self.window:KeyDown(Key.Escape) then return false end

--Update the app timing

self.context:SetScale(2,2) -- everything should be twice as big

self.context:DrawRect(0,0,200,200) -- This is the size the line squares should be at

for y = 1 , 200 do -- this should make a solid square, not rectangle
self.context:DrawLine(5, y , 205, y ) -- draw square at an offset so you can see its dimensions in a relative manner


for x = 5 , 205 do -- this should make a solid square also
self.context:DrawLine(x, 5 , x, 205 ) -- draw square at an offset so you can see its dimensions in a relative manner

self.context:DrawLine(0,0,200,200) -- the line is off from actuall 0,0 by a few pixels but it is the size

self.context:Plot(200,200) -- this should actually be at the edge of the white box but its at real cordinates 100,100

--Refresh the screen

--Returning true tells the main program to keep looping
return true

function App:rgbatovec4scalar(rgb,a)
return Vec4(rgb[1]/256,rgb[2]/256,rgb[3]/256,a/256)


As long as this is does not function as intended, my gui will have to be put on the backburner.

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...