Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates dependencies; fixes start script; refactors to add push support. #1

Merged
merged 1 commit into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
target=6.0.8
disturl=https://atom.io/download/electron
runtime=electron
build_from_source=true
arch=x64
target_arch=x64
64 changes: 28 additions & 36 deletions main-window.html
Original file line number Diff line number Diff line change
@@ -1,57 +1,49 @@
<html>
<head>
<script>
// requires app.allowRendererProcessReuse = false
//const { initPush, sendFrame } = require("./node_modules/ableton-push-canvas-display/index.js");
</script>
</head>
<body>
<canvas id="myCanvas" width="960" height="160" style="border:1px solid #c3c3c3;">
<script>
var canvas = document.getElementById("myCanvas");
console.log( canvas );
var ctx = canvas.getContext("2d");
<script>
const pushDisplay = require("ableton-push-canvas-display");

let canvas = document.getElementById("myCanvas");
let ctx = canvas.getContext("2d");

function drawFrame(ctx, frameNum) {
ctx.strokeStyle = "#ff0"
ctx.fillStyle = "#000"
ctx.fillRect(0, 0, 960, 160)
ctx.fillStyle = "hsl(" + frameNum % 360 +",100%,50%)"
ctx.lineWidth = 4
ctx.fillRect((frameNum * 2) % 960, (frameNum * 2) % 160, 20, 20)
ctx.beginPath()
ctx.arc(100, 100, 50, 0, (frameNum / 20.0) % (2 * Math.PI))
ctx.lineTo(100, 100)
ctx.stroke()
ctx.strokeStyle = "#ff0";
ctx.fillStyle = "#000";
ctx.fillRect(0, 0, 960, 160);
ctx.fillStyle = "hsl(" + frameNum % 360 +",100%,50%)";
ctx.lineWidth = 4;
ctx.fillRect((frameNum * 2) % 960, (frameNum * 2) % 160, 20, 20);
ctx.beginPath();
ctx.arc(100, 100, 50, 0, (frameNum / 20.0) % (2 * Math.PI));
ctx.lineTo(100, 100);
ctx.stroke();

ctx.font = '800 20px "SF Pro Display"';
ctx.fillStyle = '#fff'
ctx.fillStyle = '#fff';
ctx.fillText("Awesome!", 50, 100);
}

let frameNum = 0;

/*
// from ableton-canvas example
function nextFrame() {
drawFrame(ctx, frameNum)
frameNum++
sendFrame(ctx, function(error) {
// we can ignore any error here, more or less
setTimeout(nextFrame,10) // Do not use nextTick here, as this will not allow USB callbacks to fire.
drawFrame(ctx, frameNum);
frameNum++;
pushDisplay.sendFrame(ctx, function(error) {
console.log("called sendFrame()");
requestAnimationFrame(nextFrame);
})
}
*/

function nextFrame(){
drawFrame(ctx, frameNum);
frameNum++;
// if push2 is present then send it there too
}

setInterval( nextFrame, 50 );


pushDisplay.initPush(function (err) {
if (!err) {
requestAnimationFrame(nextFrame);
} else {
console.log(err);
}
});
</script>
</body>
</html>
4 changes: 2 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
"use strict";

var fluid = require("infusion");
var fluid = require("infusion");
require("infusion-electron");
require("./gridquencer-app.js");

Expand Down
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{
"name": "gridquencer",
"version": "0.0.1",
"main": "main.js",
"description": "",
"author": "Adam Tindale",
"dependencies": {
"ableton-push-canvas-display": "^1.0.1",
"flocking": "^2.0.2",
"flocking-midi": "^1.0.0-dev.20200715T193144Z.94cf29b.gh-30",
"infusion-electron": "^0.7.0"
"ableton-push-canvas-display": "1.0.1",
"flocking": "3.0.0-dev.20201125T044807Z.e93e401",
"flocking-midi": "1.0.0-dev.20200715T193144Z.94cf29b.gh-30",
"infusion-electron": "0.7.0",
"electron": "6.0.8"
},
"scripts": {
"start": "electron .",
"rebuild": "electron-rebuild -f -w ableton-push-canvas-display"
},
"devDependencies": {
"electron-rebuild": "^2.3.4"
"start": "node_modules/.bin/electron ."
}
}