mirror of
https://github.com/adanrsantos/ThePlaceHolders.git
synced 2024-12-16 10:10:39 -06:00
Compare commits
No commits in common. "dfc07022285f1f9bd45b1b3f0056aafdf0905f56" and "ab5c4342c8f045cfe02eb4f90158934bbc8bfd98" have entirely different histories.
dfc0702228
...
ab5c4342c8
|
@ -3,27 +3,21 @@ const ctx = canvas.getContext("2d");
|
|||
|
||||
const canvasSize = 500;
|
||||
const dataSize = 1000;
|
||||
const gridCount = 10;
|
||||
let zoom = 1.0;
|
||||
const centerPixel = getPixelSize() / 2;
|
||||
|
||||
function getPixelSize() {
|
||||
return canvasSize / gridCount * zoom;
|
||||
}
|
||||
|
||||
const gridCount = 10 ;
|
||||
canvas.width = canvasSize;
|
||||
canvas.height = canvasSize;
|
||||
|
||||
//let pixelSize = canvasSize / dataSize;
|
||||
let pixelSize = canvasSize / gridCount;
|
||||
const centerPixel = pixelSize / 2;
|
||||
|
||||
function drawGrid() {
|
||||
if (getPixelSize() < 5) {
|
||||
return;
|
||||
}
|
||||
ctx.strokeStyle = '#000'; // Set grid line color
|
||||
ctx.lineWidth = 1; // Set grid line width
|
||||
|
||||
// Draw horizontal lines
|
||||
for (let i = 0; i <= gridCount; i++) {
|
||||
let y = i * getPixelSize();
|
||||
let y = i * pixelSize;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, y); // Start the line at the left edge (x = 0)
|
||||
ctx.lineTo(canvasSize, y); // Draw to the right edge (x = canvasSize)
|
||||
|
@ -32,7 +26,7 @@ function drawGrid() {
|
|||
|
||||
// Draw vertical lines
|
||||
for (let i = 0; i <= gridCount; i++) {
|
||||
let x = i * getPixelSize();
|
||||
let x = i * pixelSize;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x, 0); // Start the line at the top edge (y = 0)
|
||||
ctx.lineTo(x, canvasSize); // Draw to the bottom edge (y = canvasSize)
|
||||
|
@ -89,7 +83,7 @@ class Point {
|
|||
|
||||
function draw(point) {
|
||||
point = point.canvasToData().dataToCanvas()
|
||||
ctx.fillRect(point.x, point.y, getPixelSize(), getPixelSize());
|
||||
ctx.fillRect(point.x, point.y, pixelSize, pixelSize);
|
||||
}
|
||||
|
||||
canvas.addEventListener("mousedown", (e) => {
|
||||
|
|
Loading…
Reference in a new issue