Skip to content

Commit

Permalink
Fix pattern selector.
Browse files Browse the repository at this point in the history
More cleanup.
  • Loading branch information
jasoncoon committed Feb 12, 2022
1 parent 7858d46 commit 53a27f4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ <h6 class="mb-2 text-muted">
<div class="input-group">
<div class="input-group-text">Pattern</div>
<select id="selectPattern" class="form-control w-auto">
<option selected>palette</option>
<option selected>physical order</option>
<option>clockwise palette</option>
<option>counter-clockwise palette</option>
<option>outward palette</option>
Expand Down
12 changes: 4 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,11 @@ context.textAlign = "center";
context.textBaseline = "middle";
context.font = "1px monospace";

// define some global variables
let width, height, rows, leds;

let minX, minY;
let maxX, maxY;
// define some global variables (working on eliminating these)
let width, height, rows, leds, maxX, maxY, minX, minY, coordsX, coordsY, angles, radii;

let offset = 0;
let offsetIncrement = 1.0;
let coordsX, coordsY, angles, radii;

let running = true;
let showPreviewBorders = true;
Expand Down Expand Up @@ -198,7 +194,7 @@ function onPaletteChange() {
}

function onPatternChange() {
const code = getPatternCode(selectPalette.value);
const code = getPatternCode(selectPattern.value);
inputPreviewCode.value = code;
onPreviewCodeChange();
if (!running) window.requestAnimationFrame(render);
Expand Down Expand Up @@ -271,7 +267,6 @@ function onTextLayoutChange() {
}

function onWindowResize() {
// const min = Math.min(window.innerWidth, window.innerHeight) - 48;
const min = window.innerWidth - 48;

canvasPreview.width = min;
Expand Down Expand Up @@ -374,6 +369,7 @@ function parsePixelblaze() {
({ height, leds, maxX, maxY, minX, minY, rows, width } = results);

document.getElementById("codeParsedPixelblaze").innerText = JSON.stringify(rows);

inputWidth.value = width;
inputHeight.value = height;
inputCenterX.value = width / 2;
Expand Down
4 changes: 2 additions & 2 deletions js/patterns.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function getPatternCode(patternName) {
switch (selectPattern.value) {
case "palette":
switch (patternName) {
case "physical order":
return "return ColorFromPalette(currentPalette, i - offset);";
case "clockwise palette":
return "return ColorFromPalette(currentPalette, angles[i] - offset);";
Expand Down

0 comments on commit 53a27f4

Please sign in to comment.