Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTaha Ahsan
4,717 PointsConfused in regards to how to get centerX and Y as well as Center Value
At 6:00 We add width of the rectangle divided by 2,"Why do we divide by 2?
Also, at 8:03 why subtract width and height from centervalue x and y to get origin x and y?
1 Answer
Deysha Rivera
5,088 PointsWe divide by 2, because the center of the rectangle is at the half of the length and half of the width. This "gets" us the center value.
The second part is not explained very well. We are changing the origin (originally 0,0) to match the center value of the rectangle, so we subtract what we know about the rectangle's center in order to shift it.