pushcx / leland Goto Github PK
View Code? Open in Web Editor NEWPHP code for creating hex maps
PHP code for creating hex maps
This PHP code uses the GD functions to create hex map images (eg. for wargames). ## Features: * Shapes: rectangule, hexagonal ('circle'), freeform ('free') * Variable hex sizes * shape() to calculate distance in hexes * highlight a hex * set a border on a hex * color a hex * add text to a hex * I swear it used to allow setting a background picture, but I don't see that functionality so maybe I dreamed it or lost it when I misplaced this code for four years. ## Known Issues The code has ugly styling (tabs, odd spacing, no optional braces) - sorry, I was young(er) and stupid(er). There's a fair amount of temporal coupling in there - functions that you can't call before other functions, etc. I hadn't heard of the command pattern or closures yet. There's a bug in the 'circle' shape (that the following code exercices), see http://push.cx/2010/php-hex-map-graphics for the image generated by the following code: <?php require 'class_hex_image.php'; $radius = 3; $map = new Hex_image; $map->set_color('bg', 255, 255, 255); $map->set_l(20); $map->set_shape('circle', $radius); $map->start(); for($x = 1; $x <= $map->xsize; $x++) { for($y = 1; $y <= $map->ysize; $y++) { $map->text($x, $y, 'black', $map->steps($x, $y, $radius, $radius)); // nice for getting a feel for coordinates //$map->text($x, $y, 'black', "$x,$y"); } } header('Content-Type: image.png'); $map->finish(); // calls imagepng() ?> ## Future One of the guys in #bbg on irc,freenode.net is building a browser-based game with a hex map and I remembered this code was squirreled away somewhere on my hard drive. I have no plans to fix, improve, or in any way maintain this code. I figure I may as well release it so someone can do something with it. ## License I release this code to the public domain. You may use it for any purpose with or without attribution. It would be polite to mention my name and let me know you come up with, but it's not at all required.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.