Quantcast
Channel: VBForums - Maths Forum
Viewing all articles
Browse latest Browse all 118

Generating rectangles around a centre point in a spiral starting from the centre

$
0
0
Ehh, it's been a while since I've been on VBForums. Feels a little nostalgic :bigyello:

Anyway I have a central point (40x40 pixel rectangle) and I want to generate (40x40 pixel) rectangles around it in a spiral, starting from the centre.
The quantity is variable. If 0,0 is the centre point, I want to create rectangles like so:

Code:

0,1 >>> 1,1 >>> 1,0 >>> 1,-1 >>> 0,-1 >>> -1,-1 >>> -1,0 >>> -1,1 >>> -1, 2 >>> 0,2 >>> 1,2 >>> 2,2 >>> 2,1
And I want them to continue around that centre point, in that pattern. For reference, 0,1 is up one square and 1,1 is to the right of 0,1.
I don't need to know this, I'm going to hardcode it as I only need at the very most 40 of these... however it's piqued my curiosity.

I would give an example of what I'm capable of so far... but that'd get me as far as the for loop and an x and y variable which can't be that helpful :p

Anyone have any idea about this?

Viewing all articles
Browse latest Browse all 118

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>