-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.js
97 lines (82 loc) · 2.63 KB
/
form.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import {Constants} from "./defaultSettings.js";
export function addListeners(canvas) {
var form;
document.addEventListener("DOMContentLoaded", function () {
var body = document.body;
body.appendChild(canvas);
form = document.getElementById('settings');
form.addEventListener('submit', function (event) {
event.preventDefault();
});
var $pd = form.pd;
$pd.value = Constants.pd;
$pd.addEventListener('change', function () {
var value = +this.value;
if (value > 0) {
Constants.pd = value;
}
});
var $frameCount = form['frame-count'];
$frameCount.value = Constants.frameCount;
$frameCount.addEventListener('change', function () {
var value = +this.value;
if (value > 0) {
Constants.frameCount = value;
}
});
var $distanceX = form['distance-x'];
$distanceX.value = Constants.mostDistanceX;
$distanceX.addEventListener('change', function () {
var value = +this.value;
if (value > 0) {
Constants.mostDistanceX = value;
}
});
var $distanceY = form['distance-y'];
$distanceY.value = Constants.mostDistanceY;
$distanceY.addEventListener('change', function () {
var value = +this.value;
if (value >= 0) {
Constants.mostDistanceY = value;
}
});
var $scale = form['scale'];
$scale.value = Constants.scale;
$scale.addEventListener('change', function () {
var value = +this.value;
if (value >= 0) {
Constants.scale = value;
Constants.step = Constants.canvasWidth / Constants.scale;
}
});
var $horizonX = form['horizon-x'];
$horizonX.value = Constants.horizonX;
$horizonX.addEventListener('change', function () {
Constants.horizonX = +this.value;
});
var $horizonY = form['horizon-y'];
$horizonY.value = Constants.horizonY;
$horizonY.addEventListener('change', function () {
Constants.horizonY = +this.value;
});
canvas.addEventListener('click', function (event) {
Constants.horizonY = event.layerY;
Constants.horizonX = event.layerX;
var $horizonX = form['horizon-x'];
$horizonX.value = Constants.horizonX;
var $horizonY = form['horizon-y'];
$horizonY.value = Constants.horizonY;
Constants.DD_ = Constants.canvasHeight - Constants.horizonY;
});
//
// canvas.addEventListener('wheel', function (event) {
// var delta = event.deltaY > 0 ? 10 : -10;
// var cpd = Constants.pd + delta;
// if (cpd > 0) {
// Constants.pd = cpd;
// }
// var $pd = form.pd;
// $pd.value = Constants.pd;
// });
});
}