Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

Commit

Permalink
main.js updated with generation on shape and eventListener added. sty…
Browse files Browse the repository at this point in the history
…le.css updated with appropriate styles for index.html
  • Loading branch information
auxfuse committed Oct 31, 2021
1 parent f3f1ad6 commit c747ce6
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 17 deletions.
8 changes: 8 additions & 0 deletions .idea/Canvaz.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 36 additions & 12 deletions src/art/auxfuse-points/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Auxfuse - Canvaz Points to Shape</title>
</head>
<body>
<canvas></canvas>

<script src="main.js"></script>
</body>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Auxfuse - Canvaz Points to Shape</title>
</head>
<body>
<div class="utils">
<h1>Shape Generator</h1>

<p>
Radius determines the size of the shape. The inset will determine the inwards direction
and length of an edge. Points will determine the overall shape itself, 3 making a triangle,
4 a rectangle, 5 a pentagon (or a star if inset is set to 0.5) etc etc.
</p>

<p>Select the radius, the inset, and the amount of points, then click "Generate".</p>
<form>
<label for="points">Radius</label>
<input type="number" value="100" min="100" max="1000" id="radius">

<label for="points">Inset</label>
<input type="number" value="0.5" min="0.1" max="1000" id="inset">

<label for="points">Points</label>
<input type="number" value="7" min="1" max="1000" id="points">

<button id="submit" type="submit">Generate</button>
</form>
</div>

<canvas></canvas>

<script src="main.js"></script>
</body>
</html>
12 changes: 10 additions & 2 deletions src/art/auxfuse-points/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const c = document.querySelector('canvas');
const ctx = c.getContext('2d');
const radius = document.querySelector('#radius');
const inset = document.querySelector('#inset');
const points = document.querySelector('#points');
const submit = document.querySelector('#submit');

c.height = window.innerHeight;
c.height = window.innerHeight*0.75;
c.width = window.innerWidth;

function sides(r, inset, n){
Expand All @@ -24,4 +28,8 @@ function sides(r, inset, n){
ctx.fill();
};

sides(100, 0.5, 6);
submit.addEventListener('click', e => {
e.preventDefault();

sides(radius.value, inset.value, points.value);
});
45 changes: 42 additions & 3 deletions src/art/auxfuse-points/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,46 @@ body {
}

canvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 60vh;
object-fit: contain;
}

.utils {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 1rem 2rem;
text-align: center;
}

.utils > p {
margin: 1rem;
padding: 0 2rem;
}

.utils > p:nth-child(3) {
font-weight: bold;
}

form {
display: flex;
flex-direction: column;
align-items: center;
}

form > * {
margin: 0.3rem;
}

form > label {
margin: 0;
font-weight: bold;
}

@media (min-width: 576px) {
form {
flex-direction: row;
}
}

0 comments on commit c747ce6

Please sign in to comment.