-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexandre Colucci
committed
Jan 8, 2019
0 parents
commit bb595df
Showing
51 changed files
with
8,181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The MIT License | ||
|
||
Copyright 2018 Corsair Memory, Inc | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
`AnalogClock` is a sample plugin demonstrating the [Stream Deck SDK](https://developer.elgato.com/documentation/stream-deck/). | ||
|
||
# Description | ||
|
||
`AnalogClock` is a plugin that displays a clock. You can change the style of the clock in its Property Inspector. | ||
|
||
Features: | ||
|
||
- code written in Javascript | ||
- cross-platform (macOS, Windows) | ||
- simple Property Inspector to change the style of the clock | ||
- localized | ||
|
||
|
||
# Installation | ||
|
||
In the Release folder, you can find the file `com.elgato.clock.streamDeckPlugin`. If you double-click this file on your machine, Stream Deck will install the plugin. | ||
|
||
|
||
# Source code | ||
|
||
The Sources folder contains the source code of the plugin. |
Binary file not shown.
Binary file added
BIN
+741 Bytes
Sources/com.elgato.analogclock.sdPlugin/action/images/actionimage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+656 Bytes
Sources/com.elgato.analogclock.sdPlugin/action/images/actionimage1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.15 KB
Sources/com.elgato.analogclock.sdPlugin/action/images/actionimage1@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+621 Bytes
Sources/com.elgato.analogclock.sdPlugin/action/images/actionimage2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.13 KB
Sources/com.elgato.analogclock.sdPlugin/action/images/actionimage2@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.17 KB
Sources/com.elgato.analogclock.sdPlugin/action/images/actionimage@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 changes: 123 additions & 0 deletions
123
Sources/com.elgato.analogclock.sdPlugin/action/js/clock.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/** | ||
* Simple Clock with adjustable colors (heavily inspired by kirupa: https://www.kirupa.com/html5/create_an_analog_clock_using_the_canvas.htm) | ||
* @param {canvas} cnv an existing canvas element in the DOM | ||
* API: | ||
* - drawClock() -> draws the clock - would normally called every second | ||
* - getImageData() -> returns base64-encode string of the canvas | ||
* - setColors(jsonObj) -> set colors of the clock's components as JSON | ||
* { | ||
* hour: "#efefef", | ||
* minute: "#cccccc", | ||
* second: "#ff9933", | ||
* stroke: "#cccccc", | ||
* background: "#000000" | ||
* } | ||
* - getColors() -> get current color values | ||
*/ | ||
|
||
function Clock(cnv) | ||
{ | ||
if (!cnv) return; | ||
var ctx = cnv.getContext('2d'); | ||
var clockRadius = cnv.width/2; | ||
var clockX = cnv.width / 2; | ||
var clockY = cnv.height / 2; | ||
var twoPi = 2 * Math.PI; | ||
var colors = {}; | ||
|
||
resetColors(); | ||
|
||
function resetColors() { | ||
setColors({ | ||
hour: "#efefef", | ||
minute: "#cccccc", | ||
second: "#ff9933", | ||
stroke: "#cccccc", | ||
background: "#000000" | ||
}); | ||
} | ||
|
||
function drawArm(progress, armThickness, armLength, armColor) | ||
{ | ||
var armRadians = (twoPi * progress) - (twoPi/4); | ||
var targetX = clockX + Math.cos(armRadians) * (armLength * clockRadius); | ||
var targetY = clockY + Math.sin(armRadians) * (armLength * clockRadius); | ||
|
||
ctx.lineWidth = armThickness; | ||
ctx.strokeStyle = armColor; | ||
|
||
ctx.beginPath(); | ||
ctx.moveTo(clockX, clockY); // Start at the center | ||
ctx.lineTo(targetX, targetY); // Draw a line outwards | ||
ctx.stroke(); | ||
} | ||
|
||
function drawClock() | ||
{ | ||
var now = new Date(); | ||
var h = now.getHours() % 12; | ||
var m = now.getMinutes(); | ||
var s = now.getSeconds(); | ||
|
||
ctx.fillStyle = colors.background; | ||
ctx.fillRect(0, 0, cnv.width, cnv.height); | ||
|
||
for (var i = 0; i < 12; i++) | ||
{ | ||
var innerDist = (i % 3) ? 0.8 : 0.775; | ||
var outerDist = 1; //(i % 3) ? 0.95 : 1.0; | ||
ctx.lineWidth = (i % 3) ? 4 : 5; | ||
ctx.strokeStyle = colors.stroke; | ||
|
||
var armRadians = (twoPi * (i/12)) - (twoPi/4); | ||
var x1 = clockX + Math.cos(armRadians) * (innerDist * clockRadius); | ||
var y1 = clockY + Math.sin(armRadians) * (innerDist * clockRadius); | ||
var x2 = clockX + Math.cos(armRadians) * (outerDist * clockRadius); | ||
var y2 = clockY + Math.sin(armRadians) * (outerDist * clockRadius); | ||
|
||
ctx.beginPath(); | ||
ctx.moveTo(x1, y1); // Start at the center | ||
ctx.lineTo(x2, y2); // Draw a line outwards | ||
ctx.stroke(); | ||
} | ||
|
||
|
||
var hProgress = (h/12) + (1/12)*(m/60) + (1/12)*(1/60)*(s/60); | ||
var mProgress = (m/60) + (1/60)*(s/60); | ||
var sProgress = (s/60); | ||
|
||
drawArm( hProgress, 6, 1/2, colors.hour); // Hour | ||
drawArm( hProgress, 6, -5/clockRadius, colors.hour); // Hour | ||
|
||
drawArm( mProgress, 4, 3/4, colors.minute); // Minute | ||
drawArm( mProgress, 4, -2/clockRadius, colors.minute); // Minute | ||
|
||
drawArm( sProgress, 2, 1, colors.second); // Second | ||
drawArm( sProgress, 2, -10/clockRadius, colors.second); // Second | ||
|
||
} | ||
|
||
function setColors(jsnColors) | ||
{ | ||
(typeof jsnColors === 'object') && Object.keys(jsnColors).map(c => colors[c] = jsnColors[c]); | ||
} | ||
|
||
function getColors() | ||
{ | ||
return this.colors; | ||
} | ||
|
||
function getImageData() | ||
{ | ||
return cnv.toDataURL(); | ||
} | ||
|
||
return { | ||
drawClock: drawClock, | ||
getImageData: getImageData, | ||
setColors: setColors, | ||
getColors: getColors, | ||
colors: colors, | ||
resetColors: resetColors | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
Sources/com.elgato.analogclock.sdPlugin/action/js/clockfaces.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
var clockfaces = [ | ||
{ | ||
name: 'Black', | ||
colors: { | ||
hour: '#609BB5', | ||
minute: '#609BB5', | ||
second: '#F75858', | ||
stroke: '#A4A4A4', | ||
background: '#000000' | ||
}, | ||
text: true | ||
}, | ||
{ | ||
name: 'Green', | ||
colors: { | ||
hour: '#66ffff', | ||
minute: '#33ffdd', | ||
second: '#ffff00', | ||
stroke: '#ff0000', | ||
background: '#00cc88' | ||
}, | ||
text: true | ||
}, | ||
{ | ||
name: 'Blueish', | ||
colors: { | ||
hour: '#efefef', | ||
minute: '#cccccc', | ||
second: '#ff9933', | ||
stroke: '#cccccc', | ||
background: '#141480' | ||
}, | ||
text: true | ||
}, | ||
{ | ||
name: 'White', | ||
colors: { | ||
hour: '#111111', | ||
minute: '#222222', | ||
second: '#ff0000', | ||
stroke: '#666666', | ||
background: '#ffffff' | ||
}, | ||
text: false | ||
}, | ||
{ | ||
name: 'Blue', | ||
colors: { | ||
hour: '#00aaff', | ||
minute: '#0033ff', | ||
second: '#aaaaff', | ||
stroke: '#ffff00', | ||
background: '#3366ee' | ||
}, | ||
text: true | ||
}, | ||
{ | ||
name: 'Red', | ||
colors: { | ||
hour: '#ffaa00', | ||
minute: '#ffcc00', | ||
second: '#ffaaaa', | ||
stroke: '#00ffff', | ||
background: '#de2200' | ||
}, | ||
text: false | ||
} | ||
// { | ||
// name: 'Demo', | ||
// colors: { | ||
// hour: '#111111', | ||
// minute: '#222222', | ||
// second: '#ff0000', | ||
// stroke: '#666666', | ||
// background: '#0066ff' | ||
// }, | ||
// text: true, | ||
// demo: true | ||
// } | ||
|
||
]; |
25 changes: 25 additions & 0 deletions
25
Sources/com.elgato.analogclock.sdPlugin/action/js/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title></title> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href=""> | ||
<style> | ||
.centerImageNoBorder { | ||
text-align: center; | ||
margin-bottom: 30px; | ||
margin-top: 30px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="centerImageNoBorder tutorial-example"> | ||
<canvas class="clock" id="elg_clock" width="144" height="144"> | ||
</canvas> | ||
</div> | ||
|
||
<script src="clock.js"></script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, | ||
pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, | ||
q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, | ||
dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, | ||
thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, | ||
footer, header, hgroup, menu, nav, output, ruby, section, summary, time, | ||
mark, audio, video { | ||
margin: 0; | ||
padding: 0; | ||
border: 0; | ||
font-size: 100%; | ||
font: inherit; | ||
vertical-align: baseline | ||
} | ||
|
||
article, aside, details, figcaption, figure, footer, header, hgroup, | ||
menu, nav, section { | ||
display: block | ||
} | ||
|
||
body { | ||
line-height: 1 | ||
} | ||
|
||
ol, ul { | ||
list-style: none | ||
} | ||
|
||
blockquote, q { | ||
quotes: none | ||
} | ||
|
||
blockquote:before, blockquote:after, q:before, q:after { | ||
content: ''; | ||
content: none | ||
} | ||
|
||
table { | ||
border-collapse: collapse; | ||
border-spacing: 0 | ||
} | ||
|
||
|
Oops, something went wrong.