Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Expression 2 v
« Previous 1 … 4 5 6 7 8 Next »
E2 egp hexagon
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode
E2 egp hexagon
04-02-2015, 05:28 PM,
#1
Skyteks Offline
Game Programmer
****
Posts: 109
Threads: 19
Joined: Nov 2013
Question  E2 egp hexagon
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? Huh

[Image: giphy.gif]
Find
Reply
05-02-2015, 03:03 AM,
#2
TheOneAndOnlyTee Offline
GMod Admin
Posts: 755
Threads: 47
Joined: Oct 2013
RE: E2 egp hexagon
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

Steam Profile
My Discord Server
Need help with E2 or SF? , just ask me and i'll try to help.
[Image: 98Dkcoz.gif]
Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.