Skip to content
Open
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
196 changes: 196 additions & 0 deletions nodes/signal/gui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="cache-control" content="max-age=0"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT"/>
<meta http-equiv="pragma" content="no-cache"/>
<title>IO</title>
<style>
body, html {
width: 220px;
height: 220px;
margin: 0;
padding: 0;
}

img {
display: block;
}
.white{
fill:#FFFFFF;
}
.test {
filter: opacity(100%);
}
.hide{
visibility: hidden;
}
.show{
visibility: visible;
}

</style>
</head>
<body>
<div style="width:160px; height:160px; overflow: hidden; position: absolute;top:30px;left:30px;">
<svg id= "motion" height="160" width="160">
<circle id = "2" cx="80" cy="80" r="74" stroke="#00ffff" stroke-width="8" fill="#222222" />
<path class="white" d="M111.8,110.9c-17.1,0-30.9-13.9-30.9-30.9s13.9-30.9,30.9-30.9s30.9,13.9,30.9,30.9S128.9,110.9,111.8,110.9z
M111.8,56.1c-13.2,0-23.9,10.7-23.9,23.9s10.7,23.9,23.9,23.9s23.9-10.7,23.9-23.9S125,56.1,111.8,56.1z"/>
<rect class="white" x="26.2" y="49.1" class="st2" width="54.4" height="7"/>
<rect class="white" x="43.8" y="77.5" class="st2" width="27.2" height="7"/>
<rect class="white" x="62.1" y="102.9" class="st2" width="17.9" height="7"/>
</svg>
</div>


<div style="width:160px; height:160px; overflow: hidden; position: absolute;top:30px;left:30px;">
<svg id = "motor" height="160" width="160">
<circle id = "2" cx="80" cy="80" r="74" stroke="#00ffff" stroke-width="8" fill="#222222" />
<path class="white" d="M115.2,80c0-2.3-0.2-4.7-0.7-6.9l14.6-10.7l-9.3-16.1l-16.5,7.3c-3.5-3.1-7.5-5.4-12-6.9l-1.9-17.9H70.7
l-1.9,17.9c-4.5,1.5-8.5,3.9-12,6.9l-16.5-7.3l-9.3,16.1l14.6,10.7c-0.4,2.2-0.7,4.5-0.7,6.9c0,2.4,0.2,4.7,0.7,6.9L30.9,97.6
l9.3,16.1l16.6-7.3c3.4,3,7.5,5.4,11.9,6.9l2,18h18.6l2-18c4.4-1.5,8.5-3.9,11.9-6.9l16.6,7.3l9.3-16.1l-14.6-10.7
C114.9,84.7,115.2,82.3,115.2,80z M80,106.6c-14.7,0-26.6-12-26.6-26.6c0-14.7,12-26.6,26.6-26.6c14.7,0,26.6,12,26.6,26.6
C106.6,94.6,94.7,106.6,80,106.6z"/>
</svg>
</div>

<div style="width:160px; height:160px; overflow: hidden; position: absolute;top:30px;left:30px;">
<svg id = "distance" height="160" width="160">
<circle id = "2" cx="80" cy="80" r="74" stroke="#00ffff" stroke-width="8" fill="#222222" />
<polygon class="white" points="129.1,57.2 129.1,102.8 122.1,102.8 122.1,86.5 98.3,108.6 93.5,103.5 115,83.5 37.9,83.5
37.9,102.8 30.9,102.8 30.9,57.2 37.9,57.2 37.9,76.5 115,76.5 93.5,56.5 98.3,51.4 122.1,73.5 122.1,57.2 "/>
</svg>
</div>

<div style="width:160px; height:160px; overflow: hidden; position: absolute;top:30px;left:30px;">
<svg id = "light" height="160" width="160">
<circle id = "2" cx="80" cy="80" r="74" stroke="#00ffff" stroke-width="8" fill="#222222" />
<path class="white" d="M80,110.9c-17.1,0-30.9-13.9-30.9-30.9S62.9,49.1,80,49.1s30.9,13.9,30.9,30.9S97.1,110.9,80,110.9z M80,56.1
c-13.2,0-23.9,10.7-23.9,23.9s10.7,23.9,23.9,23.9s23.9-10.7,23.9-23.9S93.2,56.1,80,56.1z"/>
<rect class="white" x="76.5" y="22" width="7" height="19.1"/>
<rect class="white" x="76.5" y="118.9" width="7" height="19.1"/>
<rect class="white" x="22" y="76.5" width="19.1" height="7"/>
<rect class="white" x="118.9" y="76.5" width="19.1" height="7"/>
<rect class="white" x="36.2" y="110.8" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -67.4181 65.8003)" width="19.1" height="7"/>
<rect class="white" x="104.7" y="42.2" transform="matrix(0.7071 -0.7071 0.7071 0.7071 1.144 94.1997)" width="19.1" height="7"/>
<rect class="white" x="110.8" y="104.7" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -47.3368 114.281)" width="7" height="19.1"/>
<rect class="white" x="42.2" y="36.2" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -18.9374 45.719)" width="7" height="19.1"/>
</svg>
</div>

<div style="width:160px; height:160px; overflow: hidden; position: absolute;top:30px;left:30px;">
<svg id = "button" height="160" width="160">
<circle id = "2" cx="80" cy="80" r="74" stroke="#00ffff" stroke-width="8" fill="#222222" />
<path class="white" d="M95.7,114.1H64.3c-10.2,0-18.5-8.3-18.5-18.5V64.3c0-10.2,8.3-18.5,18.5-18.5h31.3c10.2,0,18.5,8.3,18.5,18.5
v31.3C114.1,105.8,105.8,114.1,95.7,114.1z M64.3,52.9c-6.3,0-11.5,5.1-11.5,11.5v31.3c0,6.3,5.1,11.5,11.5,11.5h31.3
c6.3,0,11.5-5.1,11.5-11.5V64.3c0-6.3-5.1-11.5-11.5-11.5H64.3z"/>
</svg>
</div>

<div class="test" style="width:160px; height:160px; overflow: hidden; position: absolute;top:30px;left:30px;">
<svg id = "origin" height="160" width="160">
<circle id = "2" cx="80" cy="80" r="60" stroke="#00ffff" stroke-width="25" fill="#383838" />
</svg>
</div>




<div id="textNote" style="visibility: visible; position: absolute; overflow: hidden;top:190px;left:0px; width:220px; height:30px; text-align: center; font-size:1.6em; font-weight: bold; font-family: Helvetica, Arial, sans-serif;
color: #ffffff"></div>

<script>
var objects = {};

var elements = {
origin: document.getElementById('origin'),
motion: document.getElementById('motion'),
motor: document.getElementById('motor'),
distance: document.getElementById('distance'),
light: document.getElementById('light'),
button: document.getElementById('button')
};

var svg;
svg = activate("origin", elements);
var thisText = document.getElementById("textNote");

window.addEventListener("message", function (e) {

var msg = JSON.parse(e.data);

if (typeof msg.node !== "undefined" && typeof msg.frame !== "undefined" && typeof msg.object !== "undefined") {
parent.postMessage(
// {data :
JSON.stringify({
version: 170,
node: msg.node,
frame: msg.frame,
object: msg.object,
height: document.body.scrollHeight,
width: document.body.scrollWidth,
sendMatrix: false,
fullScreen: false
// })
})
// this needs to contain the final interface source
, "*");
if(msg.nodes[msg.node]) {

if (msg.nodes[msg.node].text) {

this.svg = activate(msg.nodes[msg.node].text, elements);

// console.log("from node: "+msg.nodes[msg.node].text);
document.getElementById("textNote").innerHTML = msg.nodes[msg.node].text;
} else {
this.svg = activate(msg.nodes[msg.node].name, elements);
// console.log("from node: "+msg.nodes[msg.node].name);
document.getElementById("textNote").innerHTML = msg.nodes[msg.node].name;
}
}
objects.node = msg.node;
objects.object = msg.object;

// thisText.innerHTML = objects[msg.object].nodes[msg.node].name;

}

if (typeof msg.uiActionFeedback !== "undefined") {

if (msg.uiActionFeedback === 0)
this.svg.ring.setAttribute("stroke", '#ff019f');
if (msg.uiActionFeedback === 1)
this.svg.ring.setAttribute("stroke", '#00ffff');
if (msg.uiActionFeedback === 2)
this.svg.ring.setAttribute("stroke", '#3af431');
if (msg.uiActionFeedback === 3)
this.svg.ring.setAttribute("stroke", '#f9f90a');
}
}.bind(this), false);


function activate (text, element) {
for (var key in element) {
if (text === key) {
element[key].style.display = "inline";
} else if (key in element) {
element[key].style.display = "none";
}
}

if (!(text in element)) {
element["origin"].style.display = "inline";
return {element: element["origin"], ring: element["origin"].getElementById('2')};
} else if (text in element){
return {element: element[text], ring: element[text].getElementById('2')};
}
}

</script>
</body>
</html>
147 changes: 147 additions & 0 deletions nodes/signal/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/**
* @preserve
*
* .,,,;;,'''..
* .'','... ..',,,.
* .,,,,,,',,',;;:;,. .,l,
* .,',. ... ,;, :l.
* ':;. .'.:do;;. .c ol;'.
* ';;' ;.; ', .dkl';, .c :; .'.',::,,'''.
* ',,;;;,. ; .,' .'''. .'. .d;''.''''.
* .oxddl;::,,. ', .'''. .... .'. ,:;..
* .'cOX0OOkdoc. .,'. .. ..... 'lc.
* .:;,,::co0XOko' ....''..'.'''''''.
* .dxk0KKdc:cdOXKl............. .. ..,c....
* .',lxOOxl:'':xkl,',......'.... ,'.
* .';:oo:... .
* .cd, ╔═╗┌─┐┬─┐┬ ┬┌─┐┬─┐ .
* .l; ╚═╗├┤ ├┬┘└┐┌┘├┤ ├┬┘ '
* 'l. ╚═╝└─┘┴└─ └┘ └─┘┴└─ '.
* .o. ...
* .''''','.;:''.........
* .' .l
* .:. l'
* .:. .l.
* .x: :k;,.
* cxlc; cdc,,;;.
* 'l :.. .c ,
* o.
* .,
*
* ╦ ╦┬ ┬┌┐ ┬─┐┬┌┬┐ ╔═╗┌┐ ┬┌─┐┌─┐┌┬┐┌─┐
* ╠═╣└┬┘├┴┐├┬┘│ ││ ║ ║├┴┐ │├┤ │ │ └─┐
* ╩ ╩ ┴ └─┘┴└─┴─┴┘ ╚═╝└─┘└┘└─┘└─┘ ┴ └─┘
*
* Created by Valentin on 10/22/14.
*
* Copyright (c) 2015 Valentin Heun
*
* All ascii characters above must be included in any redistribution.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

/**
* @desc prototype for a plugin. This prototype is called when a value should be changed.
* It defines how this value should be transformed before sending it to the destination.
* @param {object} objectID Origin object in which the related link is saved.
* @param {string} linkID the id of the link that is related to the call
* @param {object} inputData the data that needs to be processed
* @param {function} callback the function that is called for when the process is rendered.
* @note the callback has the same structure then the initial prototype, however inputData has changed to outputData
**/

/**
* Signal objects should have the following properties
* evalAtTime(t): Returns value between 0 and 1 with a period of 1cycle / 1t
*/
var sinWave = {
evalAtTime: (t) => {
return (Math.sin(t * 2 * Math.PI) + 1) / 2;
}
};
var squareWave = {
evalAtTime: (t) => {
return Math.sin(t * 2 * Math.PI) >= 0 ? 1 : 0;
}
};
var triangleWave = {
evalAtTime: (t) => {
return Math.abs((t % 1) * 2 - 1);
}
}
var sawtoothWave = {
evalAtTime: (t) => {
return t % 1;
}
}
var constantWave = {
evalAtTime: (t) => {
return 1;
}
}

var generalProperties = {
name: 'node',
privateData: {
currentT:0,
lastTime:Date.now(),
scale:0
},
publicData: {
wave:'constant',
speed:1
},
type: 'node'
};

var intervals = {};

var evalAtTime = (t, wave) => {
if (wave === 'sin') {
return sinWave.evalAtTime(t);
}
if (wave === 'square') {
return squareWave.evalAtTime(t);
}
if (wave === 'triangle') {
return triangleWave.evalAtTime(t);
}
if (wave === 'sawtooth') {
return sawtoothWave.evalAtTime(t);
}
if (wave === 'constant') {
return constantWave.evalAtTime(t);
}
return 0;
};

exports.properties = generalProperties;

exports.setup = function (object, frame, node, thisNode) {

};

exports.onRemove = function (object, frame, node, thisNode) {
if (intervals[`${object}${frame}${node}`]) {
clearInterval(intervals[`${object}${frame}${node}`]);
delete intervals[`${object}${frame}${node}`];
}
};

// written value should be a power value (alternatively, scale)
exports.render = function (object, frame, node, thisNode, callback) {
thisNode.privateData.scale = thisNode.data.value;
if (!intervals[`${object}${frame}${node}`]) {
intervals[`${object}${frame}${node}`] = setInterval(() => {
var elapsedTime = (Date.now() - thisNode.privateData.lastTime) * thisNode.publicData.speed;
thisNode.privateData.lastTime = Date.now();
thisNode.privateData.currentT += elapsedTime / 1000;
thisNode.processedData.value = thisNode.privateData.scale * evalAtTime(thisNode.privateData.currentT, thisNode.publicData.wave);
console.log('callback', object, frame, node, thisNode.uuid);
callback(object, frame, node, thisNode);
}, 1000/30);
}
};
3 changes: 3 additions & 0 deletions tools/.identity/constant-wave/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"enabled": true
}
3 changes: 3 additions & 0 deletions tools/.identity/saw-wave/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"enabled": true
}
3 changes: 3 additions & 0 deletions tools/.identity/sin-wave/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"enabled": true
}
3 changes: 3 additions & 0 deletions tools/.identity/square-wave/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"enabled": true
}
3 changes: 3 additions & 0 deletions tools/.identity/triangle-wave/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"enabled": true
}
Binary file added tools/constant-wave/icon.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading