This commit is contained in:
ajuvercr 2019-10-20 15:53:23 +02:00
parent dbd32194a1
commit fd06dceeb2
4 changed files with 125 additions and 53 deletions

View file

@ -4,7 +4,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Planetwars Mapbuilder</title> <title>Planetwars Mapbuilder</title>
<link rel="stylesheet" type="text/css" href="./static/res/style.css"> <!-- <link rel="stylesheet" type="text/css" href="./static/res/style.css"> -->
<link rel="shortcut icon" type="image/x-icon" href="./favicon.ico" /> <link rel="shortcut icon" type="image/x-icon" href="./favicon.ico" />
</head> </head>
@ -18,9 +18,11 @@
<a href="#">Contact</a> <a href="#">Contact</a>
</div> </div>
<div id="canvasWrapper" class="wrapper">
<canvas id="canvas" class="canvas"></canvas>
</div>
<button class="openbtn" onclick="toggleNav()">&#9776;</button> <button class="openbtn" onclick="toggleNav()">&#9776;</button>
<h2>Collapsed Sidepanel</h2>
<p>Content...</p>
</body> </body>
@ -36,6 +38,7 @@
nav_open = !nav_open; nav_open = !nav_open;
} }
</script> </script>
<script src="dist/bundle.js"></script> <script src="dist/bundle.js"></script>
</html> </html>

View file

@ -1,6 +1,64 @@
function main() { function main() {
const canvas = <HTMLCanvasElement>document.getElementById("canvas");
const ctx = canvas.getContext('2d');
const width = canvas.clientWidth;
const height = canvas.clientHeight;
canvas.width = width;
canvas.height = height;
ctx.translate(width / 2, height / 2);
ctx.strokeStyle = "#333"
draw_grid(
ctx, [width, 100, 20], [width / 2, height / 2], [width, height],
4, 0.30
);
ctx.fillStyle = "#ff5f00";
ctx.fillRect(0, 0, 100, 100);
console.log("hallo"); console.log("hallo");
} }
main(); function draw_grid(
ctx: CanvasRenderingContext2D,
lines: number[], // number of pixels between lines, with smaller gettings lines
transform: [number, number],
size: [number, number],
init_width = 2, factor = 0.5) {
ctx.save();
ctx.translate(-transform[0], -transform[1]);
for (let delta of lines) {
ctx.lineWidth = init_width;
let xoff = transform[0] % delta;
let yoff = transform[1] % delta;
ctx.beginPath();
for (let i = xoff; i < size[0]; i += delta) {
ctx.moveTo(i, 0);
ctx.lineTo(i, size[1]);
}
for (let j = yoff; j < size[1]; j += delta) {
ctx.moveTo(0, j);
ctx.lineTo(size[0], j);
}
ctx.stroke();
init_width *= factor;
}
ctx.restore();
}
setTimeout(main, 200);

View file

@ -1,71 +1,82 @@
/* The sidepanel menu */ $grey: #333;
$orange: #ff5f00;
$lightgrey: lighten($grey, 20);
$darkgrey: darken($grey, 20);
.sidepanel { /* Remove defaults */
height: 100vh;
/* Specify a height */ * {
width: 0; padding: 0;
/* 0 width - change this with JavaScript */ margin: 0;
position: fixed; border: none;
/* Stay in place */ box-sizing: border-box;
z-index: 1;
/* Stay on top */
top: 0;
right: 0;
background-color: #111;
/* Black*/
overflow-x: hidden;
overflow-y: scroll;
/* Disable horizontal scroll */
padding-top: 60px;
/* Place content 60px from the top */
transition: 0.5s;
/* 0.5 second transition effect to slide in the sidepanel */
} }
/* The sidepanel links */ /* Side panel styling */
.sidepanel a { .sidepanel {
/* 0 width - change this with JavaScript */
height: 100vh;
width: 0;
/* sizing */
position: fixed;
z-index: 1;
top: 0;
right: 0;
background-color: $grey;
overflow-x: hidden;
padding-top: 60px;
transition: 0.5s;
a {
padding: 8px 8px 8px 32px; padding: 8px 8px 8px 32px;
text-decoration: none; text-decoration: none;
font-size: 25px; font-size: 25px;
color: #818181; color: white;
display: block; display: block;
transition: 0.3s; transition: 0.3s;
} }
a:hover {
color: $orange;
/* When you mouse over the navigation links, change their color */ }
.closebtn {
.sidepanel a:hover {
color: #f1f1f1;
}
/* Position and style the close button (top right corner) */
.sidepanel .closebtn {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
font-size: 36px; font-size: 36px;
}
} }
/* Style the button that is used to open the sidepanel */
.openbtn { .openbtn {
position: absolute; position: absolute;
right: 5px; right: 5px;
top: 5px; top: 5px;
font-size: 20px; font-size: 20px;
cursor: pointer; cursor: pointer;
background-color: #111; background-color: $lightgrey;
color: white; color: white;
padding: 10px 15px; padding: 10px 15px;
border: none; border: none;
&:hover {
background-color: $orange;
color: darken($color: $grey, $amount: 10);
}
&:focus {
outline: none;
}
} }
.openbtn:hover {
background-color: #444; /* Main body styling */
.wrapper {
background-color: darken($color: $grey, $amount: 20);
width: 100vw;
height: 100vh;
overflow: hidden;
}
.canvas {
width: 100%;
height: 100%;
} }

View file

@ -1,7 +1,7 @@
module.exports = { module.exports = {
mode: "development", mode: "development",
watch: true, watch: true,
entry: "./src/index.ts", entry: ["./src/index.ts", "./src/style/style.scss"],
output: { output: {
filename: "bundle.js", filename: "bundle.js",
path: __dirname + "/dist" path: __dirname + "/dist"