Skip to content

Commit 156c855

Browse files
committed
minor changes
1 parent 68cc196 commit 156c855

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

js/events.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
// events.js
2-
3-
import { config, mandelbrotCanvas, juliaCanvas, pixelRatio, scalePerZoom, rangeInput, colorCompressionRange, colorCompressionDisplay, themeSelector } from './config.js';
1+
import { config, mandelbrotCanvas, pixelRatio, scalePerZoom, rangeInput, colorCompressionRange, colorCompressionDisplay, themeSelector } from './config.js';
42
import { renderJulia } from './rendering.js';
5-
import { canvasToMandelbrot, getCanvasCoordinates, preventDefaultBehavior } from './utils.js';
3+
import { cursorCoordinates, getCanvasCoordinates, preventDefaultBehavior } from './utils.js';
64

75
// Update max iterations
86
const updateMaxIterations = () => {
@@ -29,7 +27,6 @@ const updateColorCompression = () => {
2927
// Track Ctrl key press
3028
const handleCtrlKey = (event, pressed) => {
3129
if (event.key === 'Control') {
32-
console.log(`Ctrl ${pressed ? 'pressed' : 'unpressed'}.`);
3330
config.isCtrlPressed = pressed;
3431
}
3532
};
@@ -39,7 +36,7 @@ const handleCtrlClick = (event) => {
3936
if (config.isCtrlPressed && event.button === 0) {
4037
preventDefaultBehavior(event);
4138
const { x, y } = getCanvasCoordinates(event);
42-
const { x: mouseX, y: mouseY } = canvasToMandelbrot(x, y);
39+
const { x: mouseX, y: mouseY } = cursorCoordinates(x, y);
4340
config.targetCenter = [mouseX, mouseY];
4441
}
4542
};
@@ -51,8 +48,8 @@ const handleWheelZoom = (event) => {
5148
const delta = Math.min(Math.max(-event.deltaY * 5, -100), 100) / 100;
5249
config.targetZoom += delta;
5350

54-
const { x: mouseXBefore, y: mouseYBefore } = canvasToMandelbrot(x, y);
55-
const { x: mouseXAfter, y: mouseYAfter } = canvasToMandelbrot(x, y);
51+
const { x: mouseXBefore, y: mouseYBefore } = cursorCoordinates(x, y);
52+
const { x: mouseXAfter, y: mouseYAfter } = cursorCoordinates(x, y);
5653
config.center[0] += (mouseXBefore - mouseXAfter);
5754
config.center[1] += (mouseYBefore - mouseYAfter);
5855
};
@@ -67,7 +64,7 @@ const handleMouseMove = (event) => {
6764
}
6865

6966
const { x, y } = getCanvasCoordinates(event);
70-
const { x: mandelbrotX, y: mandelbrotY } = canvasToMandelbrot(x, y);
67+
const { x: mandelbrotX, y: mandelbrotY } = cursorCoordinates(x, y);
7168
config.juliaConstant = [mandelbrotX, mandelbrotY];
7269
renderJulia();
7370
document.querySelector("#Re").value = mandelbrotX.toFixed(8);

js/rendering.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// rendering.js
21
import { mandelbrotGl, juliaGl, mandelbrotCanvas, juliaCanvas, scalePerZoom, config } from './config.js';
32

43
// Render the Mandelbrot set

js/shaders.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// shaders.js
21
import { mandelbrotGl, juliaGl, config } from './config.js';
3-
import { createBuffer, configureAttributes } from './utils.js';
2+
import { configureAttributes } from './utils.js';
43

54
export const fetchShaders = async () => {
65
const [vertexSource, mandelbrotSource, juliaSource] = await Promise.all([

js/utils.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// utils.js
21
import { pixelRatio, config, scalePerZoom, mandelbrotCanvas, zoomSpeed, zoomLevelDisplay } from './config.js';
32

43
export const createBuffer = (gl) => {
@@ -30,7 +29,7 @@ export const resizeCanvas = (canvas, gl) => {
3029
};
3130

3231
// Function to convert canvas coordinates to Mandelbrot coordinates
33-
export const canvasToMandelbrot = (x, y) => {
32+
export const cursorCoordinates = (x, y) => {
3433
const pointX = ((x / mandelbrotCanvas.width * 2 - 1) / (
3534
(scalePerZoom ** config.zoom) / (mandelbrotCanvas.width / mandelbrotCanvas.height)
3635
)) + config.center[0];

0 commit comments

Comments
 (0)