-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
139 lines (119 loc) · 3.92 KB
/
functions.js
File metadata and controls
139 lines (119 loc) · 3.92 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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/**
* Created by duy on 3/8/16.
*/
$(function () {
var $sepDistSlider = $('#separation-distance-slider');
var $aliDistSlider = $('#alignment-distance-slider');
var $cohDistSlider = $('#cohesion-distance-slider');
var $sepDistInput = $('#separation-distance-value');
var $aliDistInput = $('#alignment-distance-value');
var $cohDistInput = $('#cohesion-distance-value');
var $sepWeightSlider = $('#separation-multiplier-slider');
var $aliWeightSlider = $('#alignment-multiplier-slider');
var $cohWeightSlider = $('#cohesion-multiplier-slider');
var $sepWeightInput = $('#separation-multiplier-value');
var $aliWeightInput = $('#alignment-multiplier-value');
var $cohWeightInput = $('#cohesion-multiplier-value');
// Seperation Distance Slider
$sepDistSlider
.rangeslider({
polyfill: true
})
.on('input', function () {
$sepDistInput[0].value = this.value;
SEPARATION_DISTANCE = this.value;
});
// Separation Distance input field
$sepDistInput.on('input', function () {
$sepDistSlider.val(this.value).change();
SEPARATION_DISTANCE = this.value;
});
// Alignment Distance Slider
$aliDistSlider
.rangeslider({
polyfill: true
})
.on('input', function () {
$aliDistInput[0].value = this.value;
ALIGNMENT_DISTANCE = this.value;
});
// Alignment Distance input field
$aliDistInput.on('input', function () {
$aliDistSlider.val(this.value).change();
ALIGNMENT_DISTANCE = this.value;
});
// Cohesion Distance Slider
$cohDistSlider
.rangeslider({
polyfill: true
})
.on('input', function () {
$cohDistInput[0].value = this.value;
COHESION_DISTANCE = this.value;
});
// Cohesion Distance input field
$cohDistInput.on('input', function () {
$cohDistSlider.val(this.value).change();
COHESION_DISTANCE = this.value;
});
// Separation Weight Slider
$sepWeightSlider
.rangeslider({
polyfill: true
})
.on('input', function () {
$sepWeightInput[0].value = this.value;
SEPARATION_MULTIPLIER = this.value;
});
// Separation Weight input field
$sepWeightInput.on('input', function () {
$sepWeightSlider.val(this.value).change();
SEPARATION_MULTIPLIER = this.value;
});
// Alignment Weight Slider
$aliWeightSlider
.rangeslider({
polyfill: true
})
.on('input', function () {
$aliWeightInput[0].value = this.value;
ALIGNMENT_MULTIPLIER = this.value;
});
// Alignment Weight input field
$aliWeightInput.on('input', function () {
$aliWeightSlider.val(this.value).change();
ALIGNMENT_MULTIPLIER = this.value;
});
// Cohesion Weight Slider
$cohWeightSlider
.rangeslider({
polyfill: true
})
.on('input', function () {
$cohWeightInput[0].value = this.value;
COHESION_MULTIPLIER = this.value;
});
// Cohesion Weight input field
$cohWeightInput.on('input', function () {
$cohWeightSlider.val(this.value).change();
COHESION_MULTIPLIER = this.value;
});
});
// Disable LOAD button until SAVE button is clicked on
$(function () {
var button = $("#save"),
submitButt = $("#load");
button.on("click", function (e) {
submitButt.prop("disabled", false); // NOT a toggle
});
});
var drawTextWithOutline = function (ctx, font, text, x, y, fillColor, outlineColor, outlineWidth) {
ctx.font = font;
ctx.strokeStyle = outlineColor;
ctx.lineWidth = outlineWidth ? outlineWidth : 5;
ctx.lineJoin = 'miter';
ctx.miterLimit = 5;
ctx.strokeText(text, x, y);
ctx.fillStyle = fillColor;
ctx.fillText(text, x, y);
};