Hey guys,
i need a function for e2 where i can enter a radius, x and y coord. to produce a hexagon with all sides same size.
My idea was afunction that gives me 6 coordiantes which i can connect then.
If someone could help me out here?
this should work but i haven't tested it and is probably wrong since i did this off the top of my head
just mess around with the EdgeOffset, anything between 1 and 0 should work how you want it to, i'd start by testing 0.50
X and Y are obvious
XSize and YSize control the width,height from the center
The offset controls how far point 1,3 is from 2 and 4,6 from 5.
Code:
function void wirelink:egpHex( Index , X , Y , XSize , YSize , EdgeOffset )
{
Pos[1,vec2] = vec2(X-XSize,Y)
Pos[2,vec2] = vec2(X-(XSize*EdgeOffset),Y+YSize)
Pos[3,vec2] = vec2(X+(XSize*EdgeOffset),Y+YSize)
Pos[4,vec2] = vec2(X+XSize,Y)
Pos[5,vec2] = vec2(X+(XSize*EdgeOffset),Y-YSize)
Pos[6,vec2] = vec2(X-(XSize*EdgeOffset),Y-YSize)
Screen:egpPoly(Index, Pos)
}
function void wirelink:egpHexOutline( Index , X , Y , XSize , YSize , EdgeOffset )
{
Pos[1,vec2] = vec2(X-(XSize*EdgeOffset),Y-YSize)
Pos[2,vec2] = vec2(X-XSize,Y)
Pos[3,vec2] = vec2(X-(XSize*EdgeOffset),Y+YSize)
Pos[4,vec2] = vec2(X+(XSize*EdgeOffset),Y+YSize)
Pos[5,vec2] = vec2(X+XSize,Y)
Pos[6,vec2] = vec2(X+(XSize*EdgeOffset),Y-YSize)
Screen:egpPolyOutline(Index, Pos)
}
Example:
EGP:egpHex(1, 256, 256, 50, 20, 0.50 )
That would create it in the center of the screen with a size of 100,40.
The offset controls how far point 1,3 is from 2 and 4,6 from 5.
just a visualization on how the sizing works and the point positions if i didn't screw the function up