Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Using setSize() relative to the origin  (Read 1293 times)

0 Members and 1 Guest are viewing this topic.

goodk1d

  • Guest
Using setSize() relative to the origin
« on: October 14, 2017, 05:49:26 pm »
Hello, is there any way to resize a rectangle relative to its center? As far as I know, its origin is only used for rotation, scaling, and positioning. Using .setSize() only resizes relative to the shape's top-left corner.

Currently trying to draw my AABBs for rotating rectangles but I can't figure out how to draw them.

What I have are the minimum vectors of the AABBs (top-left points) and their origin. Is there any workaround to this, or should I just use VertexArrays?

I'd prefer if I didn't have to do the latter, since I've already spent about 3 hours trying to figure out the workaround. ::)
« Last Edit: October 14, 2017, 05:52:09 pm by goodk1d »

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: Using setSize() relative to the origin
« Reply #1 on: October 14, 2017, 08:18:28 pm »
I assume you're actually wanting the origin to be updated relative to the new size.

So,
(click to show/hide)

goodk1d

  • Guest
Re: Using setSize() relative to the origin
« Reply #2 on: October 15, 2017, 03:03:57 am »
Ooooh, never thought about it that way. I'm stupid.

It works now. Thanks for the help!!