VMatrix Scale causes Translation

Hey guys, vgui related question here.

I am making a window with several drag and drop panels on it. I am using a certain function to create scaled panels with cam.PushModelMatrix(mat) to scale the material I make inside the panel’s Think() hook. Before the cam.PushModelMatrix(mat), I use mat:Scale(Vector(1, 1, 1) * Scale). This makes the custom material I made scaled to the right size for the situation I need to draw it in. It all works fine an dandy.

To attempt to counter act this I did some math. Thus I did the following
mat:Scale(Vector(1, 1, 1) * Scale)
mat:Translate(Vector(xoffset * Scale + xoffset, yoffset * Scale + yoffset))

The issue is after scaling (in this case by ~42%), the movement speed of the material decreases by 42% when I drag the parent panel. Meaning If I drag the draggable parent 100 pixels to the left, the material only moves 42 pixels.

Let me know if you guys have any ideas on why this happens, as well as how to counter it!

Thanks guys!



Why do you call :Scale first, then :Translate?

Because I Derive the equation I use is the distance the image auto-translates. So I scale it first, then move it back to where it should be.

I can’t understand what you just said.