-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.js
More file actions
60 lines (50 loc) · 1.14 KB
/
common.js
File metadata and controls
60 lines (50 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*** GLOBALS ***/
var startReal,
endReal,
startComplex,
endComplex,
iterations,
coloringType,
hueOffset,
exponent,
count;
var isRunning;
var canvas,
huePreviewCanvas,
context,
canvasWidth,
canvasHeight,
huePreviewCanvasWidth = 200,
huePreviewCanvasHeight = 45;
$(document).ready(function() {
// set initial window values
resetWindow();
exponent = 2;
canvas = $('#canvas');
context = $(canvas)[0].getContext("2d");
huePreviewCanvas = $('#huePreviewCanvas');
huePreviewContext = $(huePreviewCanvas)[0].getContext("2d");
setupView();
});
function resetWindow() {
startReal = - 2.5;
endReal = 1.5;
startComplex = - 2.1;
endComplex = 2.0;
iterations = 100;
coloringType = 1;
hueOffset = 0;
}
function pointIsIn(px, py, originX, originY, width, height) {
if (px < originX || px > originX + width)
return false;
if (py < originY || py > originY + height)
return false;
return true;
}
function getRealIncrement() {
return Math.abs(endReal - startReal) / (canvasWidth / window.devicePixelRatio);
}
function getImaginaryIncrement() {
return Math.abs(endComplex - startComplex) / (canvasHeight / window.devicePixelRatio);
}