aboutsummaryrefslogtreecommitdiff
path: root/src/Actions.js
diff options
context:
space:
mode:
authorMartin Ashby <martin@martin-laptop.lan>2018-06-01 19:33:11 +0100
committerMartin Ashby <martin@martin-laptop.lan>2018-06-01 19:33:11 +0100
commit4a9b96e5cc8bf822bf3b2860b175f446cb45f98a (patch)
treecff24b438803874ae6704703461b71147125d454 /src/Actions.js
parent5afaaf0432d4c9b6c2d840492eff184af41c961e (diff)
downloadunicornpaint-4a9b96e5cc8bf822bf3b2860b175f446cb45f98a.tar.gz
unicornpaint-4a9b96e5cc8bf822bf3b2860b175f446cb45f98a.tar.bz2
unicornpaint-4a9b96e5cc8bf822bf3b2860b175f446cb45f98a.tar.xz
unicornpaint-4a9b96e5cc8bf822bf3b2860b175f446cb45f98a.zip
Implemented animated GIFs
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