aboutsummaryrefslogtreecommitdiff
path: root/src/Actions.js
diff options
context:
space:
mode:
authorMartin Ashby <martin@martin-laptop.lan>2018-06-02 09:46:43 +0100
committerMartin Ashby <martin@martin-laptop.lan>2018-06-02 09:46:43 +0100
commit4a353d95f6d2dd8a9841bdae6f0721f5b014599e (patch)
treec0f039c5e7711d1163f641117b8f5548ab8d282f /src/Actions.js
parent76180c302197e83a257b975394768e5affa4054e (diff)
parent4a9b96e5cc8bf822bf3b2860b175f446cb45f98a (diff)
downloadunicornpaint-4a353d95f6d2dd8a9841bdae6f0721f5b014599e.tar.gz
unicornpaint-4a353d95f6d2dd8a9841bdae6f0721f5b014599e.tar.bz2
unicornpaint-4a353d95f6d2dd8a9841bdae6f0721f5b014599e.tar.xz
unicornpaint-4a353d95f6d2dd8a9841bdae6f0721f5b014599e.zip
Merge branch 'master' of github.com:MFAshby/unicornpaint
Diffstat (limited to 'src/Actions.js')
-rw-r--r--src/Actions.js26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/Actions.js b/src/Actions.js
index 1f4e7cf..9424c51 100644
--- a/src/Actions.js
+++ b/src/Actions.js
@@ -3,6 +3,8 @@ const SET_PIXEL = 'SET_PIXEL'
const CLEAR = 'CLEAR'
const SAVE = 'SAVE'
const LOAD = 'LOAD'
+const ADD_FRAME = "ADD_FRAME"
+const REMOVE_FRAME = "REMOVE_FRAME"
function sendAction(websocket, action) {
let actionStr = JSON.stringify(action)
@@ -23,14 +25,15 @@ function load(websocket, saveName) {
})
}
-function setPixel(websocket, x, y, r, g, b) {
+function setPixel(websocket, x, y, r, g, b, frame) {
sendAction(websocket, {
type: SET_PIXEL,
x: x,
y: y,
r: r,
g: g,
- b: b
+ b: b,
+ frame: frame
})
}
@@ -42,10 +45,27 @@ function noop(websocket) {
sendAction(websocket, { type: NO_OP })
}
+function addFrame(websocket, frame = 1, delay = 50) {
+ sendAction(websocket, {
+ type: ADD_FRAME,
+ frame: frame,
+ delay: delay
+ })
+}
+
+function removeFrame(websocket, frame = 1) {
+ sendAction(websocket, {
+ type: REMOVE_FRAME,
+ frame: frame
+ })
+}
+
export {
setPixel,
clear,
noop,
save,
- load
+ load,
+ addFrame,
+ removeFrame
} \ No newline at end of file