Compare commits

..

2 commits

Author SHA1 Message Date
reddishquill371 feb9c1cc6d working on canvas js color switcher 2024-11-13 18:37:27 -06:00
th3keyboard 643e535a1f changed toolbar, not finished 2024-11-13 18:31:14 -06:00
3 changed files with 128 additions and 58 deletions

View file

@ -12,6 +12,7 @@ html, body {
height: 100%;
width: 100%;
margin: 0px;
overflow: hidden;
}
.wrapper {
@ -86,21 +87,26 @@ html, body {
bottom: 0;
}
.toolbarItems {
display: flex;
flex-direction: column;
justify-content: start;
font-weight: 900;
.toolbarItems label, input {
float: left;
padding: 8px;
font-size: 14px;
color: white;
text-align: center;
height: 20px;
width: 20px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
}
.toolbarItems button {
display: flex;
flex-direction: row;
justify-content: space-around;
float: right;
padding: 16px;
}
.strokePicker{
margin: 2px;
padding: 0;
margin: 0;
width: 100%;
}
.strokePicker:hover {
@ -149,4 +155,32 @@ canvas {
.toolbar {
font-size: 80%;
}
.toolbarItems label, input {
float: left;
padding: 4px;
font-size: 7.5px;
color: white;
font-family: Verdana, Geneva, Tahoma, sans-serif;
}
.toolbarItems button {
display: flex;
flex-direction: row;
justify-content: space-around;
float: right;
padding: 8px;
padding-left: 24px;
}
.strokePicker{
margin: 2px;
height: 16px;
width: 60px;
}
.strokePicker:hover {
cursor: pointer;
}
}

View file

@ -24,61 +24,90 @@
<canvas id="canvas" width="500" height="500" style="border:1px solid #000000;" alt="canvas"></canvas>
<div id="toolbar" class="d-flex align-items-center toolbar">
<div class="toolbarItems">
<!--extra space for toolbar-->
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(255, 255, 255);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<label for="stroke">Strokes</label>
<input id="stroke" name="stroke" type="color" class="strokePicker">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(0, 0, 0);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<!--extra space for toolbar-->
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,128,128);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,0,0);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,128,0);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(0,128,0);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(0,128,128);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(0,0,128);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,0,128);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,128,64);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(0,64,64);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(0,128,255);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(64,0,255);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,64,0);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(192,192,192);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(255,0,0);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(255,255,0);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(0,255,0);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(0,255,255);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(0,0,247);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(255,0,255);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(255,255,128);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(0,255,128);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,255,255);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,128,255);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(255,0,128);" type="button" onclick="changeColor()"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(255,128,64);" type="button" onclick="changeColor()"></button>
</div>
</div>
<!--</div>-->
<!--note to self: above IS the canvas-->
</div>
<div id="toolbar" class="d-flex toolbar flex-wrap">
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(255, 255, 255);" type="button"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(0, 0, 0);" type="button"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,128,128);" type="button"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,0,0);" type="button"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,128,0);" type="button"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(0,128,0);" type="button"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(0,128,128);" type="button"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(0,0,128);" type="button"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,0,128);" type="button"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,128,64);" type="button"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,128,64);" type="button"></button>
</div>
<div class="toolbarItems">
<button id="colorPicker" style="height:20px; width:20px; background-color:rgb(128,128,64);" type="button"></button>
</div>
<!--<div class="toolbarItems">
<label for="stroke">Strokes</label>
<input id="stroke" name="stroke" type="color" class="strokePicker">
</div>-->
</div>
<script src="./canvas.js"></script>
</body>
</html>

View file

@ -121,6 +121,13 @@ function moveOffset(x, y) {
offy = Math.min(Math.max(y, -10 - DATA_SIZE / 2), DATA_SIZE + 10);
}
function changeColor() {
var button = document.getElementById("colorPicker");
var style = getComputedStyle(button);
console.log(style['background-color']);
}
canvas.addEventListener("wheel", async (e) => {
let mouse = mousePosition(e);
let oldScale = scale;
@ -163,7 +170,7 @@ canvas.addEventListener("mouseup", async (e) => {
if (cx < 0 || cx > CANVAS_SIZE || cy < 0 || cy > CANVAS_SIZE) {
return;
}
setPixel(image.data, cx, cy, [0, 0, 255, 255]);
setPixel(image.data, cx, cy, pixelColor);
await redraw();
draw();
}