Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Simple jQuery Hex Grid widget for game prototyping</title>
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <meta name="keywords" content="jquery opensource hexgrid hex grid" />
- <meta name="description" content="A simple jQuery Hex grid Widget, implemented using SVG, for prototyping hex-grid based games." />
- <link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
- <link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css" rel="stylesheet">
- <link href="https://netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css" rel="stylesheet">
- <script src="https://code.jquery.com/jquery-2.1.4.min.js" ></script>
- <script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
- <script src="hexgridwidget.js" ></script>
- <style type="text/css">
- svg {}
- .hexfield {
- fill: transparent;
- stroke: green;
- stroke-width: 1;
- }
- .hexfield:focus {
- outline:none;
- }
- .hexfield:hover {
- fill: blue;
- }
- .hexfield:active {
- fill: red;
- outline: none;
- }
- .hexfield.clicked{
- fill: black;
- }
- body {
- background-image: url("https://i.imgur.com/7D14Jol.jpg");
- background-size: cover; /* <------ */
- background-repeat: no-repeat;
- }
- h1 {
- background-image: url("https://i.imgur.com/7D14Jol.jpg");
- background-size: cover; /* <------ */
- background-repeat: no-repeat;
- }
- p {
- background-color: white;
- background-color: rgba(255, 255, 255, .85);
- }
- .container {
- min-height: 12000px;
- width: 8551px;
- overflow: auto;
- padding-left: 1090px;
- padding-top: 1005px;
- }
- </style>
- </head>
- <body>
- <form class="form-horizontal" onsubmit="return false;">
- <div class="container">
- <div class="left">
- <div id="container">
- </div>
- </div>
- </form>
- <script>
- <!-- main initialisation -->
- var rebuild = function () {
- var
- radius = 83.20,
- columns = 60,
- rows = 60,
- cssClass = 'hexfield';
- $('#container').empty().hexGridWidget(radius, columns, rows, cssClass).on('hexclick', function (e) {
- $('#logger').text('clicked [' + e.column + ',' + e.row + '] hex with center at [' + e.center.x + ',' + e.center.y + '] px');
- });
- $('#container .hexfield').click(function () {
- this.classList.toggle('clicked');
- });
- };
- rebuild();
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement