threequarks 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 978cd8fcbaceda6a1f785e1a518df94dce369798
4
+ data.tar.gz: 882f0c67fc0b9f1b06698f7a950516873d8a6087
5
+ SHA512:
6
+ metadata.gz: a048b09aec0f5ce14b8f88cd3267188b371431322ed04722888cfa0410a731b7ee8d7e4fcf42e65f8bfbb09a21f57bc304ab3114d2a8149b40b0b618c5cd909a
7
+ data.tar.gz: cca2bd37031df050ad505b036b784bd0ac3942c4d680ec7ccc5170054c9f00b07094cb4949be5bf69e499cdf3f52dd338d785134d85cbcc46ea7d04037b0d168
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in threequarks.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Julien Le Glaunec
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # Threequarks - Station Clock
2
+
3
+ This gem allows you to use the Canvas Station Clock http://www.3quarks.com/en/StationClock/
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'threequarks'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install threequarks
18
+
19
+ ## Usage
20
+ Add the following line to your application.js file
21
+
22
+ //= require threequarks
23
+
24
+ Display the UTC time
25
+ ```html
26
+ <div
27
+ class='clock'
28
+ offset='0'
29
+ body='<%= Threequarks::RoundBody %>'
30
+ dial='<%= Threequarks::SwissStrokeDial %>'
31
+ hourHand='<%= Threequarks::SwissHourHand %>'
32
+ minuteHand='<%= Threequarks::SwissMinuteHand %>'
33
+ secondHand='<%= Threequarks::SwissSecondHand %>'
34
+ boss='<%= Threequarks::NoBoss %>'
35
+ minuteHandBehavior='<%= Threequarks::BouncingMinuteHand %>'
36
+ secondHandBehavior='<%= Threequarks::OverhastySecondHand %>'
37
+ redrawInterval='1000'>
38
+ <canvas id='clockUTC' width='100' height='100'></canvas>
39
+ <p>UTC Time</p>
40
+ </div>
41
+ ```
42
+
43
+ Display the local time
44
+ ```html
45
+ <div
46
+ class='clock'
47
+ body='<%= Threequarks::RoundBody %>'
48
+ dial='<%= Threequarks::SwissStrokeDial %>'
49
+ hourHand='<%= Threequarks::SwissHourHand %>'
50
+ minuteHand='<%= Threequarks::SwissMinuteHand %>'
51
+ secondHand='<%= Threequarks::SwissSecondHand %>'
52
+ boss='<%= Threequarks::NoBoss %>'
53
+ minuteHandBehavior='<%= Threequarks::BouncingMinuteHand %>'
54
+ secondHandBehavior='<%= Threequarks::OverhastySecondHand %>'
55
+ redrawInterval='1000'>
56
+ <canvas id='clockLocal' width='100' height='100'></canvas>
57
+ <p>Local Time (without offset attribute)</p>
58
+ </div>
59
+ ```
60
+
61
+ List of different options
62
+
63
+ # clock body
64
+ NoBody = 0
65
+ SmallWhiteBody = 1
66
+ RoundBody = 2
67
+ RoundGreenBody = 3
68
+ SquareBody = 4
69
+
70
+ # stroke dial
71
+ NoDial = 0
72
+ GermanHourStrokeDial = 1
73
+ GermanStrokeDial = 2
74
+ AustriaStrokeDial = 3
75
+ SwissStrokeDial = 4
76
+
77
+ #clock hour hand
78
+ PointedHourHand = 1
79
+ BarHourHand = 2
80
+ SwissHourHand = 3
81
+
82
+ #clock minute hand
83
+ PointedMinuteHand = 1
84
+ BarMinuteHand = 2
85
+ SwissMinuteHand = 3
86
+
87
+ #clock second hand
88
+ NoSecondHand = 0
89
+ BarSecondHand = 1
90
+ HoleShapedSecondHand = 2
91
+ NewHoleShapedSecondHand = 3
92
+ SwissSecondHand = 4
93
+
94
+ # clock boss
95
+ NoBoss = 0
96
+ BlackBoss = 1
97
+ RedBoss = 2
98
+
99
+ # minute hand behavior
100
+ CreepingMinuteHand = 0
101
+ BouncingMinuteHand = 1
102
+ ElasticBouncingMinuteHand = 2
103
+
104
+ # second hand behavior
105
+ CreepingSecondHand = 0
106
+ BouncingSecondHand = 1
107
+ ElasticBouncingSecondHand = 2
108
+ OverhastySecondHand = 3
109
+
110
+ ## Contributing
111
+
112
+ 1. Fork it ( https://github.com/[my-github-username]/threequarks/fork )
113
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
114
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
115
+ 4. Push to the branch (`git push origin my-new-feature`)
116
+ 5. Create a new Pull Request
117
+
118
+ src: http://www.sitepoint.com/create-ruby-gem-jquery-plugin-basics/
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,415 @@
1
+ /*!
2
+ * station-clock.js
3
+ *
4
+ * Copyright (c) 2010 Ruediger Appel
5
+ * ludi at mac dot com
6
+ *
7
+ * Date: 2010-08-08
8
+ * Version: 1.0.0
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ *
22
+ * Known Issues:
23
+ *
24
+ * Shadows for some second hands is not on one layer
25
+ */
26
+
27
+ // clock body (Uhrgehäuse)
28
+ StationClock.NoBody = 0;
29
+ StationClock.SmallWhiteBody = 1;
30
+ StationClock.RoundBody = 2;
31
+ StationClock.RoundGreenBody = 3;
32
+ StationClock.SquareBody = 4;
33
+
34
+ // stroke dial (Zifferblatt)
35
+ StationClock.NoDial = 0;
36
+ StationClock.GermanHourStrokeDial = 1;
37
+ StationClock.GermanStrokeDial = 2;
38
+ StationClock.AustriaStrokeDial = 3;
39
+ StationClock.SwissStrokeDial = 4;
40
+
41
+ //clock hour hand (Stundenzeiger)
42
+ StationClock.PointedHourHand = 1;
43
+ StationClock.BarHourHand = 2;
44
+ StationClock.SwissHourHand = 3;
45
+
46
+ //clock minute hand (Minutenzeiger)
47
+ StationClock.PointedMinuteHand = 1;
48
+ StationClock.BarMinuteHand = 2;
49
+ StationClock.SwissMinuteHand = 3;
50
+
51
+ //clock second hand (Sekundenzeiger)
52
+ StationClock.NoSecondHand = 0;
53
+ StationClock.BarSecondHand = 1;
54
+ StationClock.HoleShapedSecondHand = 2;
55
+ StationClock.NewHoleShapedSecondHand = 3;
56
+ StationClock.SwissSecondHand = 4;
57
+
58
+ // clock boss (Zeigerabdeckung)
59
+ StationClock.NoBoss = 0;
60
+ StationClock.BlackBoss = 1;
61
+ StationClock.RedBoss = 2;
62
+
63
+ // minute hand behavoir
64
+ StationClock.CreepingMinuteHand = 0;
65
+ StationClock.BouncingMinuteHand = 1;
66
+ StationClock.ElasticBouncingMinuteHand = 2;
67
+
68
+ // second hand behavoir
69
+ StationClock.CreepingSecondHand = 0;
70
+ StationClock.BouncingSecondHand = 1;
71
+ StationClock.ElasticBouncingSecondHand = 2;
72
+ StationClock.OverhastySecondHand = 3;
73
+
74
+
75
+ function StationClock(clockId, offset) {
76
+ this.clockId = clockId;
77
+ this.offset = offset
78
+ this.radius = 0;
79
+
80
+ // clock body
81
+ this.body = StationClock.RoundBody;
82
+ this.bodyShadowColor = "rgba(0,0,0,0.5)";
83
+ this.bodyShadowOffsetX = 0.03;
84
+ this.bodyShadowOffsetY = 0.03;
85
+ this.bodyShadowBlur = 0.06;
86
+
87
+ // body dial
88
+ this.dial = StationClock.SwissStrokeDial;
89
+
90
+ // clock hands
91
+ this.hourHand = StationClock.SwissHourHand;
92
+ this.minuteHand = StationClock.SwissMinuteHand;
93
+ this.secondHand = StationClock.SwissSecondHand;
94
+ this.handShadowColor = "rgba(0,0,0,0.3)";
95
+ this.handShadowOffsetX = 0.03;
96
+ this.handShadowOffsetY = 0.03;
97
+ this.handShadowBlur = 0.04;
98
+
99
+ // clock boss
100
+ this.boss = StationClock.NoBoss;
101
+ this.bossShadowColor = "rgba(0,0,0,0.2)";
102
+ this.bossShadowOffsetX = 0.02;
103
+ this.bossShadowOffsetY = 0.02;
104
+ this.bossShadowBlur = 0.03;
105
+
106
+ // hand behavoir
107
+ this.minuteHandBehavoir = StationClock.CreepingMinuteHand;
108
+ this.secondHandBehavoir = StationClock.OverhastySecondHand;
109
+
110
+ // hand animation
111
+ this.minuteHandAnimationStep = 0;
112
+ this.secondHandAnimationStep = 0;
113
+ this.lastMinute = 0;
114
+ this.lastSecond = 0;
115
+ };
116
+
117
+ StationClock.prototype.draw = function() {
118
+ var clock = document.getElementById(this.clockId);
119
+ if (clock) {
120
+ var context = clock.getContext('2d');
121
+ if (context) {
122
+ this.radius = 0.75 * (Math.min(clock.width, clock.height) / 2);
123
+
124
+ // clear canvas and set new origin
125
+ context.clearRect(0, 0, clock.width, clock.height);
126
+ context.save();
127
+ context.translate(clock.width / 2, clock.height / 2);
128
+
129
+ // draw body
130
+ if (this.body != StationClock.NoStrokeBody) {
131
+ context.save();
132
+ switch (this.body) {
133
+ case StationClock.SmallWhiteBody:
134
+ this.fillCircle(context, "rgb(255,255,255)", 0, 0, 1);
135
+ break;
136
+ case StationClock.RoundBody:
137
+ this.fillCircle(context, "rgb(255,255,255)", 0, 0, 1.1);
138
+ context.save();
139
+ this.setShadow(context, this.bodyShadowColor, this.bodyShadowOffsetX, this.bodyShadowOffsetY, this.bodyShadowBlur);
140
+ this.strokeCircle(context, "rgb(0,0,0)", 0, 0, 1.1, 0.07);
141
+ context.restore()
142
+ break;
143
+ case StationClock.RoundGreenBody:
144
+ this.fillCircle(context, "rgb(235,236,212)", 0, 0, 1.1);
145
+ context.save();
146
+ this.setShadow(context, this.bodyShadowColor, this.bodyShadowOffsetX, this.bodyShadowOffsetY, this.bodyShadowBlur);
147
+ this.strokeCircle(context, "rgb(180,180,180)", 0, 0, 1.1, 0.2);
148
+ context.restore()
149
+ this.strokeCircle(context, "rgb(29,84,31)", 0, 0, 1.15, 0.1);
150
+ context.save();
151
+ this.setShadow(context, "rgba(235,236,212,100)", -0.02, -0.02, 0.09);
152
+ this.strokeCircle(context, 'rgb(76,128,110)', 0, 0, 1.1, 0.08);
153
+ context.restore()
154
+ break;
155
+ case StationClock.SquareBody:
156
+ context.save();
157
+ this.setShadow(context, this.bodyShadowColor, this.bodyShadowOffsetX, this.bodyShadowOffsetY, this.bodyShadowBlur);
158
+ this.fillSquare(context, 'rgb(237,235,226)', 0, 0, 2.4);
159
+ this.strokeSquare(context, 'rgb(38,106,186)', 0, 0, 2.32, 0.16);
160
+ context.restore()
161
+ context.save();
162
+ this.setShadow(context, this.bodyShadowColor, this.bodyShadowOffsetX, this.bodyShadowOffsetY, this.bodyShadowBlur);
163
+ this.strokeSquare(context, 'rgb(42,119,208)', 0, 0, 2.24, 0.08);
164
+ context.restore()
165
+ break;
166
+ }
167
+ context.restore();
168
+ }
169
+
170
+ // draw dial
171
+ for (var i = 0; i < 60; i++) {
172
+ context.save();
173
+ context.rotate(i * Math.PI / 30);
174
+ switch (this.dial) {
175
+ case StationClock.SwissStrokeDial:
176
+ if ((i % 5) == 0) {
177
+ this.strokeLine(context, 'rgb(0,0,0)', 0.0, -1.0, 0.0, -0.75, 0.07);
178
+ } else {
179
+ this.strokeLine(context, 'rgb(0,0,0)', 0.0, -1.0, 0.0, -0.92, 0.026);
180
+ }
181
+ break;
182
+ case StationClock.AustriaStrokeDial:
183
+ if ((i % 5) == 0) {
184
+ this.fillPolygon(context, 'rgb(0,0,0)', -0.04, -1.0, 0.04, -1.0, 0.03, -0.78, -0.03, -0.78);
185
+ } else {
186
+ this.strokeLine(context, 'rgb(0,0,0)', 0.0, -1.0, 0.0, -0.94, 0.02);
187
+ }
188
+ break;
189
+ case StationClock.GermanStrokeDial:
190
+ if ((i % 15) == 0) {
191
+ this.strokeLine(context, 'rgb(0,0,0)', 0.0, -1.0, 0.0, -0.70, 0.08);
192
+ } else if ((i % 5) == 0) {
193
+ this.strokeLine(context, 'rgb(0,0,0)', 0.0, -1.0, 0.0, -0.76, 0.08);
194
+ } else {
195
+ this.strokeLine(context, 'rgb(0,0,0)', 0.0, -1.0, 0.0, -0.92, 0.036);
196
+ }
197
+ break;
198
+ case StationClock.GermanHourStrokeDial:
199
+ if ((i % 15) == 0) {
200
+ this.strokeLine(context, 'rgb(0,0,0)', 0.0, -1.0, 0.0, -0.70, 0.10);
201
+ } else if ((i % 5) == 0) {
202
+ this.strokeLine(context, 'rgb(0,0,0)', 0.0, -1.0, 0.0, -0.74, 0.08);
203
+ }
204
+ break;
205
+ }
206
+ context.restore();
207
+ }
208
+
209
+ // get current time
210
+ var time = new Date();
211
+ var millis = time.getMilliseconds() / 1000.0;
212
+ var seconds = time.getSeconds();
213
+ // if this.offset == null, we show the local time
214
+ // if this.offset != null, we show the GMT+offset time
215
+ if (this.offset == null) {
216
+ var minutes = time.getMinutes()
217
+ } else {
218
+ var current_offset = time.getTimezoneOffset()
219
+ var minutes = time.getMinutes() + current_offset + (this.offset*60);
220
+ }
221
+ var hours = time.getHours();
222
+
223
+ // draw hour hand
224
+ context.save();
225
+ context.rotate(hours * Math.PI / 6 + minutes * Math.PI / 360);
226
+ this.setShadow(context, this.handShadowColor, this.handShadowOffsetX, this.handShadowOffsetY, this.handShadowBlur);
227
+ switch (this.hourHand) {
228
+ case StationClock.BarHourHand:
229
+ this.fillPolygon(context, 'rgb(0,0,0)', -0.05, -0.6, 0.05, -0.6, 0.05, 0.15, -0.05, 0.15);
230
+ break;
231
+ case StationClock.PointedHourHand:
232
+ this.fillPolygon(context, 'rgb(0,0,0)', 0.0, -0.6, 0.065, -0.53, 0.065, 0.19, -0.065, 0.19, -0.065, -0.53);
233
+ break;
234
+ case StationClock.SwissHourHand:
235
+ this.fillPolygon(context, 'rgb(0,0,0)', -0.05, -0.6, 0.05, -0.6, 0.065, 0.26, -0.065, 0.26);
236
+ break;
237
+ }
238
+ context.restore();
239
+
240
+ // draw minute hand
241
+ context.save();
242
+ switch (this.minuteHandBehavoir) {
243
+ case StationClock.CreepingMinuteHand:
244
+ context.rotate((minutes + seconds / 60) * Math.PI / 30);
245
+ break;
246
+ case StationClock.BouncingMinuteHand:
247
+ context.rotate(minutes * Math.PI / 30);
248
+ break;
249
+ case StationClock.ElasticBouncingMinuteHand:
250
+ if (this.lastMinute != minutes) {
251
+ this.minuteHandAnimationStep = 3;
252
+ this.lastMinute = minutes;
253
+ }
254
+ context.rotate((minutes + this.getAnimationOffset(this.minuteHandAnimationStep)) * Math.PI / 30);
255
+ this.minuteHandAnimationStep--;
256
+ break;
257
+ }
258
+ this.setShadow(context, this.handShadowColor, this.handShadowOffsetX, this.handShadowOffsetY, this.handShadowBlur);
259
+ switch (this.minuteHand) {
260
+ case StationClock.BarMinuteHand:
261
+ this.fillPolygon(context, 'rgb(0,0,0)', -0.05, -0.6, 0.05, -0.6, 0.05, 0.15, -0.05, 0.15);
262
+ break;
263
+ case StationClock.PointedMinuteHand:
264
+ this.fillPolygon(context, 'rgb(0,0,0)', 0.0, -0.93, 0.045, -0.885, 0.045, 0.23, -0.045, 0.23, -0.045, -0.885);
265
+ break;
266
+ case StationClock.SwissMinuteHand:
267
+ this.fillPolygon(context, 'rgb(0,0,0)', -0.035, -0.93, 0.035, -0.93, 0.05, 0.25, -0.05, 0.25);
268
+ break;
269
+ }
270
+ context.restore();
271
+
272
+ // draw second hand
273
+ context.save();
274
+ switch (this.secondHandBehavoir) {
275
+ case StationClock.OverhastySecondHand:
276
+ context.rotate(Math.min((seconds + millis) * (60.0 / 58.5), 60.0) * Math.PI / 30);
277
+ break;
278
+ case StationClock.CreepingSecondHand:
279
+ context.rotate((seconds + millis) * Math.PI / 30);
280
+ break;
281
+ case StationClock.BouncingSecondHand:
282
+ context.rotate(seconds * Math.PI / 30);
283
+ break;
284
+ case StationClock.ElasticBouncingSecondHand:
285
+ if (this.lastSecond != seconds) {
286
+ this.secondHandAnimationStep = 3;
287
+ this.lastSecond = seconds;
288
+ }
289
+ context.rotate((seconds + this.getAnimationOffset(this.secondHandAnimationStep)) * Math.PI / 30);
290
+ this.secondHandAnimationStep--;
291
+ break;
292
+ }
293
+ this.setShadow(context, this.handShadowColor, this.handShadowOffsetX, this.handShadowOffsetY, this.handShadowBlur);
294
+ switch (this.secondHand) {
295
+ case StationClock.BarSecondHand:
296
+ this.fillPolygon(context, 'rgb(200,0,0)', -0.006, -0.92, 0.006, -0.92, 0.028, 0.23, -0.028, 0.23);
297
+ break;
298
+ case StationClock.HoleShapedSecondHand:
299
+ this.fillPolygon(context, 'rgb(200,0,0)', 0.0, -0.9, 0.011, -0.889, 0.01875, -0.6, -0.01875, -0.6, -0.011, -0.889);
300
+ this.fillPolygon(context, 'rgb(200,0,0)', 0.02, -0.4, 0.025, 0.22, -0.025, 0.22, -0.02, -0.4);
301
+ this.strokeCircle(context, 'rgb(200,0,0)', 0, -0.5, 0.083, 0.066);
302
+ break;
303
+ case StationClock.NewHoleShapedSecondHand:
304
+ this.fillPolygon(context, 'rgb(200,0,0)', 0.0, -0.95, 0.015, -0.935, 0.0187, -0.65, -0.0187, -0.65, -0.015, -0.935);
305
+ this.fillPolygon(context, 'rgb(200,0,0)', 0.022, -0.45, 0.03, 0.27, -0.03, 0.27, -0.022, -0.45);
306
+ this.strokeCircle(context, 'rgb(200,0,0)', 0, -0.55, 0.085, 0.07);
307
+ break;
308
+ case StationClock.SwissSecondHand:
309
+ this.strokeLine(context, 'rgb(200,0,0)', 0.0, -0.6, 0.0, 0.35, 0.026);
310
+ this.fillCircle(context, 'rgb(200,0,0)', 0, -0.64, 0.1);
311
+ break;
312
+ }
313
+ context.restore();
314
+
315
+ // draw clock boss
316
+ if (this.boss != StationClock.NoBoss) {
317
+ context.save();
318
+ this.setShadow(context, this.bossShadowColor, this.bossShadowOffsetX, this.bossShadowOffsetY, this.bossShadowBlur);
319
+ switch (this.boss) {
320
+ case StationClock.BlackBoss:
321
+ this.fillCircle(context, 'rgb(0,0,0)', 0, 0, 0.1);
322
+ break;
323
+ case StationClock.RedBoss:
324
+ this.fillCircle(context, 'rgb(220,0,0)', 0, 0, 0.06);
325
+ break;
326
+ }
327
+ context.restore();
328
+ }
329
+
330
+ context.restore();
331
+ }
332
+ }
333
+ }
334
+
335
+ StationClock.prototype.getAnimationOffset = function(animationStep) {
336
+ switch (animationStep) {
337
+ case 3: return 0.2;
338
+ case 2: return -0.1;
339
+ case 1: return 0.05;
340
+ }
341
+ return 0;
342
+ }
343
+
344
+ StationClock.prototype.setShadow = function(context, color, offsetX, offsetY, blur) {
345
+ if (color) {
346
+ context.shadowColor = color;
347
+ context.shadowOffsetX = this.radius * offsetX;
348
+ context.shadowOffsetY = this.radius * offsetY;
349
+ context.shadowBlur = this.radius * blur;
350
+ }
351
+ }
352
+
353
+ StationClock.prototype.fillCircle = function(context, color, x, y, radius) {
354
+ if (color) {
355
+ context.beginPath();
356
+ context.fillStyle = color;
357
+ context.arc(x * this.radius, y * this.radius, radius * this.radius, 0, 2 * Math.PI, true);
358
+ context.fill();
359
+ }
360
+ }
361
+
362
+ StationClock.prototype.strokeCircle = function(context, color, x, y, radius, lineWidth) {
363
+ if (color) {
364
+ context.beginPath();
365
+ context.strokeStyle = color;
366
+ context.lineWidth = lineWidth * this.radius;
367
+ context.arc(x * this.radius, y * this.radius, radius * this.radius, 0, 2 * Math.PI, true);
368
+ context.stroke();
369
+ }
370
+ }
371
+
372
+ StationClock.prototype.fillSquare = function(context, color, x, y, size) {
373
+ if (color) {
374
+ context.fillStyle = color;
375
+ context.fillRect((x - size / 2) * this.radius, (y -size / 2) * this.radius, size * this.radius, size * this.radius);
376
+ }
377
+ }
378
+
379
+ StationClock.prototype.strokeSquare = function(context, color, x, y, size, lineWidth) {
380
+ if (color) {
381
+ context.strokeStyle = color;
382
+ context.lineWidth = lineWidth * this.radius;
383
+ context.strokeRect((x - size / 2) * this.radius, (y -size / 2) * this.radius, size * this.radius, size * this.radius);
384
+ }
385
+ }
386
+
387
+ StationClock.prototype.strokeLine = function(context, color, x1, y1, x2, y2, width) {
388
+ if (color) {
389
+ context.beginPath();
390
+ context.strokeStyle = color;
391
+ context.moveTo(x1 * this.radius, y1 * this.radius);
392
+ context.lineTo(x2 * this.radius, y2 * this.radius);
393
+ context.lineWidth = width * this.radius;
394
+ context.stroke();
395
+ }
396
+ }
397
+
398
+
399
+ StationClock.prototype.fillPolygon = function(context, color, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5) {
400
+ if (color) {
401
+ context.beginPath();
402
+ context.fillStyle = color;
403
+ context.moveTo(x1 * this.radius, y1 * this.radius);
404
+ context.lineTo(x2 * this.radius, y2 * this.radius);
405
+ context.lineTo(x3 * this.radius, y3 * this.radius);
406
+ context.lineTo(x4 * this.radius, y4 * this.radius);
407
+ if ((x5 != undefined) && (y5 != undefined)) {
408
+ context.lineTo(x5 * this.radius, y5 * this.radius);
409
+ }
410
+ context.lineTo(x1 * this.radius, y1 * this.radius);
411
+ context.fill();
412
+ }
413
+ }
414
+
415
+
@@ -0,0 +1 @@
1
+ //= require_tree .
@@ -0,0 +1,30 @@
1
+ $(function() {
2
+
3
+ $('.clock').each(function(i, el) {
4
+
5
+ var canvasId = $(el).children().first().attr('id');
6
+ var offset = $(el).attr('offset');
7
+ var body = $(el).attr('body') != null ? $(el).attr('body') : StationClock.RoundBody;
8
+ var dial = $(el).attr('dial') != null ? $(el).attr('dial') : StationClock.SwissStrokeDial;
9
+ var hourHand = $(el).attr('hourHand') != null ? $(el).attr('hourHand') : StationClock.SwissHourHand;
10
+ var minuteHand = $(el).attr('minuteHand') != null ? $(el).attr('minuteHand') : StationClock.SwissMinuteHand;
11
+ var secondHand = $(el).attr('secondHand') != null ? $(el).attr('secondHand') : StationClock.SwissSecondHand;
12
+ var boss = $(el).attr('boss') != null ? $(el).attr('boss') : StationClock.NoBoss;
13
+ var minuteHandBehavior = $(el).attr('minuteHandBehavior') != null ? $(el).attr('minuteHandBehavior') : StationClock.BouncingMinuteHand;
14
+ var secondHandBehavior = $(el).attr('secondHandBehavior') != null ? $(el).attr('secondHandBehavior') : StationClock.OverhastySecondHand;
15
+ var redrawInterval = $(el).attr('redrawInterval') != null ? $(el).attr('redrawInterval') : 50;
16
+
17
+ var clock = new StationClock(canvasId, offset);
18
+ clock.body = parseInt(body);
19
+ clock.dial = parseInt(dial);
20
+ clock.hourHand = parseInt(hourHand);
21
+ clock.minuteHand = parseInt(minuteHand);
22
+ clock.secondHand = parseInt(secondHand);
23
+ clock.boss = parseInt(boss);
24
+ clock.minuteHandBehavoir = parseInt(minuteHandBehavior);
25
+ clock.secondHandBehavoir = parseInt(secondHandBehavior);
26
+ window.setInterval(function() { clock.draw() }, parseInt(redrawInterval));
27
+
28
+ });
29
+
30
+ });
@@ -0,0 +1,53 @@
1
+ require "threequarks/version"
2
+ require "threequarks/engine"
3
+
4
+ module Threequarks
5
+
6
+ # clock body
7
+ NoBody = 0
8
+ SmallWhiteBody = 1
9
+ RoundBody = 2
10
+ RoundGreenBody = 3
11
+ SquareBody = 4
12
+
13
+ # stroke dial
14
+ NoDial = 0
15
+ GermanHourStrokeDial = 1
16
+ GermanStrokeDial = 2
17
+ AustriaStrokeDial = 3
18
+ SwissStrokeDial = 4
19
+
20
+ #clock hour hand
21
+ PointedHourHand = 1
22
+ BarHourHand = 2
23
+ SwissHourHand = 3
24
+
25
+ #clock minute hand
26
+ PointedMinuteHand = 1
27
+ BarMinuteHand = 2
28
+ SwissMinuteHand = 3
29
+
30
+ #clock second hand
31
+ NoSecondHand = 0
32
+ BarSecondHand = 1
33
+ HoleShapedSecondHand = 2
34
+ NewHoleShapedSecondHand = 3
35
+ SwissSecondHand = 4
36
+
37
+ # clock boss
38
+ NoBoss = 0
39
+ BlackBoss = 1
40
+ RedBoss = 2
41
+
42
+ # minute hand behavior
43
+ CreepingMinuteHand = 0
44
+ BouncingMinuteHand = 1
45
+ ElasticBouncingMinuteHand = 2
46
+
47
+ # second hand behavior
48
+ CreepingSecondHand = 0
49
+ BouncingSecondHand = 1
50
+ ElasticBouncingSecondHand = 2
51
+ OverhastySecondHand = 3
52
+
53
+ end
@@ -0,0 +1,4 @@
1
+ module Threequarks
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module Threequarks
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'threequarks/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "threequarks"
8
+ spec.version = Threequarks::VERSION
9
+ spec.authors = ["Julien Le Glaunec"]
10
+ spec.email = ["jleglaunec@gmail.com"]
11
+ spec.summary = %q{Display a station clock on a website via SVG}
12
+ spec.description = %q{source: http://www.3quarks.com/en/SVGClock/index.html}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: threequarks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Julien Le Glaunec
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: 'source: http://www.3quarks.com/en/SVGClock/index.html'
42
+ email:
43
+ - jleglaunec@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - app/assets/javascript/station-clock.js
54
+ - app/assets/javascript/threequarks.js
55
+ - app/assets/javascript/threequarks_initializer.js
56
+ - lib/threequarks.rb
57
+ - lib/threequarks/engine.rb
58
+ - lib/threequarks/version.rb
59
+ - threequarks.gemspec
60
+ homepage: ''
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.2.2
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Display a station clock on a website via SVG
84
+ test_files: []