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>
<meta charset="utf-8">
<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" />
</head>
@ -18,9 +18,11 @@
<a href="#">Contact</a>
</div>
<div id="canvasWrapper" class="wrapper">
<canvas id="canvas" class="canvas"></canvas>
</div>
<button class="openbtn" onclick="toggleNav()">&#9776;</button>
<h2>Collapsed Sidepanel</h2>
<p>Content...</p>
</body>
@ -36,6 +38,7 @@
nav_open = !nav_open;
}
</script>
<script src="dist/bundle.js"></script>
</html>

View file

@ -1,6 +1,64 @@
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");
}
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,58 +1,51 @@
/* The sidepanel menu */
$grey: #333;
$orange: #ff5f00;
$lightgrey: lighten($grey, 20);
$darkgrey: darken($grey, 20);
.sidepanel {
height: 100vh;
/* Specify a height */
width: 0;
/* 0 width - change this with JavaScript */
position: fixed;
/* Stay in place */
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 */
/* Remove defaults */
* {
padding: 0;
margin: 0;
border: none;
box-sizing: border-box;
}
/* 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;
text-decoration: none;
font-size: 25px;
color: #818181;
color: white;
display: block;
transition: 0.3s;
}
/* When you mouse over the navigation links, change their color */
.sidepanel a:hover {
color: #f1f1f1;
a:hover {
color: $orange;
}
/* Position and style the close button (top right corner) */
.sidepanel .closebtn {
.closebtn {
position: absolute;
top: 0;
left: 0;
font-size: 36px;
}
/* Style the button that is used to open the sidepanel */
}
.openbtn {
position: absolute;
@ -60,12 +53,30 @@
top: 5px;
font-size: 20px;
cursor: pointer;
background-color: #111;
background-color: $lightgrey;
color: white;
padding: 10px 15px;
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 = {
mode: "development",
watch: true,
entry: "./src/index.ts",
entry: ["./src/index.ts", "./src/style/style.scss"],
output: {
filename: "bundle.js",
path: __dirname + "/dist"