From 4a9b96e5cc8bf822bf3b2860b175f446cb45f98a Mon Sep 17 00:00:00 2001 From: Martin Ashby Date: Fri, 1 Jun 2018 19:33:11 +0100 Subject: Implemented animated GIFs --- src/Actions.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/Actions.js') 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 -- cgit v1.2.3-ZIG