mirror of
https://github.com/dyne/FreeJ.git
synced 2026-06-16 12:59:33 +02:00
script directory re-organisation
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
@@ -0,0 +1,78 @@
|
||||
// simple audio test reading out harmonics
|
||||
// make sure jack is running and have a look at the connections
|
||||
// also check the values (samplesize and samplerate) to match your conf
|
||||
// -jrml
|
||||
|
||||
H=400
|
||||
W=64
|
||||
M=4;
|
||||
|
||||
//H=600;
|
||||
//W=H/(H/80);
|
||||
|
||||
|
||||
set_resolution(W,H);
|
||||
|
||||
|
||||
|
||||
|
||||
audio = new AudioJack("alsaplayer", 2048, 44100);
|
||||
|
||||
//encoder = new VideoEncoder(10, 64000, 5, 24000);
|
||||
//encoder.add_audio(audio);
|
||||
//register_encoder(encoder);
|
||||
//encoder.start_filesave("prova.ogg");
|
||||
|
||||
geo = new GeometryLayer();
|
||||
geo.activate(true);
|
||||
geo.start();
|
||||
geo.set_fps();
|
||||
add_layer(geo);
|
||||
|
||||
kbd = new KeyboardController();
|
||||
register_controller(kbd);
|
||||
kbd.released_q = function() { quit(); }
|
||||
kbd.released_r = function() {
|
||||
if(reset("audio_test.js")) {
|
||||
rem_controller(this);
|
||||
echo("reset ok");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bang = new TriggerController();
|
||||
bang.frame = function() {
|
||||
|
||||
audio.fft();
|
||||
|
||||
geo.color(0,0,0,50);
|
||||
geo.rectangle_fill(0,0,W,H);
|
||||
|
||||
flash = 0;
|
||||
|
||||
for(c=0;c<16;c++) {
|
||||
|
||||
hc = audio.get_harmonic(c);
|
||||
|
||||
if(hc>H) hc = H-1; // boundary
|
||||
|
||||
if(hc>(H/2)) flash=hc; // flash
|
||||
|
||||
geo.color( 0xff, 0xff, 0xff, 0xff );
|
||||
|
||||
geo.vline( c*M, H, H-( hc ));
|
||||
geo.vline( (c*M)+1, H, H-( hc ));
|
||||
|
||||
geo.vline( (c*M)+2, 0, hc);
|
||||
geo.vline( (c*M)+3, 0, hc);
|
||||
}
|
||||
|
||||
if(flash >0) {
|
||||
geo.color(0xff,0xff,0xff, 200);
|
||||
geo.ellipse_fill(W/2, H/2, (W/2)-10, hc/2);
|
||||
}
|
||||
|
||||
}
|
||||
register_controller(bang);
|
||||
|
||||
gc();
|
||||
@@ -0,0 +1,158 @@
|
||||
// crossover J & J
|
||||
// from cellsbutton02 yogyakarta performance
|
||||
// -jrml aug2008
|
||||
|
||||
W=640
|
||||
H=480
|
||||
|
||||
set_resolution(W,H);
|
||||
|
||||
audio = new AudioJack("alsa_pcm:capture_1", 2048, 44100);
|
||||
|
||||
|
||||
geo = new GeometryLayer();
|
||||
geo.activate(true);
|
||||
geo.start();
|
||||
geo.set_fps();
|
||||
add_layer(geo);
|
||||
|
||||
shift=0;
|
||||
draw=0;
|
||||
mode=0;
|
||||
|
||||
kbd = new KeyboardController();
|
||||
register_controller(kbd);
|
||||
|
||||
linedraw = function(x0,y0,x1,y1) {
|
||||
if(draw==0) geo.line(x0,y0,x1,y1);
|
||||
else if(draw==1) geo.aaline(x0,y0,x1,y1);
|
||||
}
|
||||
|
||||
|
||||
kbd.pressed_p = function() { shift++; }
|
||||
kbd.pressed_o = function() { shift--; }
|
||||
|
||||
kbd.released_a = function() { draw=1; };
|
||||
kbd.released_s = function() { draw=0; };
|
||||
|
||||
kbd.released_b = function() {
|
||||
if(mode==1) mode=0;
|
||||
else mode=1;
|
||||
};
|
||||
|
||||
kbd.released_q = function() { quit(); }
|
||||
kbd.released_r = function() {
|
||||
if(reset("crossover.js")) {
|
||||
rem_controller(this);
|
||||
echo("reset ok");
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
center_x = W/2;
|
||||
center_y = H/2;
|
||||
|
||||
crossfat = 10;
|
||||
|
||||
smallcross = function(x,y,len) {
|
||||
linedraw(x-len,y-len,x+len,y+len);
|
||||
linedraw(x-len,y+len,x+len,y-len);
|
||||
};
|
||||
|
||||
wave = new Array();
|
||||
|
||||
bang = new TriggerController();
|
||||
bang.frame = function() {
|
||||
|
||||
audio.fft();
|
||||
|
||||
geo.color(0,0,0,50);
|
||||
geo.rectangle_fill(0,0,W,H);
|
||||
|
||||
geo.color( 0xff, 0xff, 0xff, 0xff );
|
||||
|
||||
if(mode==1) { // small crosses
|
||||
|
||||
hc1 = audio.get_harmonic(2);
|
||||
hc2 = audio.get_harmonic(12);
|
||||
|
||||
crossfat = hc2*16;
|
||||
if(crossfat<16) crossfat=16;
|
||||
|
||||
crosswide = hc1*8;
|
||||
|
||||
wave.unshift(crosswide);
|
||||
if(wave.length < W/16) return;
|
||||
/*
|
||||
echo("crossfat = " + crossfat);
|
||||
echo("diagonals = " + diago1 + " x " + diago2);
|
||||
*/
|
||||
for(xx=0; xx<W/crossfat; xx++) {
|
||||
|
||||
for(yy=0; yy<H/crossfat; yy++) {
|
||||
|
||||
smallcross(center_x+(xx*crossfat),
|
||||
center_y+(yy*crossfat),
|
||||
wave[xx]);
|
||||
|
||||
smallcross(center_x-(xx*crossfat),
|
||||
center_y-(yy*crossfat),
|
||||
wave[xx]);
|
||||
|
||||
smallcross(center_x+(xx*crossfat),
|
||||
center_y-(yy*crossfat),
|
||||
wave[xx]);
|
||||
|
||||
smallcross(center_x-(xx*crossfat),
|
||||
center_y+(yy*crossfat),
|
||||
wave[xx]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
wave.pop();
|
||||
|
||||
} else { // wired cross
|
||||
|
||||
for(c=0;c<16;c++) {
|
||||
|
||||
hc = (audio.get_harmonic(c) * 8) + shift*2;
|
||||
|
||||
p = c*8;
|
||||
|
||||
xphc = center_x+hc;
|
||||
xmhc = center_x-hc;
|
||||
xpp = center_x+p;
|
||||
xmp = center_x-p;
|
||||
|
||||
yphc = center_y+hc;
|
||||
ymhc = center_y-hc;
|
||||
ypp = center_y+p;
|
||||
ymp = center_y-p;
|
||||
|
||||
linedraw(xpp, ypp, xphc, yphc);
|
||||
linedraw(xpp, ypp, xmhc, ymhc);
|
||||
linedraw(xpp, ypp, xphc, ymhc);
|
||||
linedraw(xpp, ypp, xmhc, yphc);
|
||||
|
||||
linedraw(xmp, ymp, xphc, yphc);
|
||||
linedraw(xmp, ymp, xmhc, ymhc);
|
||||
linedraw(xmp, ymp, xphc, ymhc);
|
||||
linedraw(xmp, ymp, xmhc, yphc);
|
||||
|
||||
linedraw(xmp, ypp, xphc, yphc);
|
||||
linedraw(xmp, ypp, xmhc, ymhc);
|
||||
linedraw(xmp, ypp, xphc, ymhc);
|
||||
linedraw(xmp, ypp, xmhc, yphc);
|
||||
|
||||
linedraw(xpp, ymp, xphc, yphc);
|
||||
linedraw(xpp, ymp, xmhc, ymhc);
|
||||
linedraw(xpp, ymp, xphc, ymhc);
|
||||
linedraw(xpp, ymp, xmhc, yphc);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
register_controller(bang);
|
||||
|
||||
gc();
|
||||
@@ -0,0 +1,259 @@
|
||||
/* FreeJ example scripts
|
||||
* (c) Copyright 2005 Christoph Rudorff aka MrGoil <goil@dyne.org>
|
||||
*
|
||||
* This source code is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Public License as published
|
||||
* by the Free Software Foundation; either version 3 of the License,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* This source code is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* Please refer to the GNU Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Public License along with
|
||||
* this source code; if not, write to:
|
||||
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
Javascript Version of the xscreensaver Cynosure
|
||||
*/
|
||||
|
||||
curColor = 0;
|
||||
curBase = curColor;
|
||||
shadowWidth = 2 ; //get_integer_resource ("shadowWidth", "Integer");
|
||||
elevation = 10; //get_integer_resource ("elevation", "Integer");
|
||||
sway = 30; //get_integer_resource ("sway", "Integer");
|
||||
tweak = 20; //get_integer_resource ("tweak", "Integer");
|
||||
gridSize = 10; //get_integer_resource ("gridSize", "Integer");
|
||||
timeLeft = 0;
|
||||
ncolors = 8; //get_integer_resource ("colors", "Colors");
|
||||
iterations = 100; //get_integer_resource ("iterations", "Iterations");
|
||||
MINCELLSIZE = 64;
|
||||
MINRECTSIZE = 24;
|
||||
THRESHOLD = 100;
|
||||
|
||||
i = 0;
|
||||
|
||||
colors = new Array(0xa03000ff, 0x006000ff, 0x336000ff, 0x00ff00ff, 0xc20000ff, 0x0000c0ff, 0xc0c0c0ff, 0x30f0f0ff, 0x00ff90ff);
|
||||
width=200; height=600;
|
||||
width=1024; height=768;
|
||||
width=800; height=800;
|
||||
width=400; height=300;
|
||||
|
||||
geo = new GeometryLayer();
|
||||
add_layer(geo);
|
||||
|
||||
trigger = new TriggerController();
|
||||
register_controller(trigger);
|
||||
trigger.frame = function() { Draw(); };
|
||||
|
||||
kbd = new KeyboardController();
|
||||
register_controller(kbd);
|
||||
kbd.released_q = function() { quit(); }
|
||||
kbd.released_x = function() { Draw(); }
|
||||
|
||||
kbd.released_p = function() {
|
||||
echo("ok, I shot myself now");
|
||||
try{rem_controller(trigger);}catch(e){echo("tg nope: "+e);}
|
||||
try{rem_layer(geo);}catch(e){echo("la nope: "+e);}
|
||||
try{rem_controller(mc);}catch(e){echo("mc nope: "+e);}
|
||||
try{rem_controller(kbd);}catch(e){echo("kb nope: "+e);}
|
||||
delete geo;
|
||||
delete mc;
|
||||
delete kbd;
|
||||
delete trigger;
|
||||
gc(); // kbd-js not cleared within this call!
|
||||
echo("Bullet arrived.");
|
||||
}
|
||||
|
||||
|
||||
mc = new MidiController(); // ('descr')
|
||||
register_controller(mc);
|
||||
ret = mc.connect_from(0, 20, 0);
|
||||
|
||||
mc.event_ctrl = function (ch, func, value) {
|
||||
switch (ch) {
|
||||
case 0:
|
||||
switch (func) {
|
||||
case 2:
|
||||
shadowWidth = value;
|
||||
break;
|
||||
case 3:
|
||||
elevation = value;
|
||||
break;
|
||||
case 4:
|
||||
sway = value;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
switch (func) {
|
||||
case 2:
|
||||
tweak = value+1;
|
||||
break;
|
||||
case 3:
|
||||
gridSize = value/4 +1;
|
||||
break;
|
||||
case 4:
|
||||
iterations = value*2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (func) {
|
||||
case 2:
|
||||
MINRECTSIZE = value;
|
||||
break;
|
||||
case 3:
|
||||
MINCELLSIZE = value;
|
||||
break;
|
||||
case 4:
|
||||
THRESHOLD = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function integer(i) {
|
||||
if (i>0)
|
||||
return Math.floor(i)
|
||||
else
|
||||
return Math.ceil(i)
|
||||
}
|
||||
|
||||
function Draw() {
|
||||
for (j=0; j<10; j++) {
|
||||
if ((iterations > 0) && (++i >= iterations)) {
|
||||
i = 0; // clearScreen
|
||||
geo.rectangle_fill(0,0,width,height,0x000000FF);
|
||||
}
|
||||
paint();
|
||||
}
|
||||
}
|
||||
|
||||
function paint() {
|
||||
var cellsWide, cellsHigh, cellWidth, cellHeight;
|
||||
//debug ("paint");
|
||||
/* How many cells wide the grid is (equal to gridSize +/- (gridSize / 2))
|
||||
*/
|
||||
cellsWide = c_tweak(gridSize, gridSize / 2);
|
||||
/* How many cells high the grid is (equal to gridSize +/- (gridSize / 2))
|
||||
*/
|
||||
cellsHigh = c_tweak(gridSize, gridSize / 2);
|
||||
/* How wide each cell in the grid is */
|
||||
cellWidth = width / cellsWide;
|
||||
/* How tall each cell in the grid is */
|
||||
cellHeight = height / cellsHigh;
|
||||
|
||||
/* Ensure that each cell is above a certain minimum size */
|
||||
|
||||
if (cellWidth < MINCELLSIZE) {
|
||||
cellWidth = MINCELLSIZE;
|
||||
cellsWide = width / cellWidth;
|
||||
}
|
||||
|
||||
if (cellHeight < MINCELLSIZE) {
|
||||
cellHeight = MINCELLSIZE;
|
||||
cellsHigh = width / cellWidth;
|
||||
}
|
||||
/* fill the grid with randomly-generated cells */
|
||||
for(var i = 0; i < cellsHigh; i++) {
|
||||
/* Each row is a different color, randomly generated (but constrained) */
|
||||
var c = genNewColor();
|
||||
var fg_gc = colors[c];
|
||||
//debug("pick color #" + c + " = " + fg_gc);
|
||||
//XSetForeground(dpy, fg_gc, colors[c].pixel);
|
||||
|
||||
for(var j = 0; j < cellsWide; j++) {
|
||||
var curWidth, curHeight, curX, curY;
|
||||
|
||||
/* Generate a random height for a rectangle and make sure that */
|
||||
/* it's above a certain minimum size */
|
||||
curHeight = random() % (cellHeight - shadowWidth);
|
||||
if (curHeight < MINRECTSIZE)
|
||||
curHeight = MINRECTSIZE;
|
||||
/* Generate a random width for a rectangle and make sure that
|
||||
it's above a certain minimum size */
|
||||
curWidth = random() % (cellWidth - shadowWidth);
|
||||
if (curWidth < MINRECTSIZE)
|
||||
curWidth = MINRECTSIZE;
|
||||
/* Figure out a random place to locate the rectangle within the
|
||||
cell */
|
||||
curY = (i * cellHeight) + (random() % ((cellHeight - curHeight) -
|
||||
shadowWidth));
|
||||
curX = (j * cellWidth) + (random() % ((cellWidth - curWidth) -
|
||||
shadowWidth));
|
||||
|
||||
/* Draw the shadow */
|
||||
if (elevation > 0)
|
||||
geo.rectangle_fill(curX + elevation, curY + elevation,
|
||||
curX + elevation + curWidth,
|
||||
curY + elevation + curHeight,
|
||||
0x00000060);
|
||||
|
||||
/* Draw the edge */
|
||||
if (shadowWidth > 0)
|
||||
geo.rectangle_fill(curX + shadowWidth, curY + shadowWidth,
|
||||
curX + shadowWidth + curWidth,
|
||||
curY + shadowWidth + curHeight,
|
||||
0x000000ff);
|
||||
|
||||
geo.rectangle_fill(curX, curY, curX+curWidth, curY+curHeight, fg_gc)
|
||||
|
||||
/* Draw a 1-pixel black border around the rectangle */
|
||||
geo.rectangle(curX, curY, curX+curWidth, curY+curHeight, 0x00000000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function random() {
|
||||
return integer(Math.random() * 0xffffffff);
|
||||
}
|
||||
|
||||
|
||||
function genConstrainedColor(base, tweak) {
|
||||
var i = integer(1 + (random() % tweak));
|
||||
if (random() & 1)
|
||||
i = -i;
|
||||
i = (base + i) % ncolors;
|
||||
while (i < 0)
|
||||
i += ncolors;
|
||||
return integer(i);
|
||||
}
|
||||
|
||||
function c_tweak(base, tweak) {
|
||||
var ranTweak = integer(random() % (2 * tweak));
|
||||
var n = (base + (ranTweak - tweak));
|
||||
if (n < 0) n = -n;
|
||||
return integer(n < 255 ? n : 255);
|
||||
}
|
||||
|
||||
function genNewColor() {
|
||||
/* These lines handle "sway", or the gradual random changing of */
|
||||
/* colors. After genNewColor() has been called a given number of */
|
||||
/* times (specified by a random permutation of the tweak variable), */
|
||||
/* take whatever color has been most recently randomly generated and */
|
||||
/* make it the new base color. */
|
||||
if (timeLeft == 0) {
|
||||
timeLeft = c_tweak(sway, sway / 3);
|
||||
curColor = curBase;
|
||||
} else {
|
||||
timeLeft--;
|
||||
}
|
||||
|
||||
/* If a randomly generated number is less than the threshold value,
|
||||
produce a "sport" color value that is completely unrelated to the
|
||||
current palette. */
|
||||
if (0 == (random() % THRESHOLD)) {
|
||||
return integer(random() % ncolors);
|
||||
} else {
|
||||
curBase = genConstrainedColor(curColor, tweak);
|
||||
return integer(curBase);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
echo("cyno script end");
|
||||
@@ -0,0 +1,251 @@
|
||||
/* FreeJ example scripts
|
||||
* (c) Copyright 2005 Christoph Rudorff aka MrGoil <goil@dyne.org>
|
||||
*
|
||||
* This source code is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Public License as published
|
||||
* by the Free Software Foundation; either version 3 of the License,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* This source code is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* Please refer to the GNU Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Public License along with
|
||||
* this source code; if not, write to:
|
||||
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
Javascript Version of the xscreensaver Cynosure
|
||||
*/
|
||||
|
||||
|
||||
// global values
|
||||
i = 0; // iterations
|
||||
timeLeft = 0;
|
||||
curColor = 0;
|
||||
curBase = curColor;
|
||||
|
||||
// find my library
|
||||
|
||||
include("param.js");
|
||||
|
||||
// define interactive parameters
|
||||
param = new Array();
|
||||
// Param(obj, name, in_min, in_max, out_min, out_max, out_start_value)
|
||||
param[0] = new Param(this, "shadowWidth", 0, 125, 0, 128, 2);
|
||||
param[1] = new Param(this, "elevation", 0, 125, 0, 64, 10);
|
||||
param[2] = new Param(this, "sway", 0, 125, 0, 127, 30);
|
||||
param[3] = new Param(this, "tweak", 0, 125, 1, 32, 20);
|
||||
param[4] = new Param(this, "gridSize", 0, 125, 2, 127, 30);
|
||||
param[4].frac=2;
|
||||
param[5] = new Param(this, "iterations", 0, 125, 0, 125, 100);
|
||||
param[6] = new Param(this, "MINCELLSIZE", 0, 125,16, 400, 64); // width
|
||||
param[7] = new Param(this, "MINRECTSIZE", 0, 125, 0, 128, 24);
|
||||
param[8] = new Param(this, "THRESHOLD", 0, 125, 1, 128, 20);
|
||||
|
||||
// assign paras to midi[channel][function]
|
||||
midi_action = new Array(); // channel
|
||||
midi_action[0] = new Array(); // function
|
||||
midi_action[0][2] = param[0];
|
||||
midi_action[0][3] = param[1];
|
||||
midi_action[0][4] = param[2];
|
||||
midi_action[1] = new Array();
|
||||
midi_action[1][2] = param[3];
|
||||
midi_action[1][3] = param[4];
|
||||
midi_action[1][4] = param[5];
|
||||
midi_action[2] = new Array();
|
||||
midi_action[2][2] = param[6];
|
||||
midi_action[2][3] = param[7];
|
||||
midi_action[2][4] = param[8];
|
||||
|
||||
// on screen display
|
||||
osd = new TextLayer();
|
||||
osd.print(" "); // BUG!
|
||||
add_layer(osd);
|
||||
osd.up();
|
||||
|
||||
colors = new Array(0xa03000ff, 0x006000ff, 0x336000ff, 0x00ff00ff, 0xc20000ff, 0x0000c0ff, 0xc0c0c0ff, 0x30f0f0ff, 0x00ff90ff);
|
||||
ncolors = colors.length - 1;
|
||||
//width=1024; height=768;
|
||||
//width=400; height=300;
|
||||
width=640; height=480;
|
||||
width=400; height=300;
|
||||
|
||||
geo = new GeometryLayer(width, height);
|
||||
//geo = new GeometryLayer(100,100);
|
||||
add_layer(geo);
|
||||
|
||||
trigger = new TriggerController();
|
||||
register_controller(trigger);
|
||||
trigger.frame = function() { Draw(); };
|
||||
|
||||
kbd = new KeyboardController();
|
||||
register_controller(kbd);
|
||||
kbd.released_q = function() { quit(); }
|
||||
kbd.released_x = function() { Draw(); }
|
||||
|
||||
parm_sel = 0;
|
||||
kbd.pressed_up = function() {
|
||||
parm_sel = Math.min(param.length-1, parm_sel+1);
|
||||
param[parm_sel].print(osd);
|
||||
}
|
||||
kbd.pressed_down = function() {
|
||||
parm_sel = Math.max(0, parm_sel-1);
|
||||
param[parm_sel].print(osd);
|
||||
}
|
||||
kbd.pressed_left = function() {
|
||||
param[parm_sel].step(-1);
|
||||
param[parm_sel].print(osd);
|
||||
}
|
||||
kbd.pressed_right = function() {
|
||||
param[parm_sel].step(1);
|
||||
param[parm_sel].print(osd);
|
||||
}
|
||||
|
||||
|
||||
mc = new MidiController();
|
||||
register_controller(mc);
|
||||
ret = mc.connect_from(0, 20, 0);
|
||||
|
||||
mc.event_ctrl = function (ch, func, value) {
|
||||
var a = midi_action[ch];
|
||||
if (a)
|
||||
a = a[func];
|
||||
if (a) {
|
||||
a.setValue(value);
|
||||
a.print(osd);
|
||||
}
|
||||
}
|
||||
|
||||
function Draw() {
|
||||
for (j=0; j<10; j++) {
|
||||
if ((iterations > 0) && (++i >= iterations)) {
|
||||
i = 0; // clearScreen
|
||||
geo.rectangle_fill(0,0,width,height,0x000000FF);
|
||||
}
|
||||
paint();
|
||||
}
|
||||
}
|
||||
|
||||
function paint() {
|
||||
var cellsWide, cellsHigh, cellWidth, cellHeight;
|
||||
//debug ("paint");
|
||||
/* How many cells wide the grid is (equal to gridSize +/- (gridSize / 2))
|
||||
*/
|
||||
cellsWide = c_tweak(gridSize, gridSize / 2);
|
||||
/* How many cells high the grid is (equal to gridSize +/- (gridSize / 2))
|
||||
*/
|
||||
cellsHigh = c_tweak(gridSize, gridSize / 2);
|
||||
/* How wide each cell in the grid is */
|
||||
cellWidth = width / cellsWide;
|
||||
/* How tall each cell in the grid is */
|
||||
cellHeight = height / cellsHigh;
|
||||
|
||||
/* Ensure that each cell is above a certain minimum size */
|
||||
|
||||
if (cellWidth < MINCELLSIZE) {
|
||||
cellWidth = MINCELLSIZE;
|
||||
cellsWide = width / cellWidth;
|
||||
}
|
||||
|
||||
if (cellHeight < MINCELLSIZE) {
|
||||
cellHeight = MINCELLSIZE;
|
||||
cellsHigh = height / cellHeight;
|
||||
}
|
||||
/* fill the grid with randomly-generated cells */
|
||||
for(var i = 0; i < cellsHigh; i++) {
|
||||
/* Each row is a different color, randomly generated (but constrained) */
|
||||
var c = genNewColor();
|
||||
var fg_gc = colors[c];
|
||||
//debug("pick color #" + c + " = " + fg_gc);
|
||||
//XSetForeground(dpy, fg_gc, colors[c].pixel);
|
||||
|
||||
for(var j = 0; j < cellsWide; j++) {
|
||||
var curWidth, curHeight, curX, curY;
|
||||
|
||||
/* Generate a random height for a rectangle and make sure that */
|
||||
/* it's above a certain minimum size */
|
||||
curHeight = random() % (cellHeight - shadowWidth);
|
||||
if (curHeight < MINRECTSIZE)
|
||||
curHeight = MINRECTSIZE;
|
||||
/* Generate a random width for a rectangle and make sure that
|
||||
it's above a certain minimum size */
|
||||
curWidth = random() % (cellWidth - shadowWidth);
|
||||
if (curWidth < MINRECTSIZE)
|
||||
curWidth = MINRECTSIZE;
|
||||
/* Figure out a random place to locate the rectangle within the
|
||||
cell */
|
||||
curY = (i * cellHeight) + (random() % ((cellHeight - curHeight) -
|
||||
shadowWidth));
|
||||
curX = (j * cellWidth) + (random() % ((cellWidth - curWidth) -
|
||||
shadowWidth));
|
||||
|
||||
/* Draw the shadow */
|
||||
if (elevation > 0)
|
||||
geo.rectangle_fill(curX + elevation, curY + elevation,
|
||||
curX + elevation + curWidth,
|
||||
curY + elevation + curHeight,
|
||||
0x00000060);
|
||||
|
||||
/* Draw the edge */
|
||||
if (shadowWidth > 0)
|
||||
geo.rectangle_fill(curX + shadowWidth, curY + shadowWidth,
|
||||
curX + shadowWidth + curWidth,
|
||||
curY + shadowWidth + curHeight,
|
||||
0x000000ff);
|
||||
|
||||
geo.rectangle_fill(curX, curY, curX+curWidth, curY+curHeight, fg_gc)
|
||||
|
||||
/* Draw a 1-pixel black border around the rectangle */
|
||||
geo.rectangle(curX, curY, curX+curWidth, curY+curHeight, 0x00000000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function random() {
|
||||
return (Math.random() * 0xffffffff).int();
|
||||
}
|
||||
|
||||
function genConstrainedColor(base, tweak) {
|
||||
var i = 1 + (random() % tweak);
|
||||
if (random() & 1)
|
||||
i = -i;
|
||||
i = (base + i) % ncolors;
|
||||
while (i < 0)
|
||||
i += ncolors;
|
||||
return i;
|
||||
}
|
||||
|
||||
function c_tweak(base, tweak) {
|
||||
var ranTweak = random() % (2 * tweak);
|
||||
var n = (base + (ranTweak - tweak));
|
||||
if (n < 0) n = -n;
|
||||
return Math.min(255, n);
|
||||
}
|
||||
|
||||
function genNewColor() {
|
||||
/* These lines handle "sway", or the gradual random changing of */
|
||||
/* colors. After genNewColor() has been called a given number of */
|
||||
/* times (specified by a random permutation of the tweak variable), */
|
||||
/* take whatever color has been most recently randomly generated and */
|
||||
/* make it the new base color. */
|
||||
if (timeLeft == 0) {
|
||||
timeLeft = c_tweak(sway, sway / 3);
|
||||
curColor = curBase;
|
||||
} else {
|
||||
timeLeft--;
|
||||
}
|
||||
|
||||
/* If a randomly generated number is less than the threshold value,
|
||||
produce a "sport" color value that is completely unrelated to the
|
||||
current palette. */
|
||||
if (0 == (random() % THRESHOLD)) {
|
||||
return random() % ncolors;
|
||||
} else {
|
||||
curBase = genConstrainedColor(curColor, tweak);
|
||||
return curBase;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/* FreeJ example scripts
|
||||
* (c) Copyright 2005 Christoph Rudorff aka MrGoil <goil@dyne.org>
|
||||
*
|
||||
* This source code is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Public License as published
|
||||
* by the Free Software Foundation; either version 3 of the License,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* This source code is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* Please refer to the GNU Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Public License along with
|
||||
* this source code; if not, write to:
|
||||
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
Example how to handle errors in js and freej
|
||||
|
||||
run with -D3 and/or -c to see the mess
|
||||
|
||||
*/
|
||||
|
||||
|
||||
var cam = new Array();
|
||||
function do_cam(n) {
|
||||
var cam_obj = null;
|
||||
if (cam[n]) {
|
||||
echo("delete cam"+n);
|
||||
cam_obj = cam[n];
|
||||
echo("file: " + cam_obj.get_filename());
|
||||
rem_layer(cam_obj);
|
||||
cam[n] = null;
|
||||
delete (cam_obj); // FIXME: destructor still not called
|
||||
} else {
|
||||
file = "/dev/video" + n;
|
||||
echo("open cam" + n + " " + file);
|
||||
try {
|
||||
cam_obj = new CamLayer(320, 240, file);
|
||||
} catch (e) {
|
||||
echo ("camExp: " + dumpex(e) );
|
||||
}
|
||||
if (cam_obj) {
|
||||
echo("cam obj: " + cam_obj);
|
||||
add_layer(cam_obj);
|
||||
cam[n] = cam_obj;
|
||||
} else{
|
||||
echo("cam failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dump Exception
|
||||
// props: message fileName lineNumber stack name
|
||||
function dumpex(e) {
|
||||
var msg = "Dump ex: ";
|
||||
for (prop in e) {
|
||||
msg += "'"+prop + "'='" + e[prop]+"', ";
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
mkbd = new KeyboardController();
|
||||
register_controller(mkbd);
|
||||
mkbd.released_q = function() { quit(); }
|
||||
mkbd.released_c = function() { include("cynosure.js"); }
|
||||
mkbd.released_p = function() { include("pan_joy.js"); }
|
||||
mkbd.released_1 = function() { do_cam(0); }
|
||||
mkbd.released_2 = function() { do_cam(1); }
|
||||
mkbd.released_3 = function() { echo("\n\n\nSPAM SPAM\n\n"); }
|
||||
|
||||
mkbd.released_0 = function() {
|
||||
echo("test bad geo layer");
|
||||
try {
|
||||
echo("try");
|
||||
g=new GeometryLayer(30,30,90,90); // freej object
|
||||
echo("\n got geo layer: " + g);
|
||||
} catch (e) {
|
||||
echo ("Exp: " + dumpex(e) );
|
||||
}
|
||||
echo("test end");
|
||||
}
|
||||
mkbd.released_9 = function() {
|
||||
echo("test bad Array");
|
||||
try {
|
||||
echo("try");
|
||||
g=new Array(-90); // js core object
|
||||
echo("\n ok got : " + g);
|
||||
} catch (e) {
|
||||
echo ("Exp: " + dumpex(e) );
|
||||
}
|
||||
echo("test end");
|
||||
}
|
||||
|
||||
mkbd.released_s = function() {
|
||||
echo("now making unhandled exception:");
|
||||
g=new GeometryLayer(30,30,90,90);
|
||||
echo("done (or not ...)");
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// simple audio test reading out harmonics
|
||||
// make sure jack is running and have a look at the connections
|
||||
// also check the values (samplesize and samplerate) to match your conf
|
||||
// -jrml
|
||||
|
||||
//set_resolution(W,H);
|
||||
|
||||
audio = new AudioJack("xine/out_1", 2048, 44100);
|
||||
|
||||
img = new ImageLayer();
|
||||
img.open("../doc/ipernav.png");
|
||||
img.activate(true);
|
||||
img.set_fps();
|
||||
img.start();
|
||||
add_layer(img);
|
||||
vtg = new Filter("vertigo");
|
||||
img.add_filter(vtg);
|
||||
|
||||
kbd = new KeyboardController();
|
||||
register_controller(kbd);
|
||||
kbd.released_q = function() { quit(); }
|
||||
kbd.released_r = function() {
|
||||
if(reset("freej_equalizer.js")) {
|
||||
rem_controller(this);
|
||||
echo("reset ok");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bang = new TriggerController();
|
||||
bang.frame = function() {
|
||||
|
||||
audio.fft();
|
||||
|
||||
flash = 0;
|
||||
phase = (((audio.get_harmonic(8)
|
||||
+ audio.get_harmonic(1) )
|
||||
/ 2 )
|
||||
* 3 ) / 128;
|
||||
if(phase<1) phase = 0;
|
||||
zoom = (((audio.get_harmonic(8)
|
||||
+ audio.get_harmonic(16) )
|
||||
/ 2 )
|
||||
* 3 ) / 64;
|
||||
zoom = (audio.get_harmonic(16)*3)/64;
|
||||
if(zoom<1) zoom = 1;
|
||||
vtg.set_parameter("PhaseIncrement", phase);
|
||||
vtg.set_parameter("ZoomRate", zoom);
|
||||
}
|
||||
|
||||
|
||||
register_controller(bang);
|
||||
|
||||
gc();
|
||||
@@ -0,0 +1,12 @@
|
||||
// simple use of goom and audio
|
||||
// -jrml
|
||||
|
||||
audio = new AudioJack("xine:out_l", 2048, 44100);
|
||||
|
||||
goom = new GoomLayer();
|
||||
audio.add_output(goom);
|
||||
goom.start();
|
||||
add_layer(goom);
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// freej joystick controller settings
|
||||
// basic template by jaromil
|
||||
//
|
||||
|
||||
joy = new JoystickController();
|
||||
register_controller( joy );
|
||||
|
||||
|
||||
joy.axismotion = function(which, axis, value) {
|
||||
echo("joystick " + which +
|
||||
" axis " + axis +
|
||||
" value " + value);
|
||||
}
|
||||
|
||||
|
||||
joy.button = function (which, button, state) {
|
||||
echo("joystick " + which +
|
||||
" button " + button +
|
||||
" state " + state);
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
//
|
||||
// freej keyboard controller settings
|
||||
// basic template by jaromil
|
||||
//
|
||||
|
||||
kbd = new KeyboardController();
|
||||
register_controller( kbd );
|
||||
|
||||
__kbd_sel = selected_layer();
|
||||
|
||||
kbd.pressed_1 = function() { __kbd_sel.set_blit("RGB"); }
|
||||
kbd.pressed_2 = function() { __kbd_sel.set_blit("RED"); }
|
||||
kbd.pressed_3 = function() { __kbd_sel.set_blit("GREEN"); }
|
||||
kbd.pressed_4 = function() { __kbd_sel.set_blit("BLUE"); }
|
||||
kbd.pressed_5 = function() { __kbd_sel.set_blit("ADD"); }
|
||||
kbd.pressed_6 = function() { __kbd_sel.set_blit("SUB"); }
|
||||
kbd.pressed_7 = function() { __kbd_sel.set_blit("ABSDIFF"); }
|
||||
kbd.pressed_8 = function() { __kbd_sel.set_blit("AND"); }
|
||||
kbd.pressed_9 = function() { __kbd_sel.set_blit("OR"); }
|
||||
kbd.pressed_0 = function() { __kbd_sel.set_blit("NEG"); }
|
||||
|
||||
|
||||
kbd.pressed_a = function() { }
|
||||
kbd.pressed_b = function() { }
|
||||
kbd.pressed_c = function() { }
|
||||
kbd.pressed_d = function() { }
|
||||
kbd.pressed_e = function() { }
|
||||
kbd.pressed_f = function() { }
|
||||
kbd.pressed_g = function() { }
|
||||
kbd.pressed_h = function() { }
|
||||
kbd.pressed_i = function() { }
|
||||
kbd.pressed_j = function() { }
|
||||
kbd.pressed_k = function() { }
|
||||
kbd.pressed_l = function() { }
|
||||
kbd.pressed_m = function() { }
|
||||
kbd.pressed_n = function() { }
|
||||
kbd.pressed_o = function() { }
|
||||
kbd.pressed_p = function() { }
|
||||
kbd.pressed_q = function() { }
|
||||
kbd.pressed_r = function() { }
|
||||
kbd.pressed_s = function() { }
|
||||
kbd.pressed_t = function() { }
|
||||
kbd.pressed_u = function() { }
|
||||
kbd.pressed_v = function() { }
|
||||
kbd.pressed_w = function() { }
|
||||
kbd.pressed_x = function() { }
|
||||
kbd.pressed_y = function() { }
|
||||
kbd.pressed_z = function() { }
|
||||
|
||||
// more letter keys are available
|
||||
// in combination with control, shift or alt keys
|
||||
// define them as:
|
||||
kbd.pressed_ctrl_a = function() { }
|
||||
kbd.pressed_shift_b = function() { }
|
||||
kbd.pressed_alt_c = function() { }
|
||||
// .. and so on with other letters
|
||||
// you can also combine ctrl+shift+alt for example:
|
||||
kbd.pressed_ctrl_shift_alt_a = function() { }
|
||||
|
||||
// symbol keys:
|
||||
kbd.pressed_up = function() { }
|
||||
kbd.pressed_down = function() { }
|
||||
kbd.pressed_insert = function() { }
|
||||
kbd.pressed_home = function() { }
|
||||
kbd.pressed_end = function() { }
|
||||
kbd.pressed_pageup = function() { }
|
||||
kbd.pressed_pagedown = function() { }
|
||||
|
||||
// left/right are to change the selected layer
|
||||
kbd.pressed_left = function() {
|
||||
if(!__kbd_sel) __kbd_sel = selected_layer();
|
||||
__kbd_sel = __kbd_sel.prev(); __kbd_sel.select();
|
||||
}
|
||||
kbd.pressed_right = function() {
|
||||
if(!__kbd_sel) __kbd_sel = selected_layer();
|
||||
__kbd_sel = __kbd_sel.next(); __kbd_sel.select();
|
||||
}
|
||||
// plus/minus are to move layer up and down
|
||||
kbd.pressed_plus = function() {
|
||||
if(!__kbd_sel) __kbd_sel = selected_layer();
|
||||
__kbd_sel.up();
|
||||
}
|
||||
kbd.pressed_minus = function() {
|
||||
if(!__kbd_sel) __kbd_sel = selected_layer();
|
||||
__kbd_sel.down();
|
||||
}
|
||||
|
||||
kbd.pressed_backspace = function() { }
|
||||
kbd.pressed_tab = function() { }
|
||||
kbd.pressed_return = function() { }
|
||||
kbd.pressed_space = function() { }
|
||||
kbd.pressed_less = function() { }
|
||||
kbd.pressed_greater = function() { }
|
||||
kbd.pressed_equals = function() { }
|
||||
|
||||
// numeric keypad keys:
|
||||
kbd.pressed_num_1 = function() { }
|
||||
kbd.pressed_num_2 = function() { }
|
||||
kbd.pressed_num_3 = function() { }
|
||||
kbd.pressed_num_4 = function() { }
|
||||
kbd.pressed_num_5 = function() { }
|
||||
kbd.pressed_num_6 = function() { }
|
||||
kbd.pressed_num_7 = function() { }
|
||||
kbd.pressed_num_8 = function() { }
|
||||
kbd.pressed_num_9 = function() { }
|
||||
kbd.pressed_num_0 = function() { }
|
||||
|
||||
kbd.pressed_num_period = function() { }
|
||||
kbd.pressed_num_divide = function() { }
|
||||
kbd.pressed_num_multiply = function() { }
|
||||
kbd.pressed_num_minus = function() { }
|
||||
kbd.pressed_num_plus = function() { }
|
||||
kbd.pressed_num_enter = function() { }
|
||||
kbd.pressed_num_equals = function() { }
|
||||
|
||||
// to quit we have default keys:
|
||||
kbd.pressed_ctrl_q = function() { quit(); }
|
||||
kbd.pressed_ctrl_c = function() { quit(); }
|
||||
kbd.pressed_esc = function() { quit(); }
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
/// actions at key release
|
||||
|
||||
kbd.released_1 = function() { }
|
||||
kbd.released_2 = function() { }
|
||||
kbd.released_3 = function() { }
|
||||
kbd.released_4 = function() { }
|
||||
kbd.released_5 = function() { }
|
||||
kbd.released_6 = function() { }
|
||||
kbd.released_7 = function() { }
|
||||
kbd.released_8 = function() { }
|
||||
kbd.released_9 = function() { }
|
||||
kbd.released_0 = function() { }
|
||||
|
||||
kbd.released_a = function() { }
|
||||
kbd.released_b = function() { }
|
||||
kbd.released_c = function() { }
|
||||
kbd.released_d = function() { }
|
||||
kbd.released_e = function() { }
|
||||
kbd.released_f = function() { }
|
||||
kbd.released_g = function() { }
|
||||
kbd.released_h = function() { }
|
||||
kbd.released_i = function() { }
|
||||
kbd.released_j = function() { }
|
||||
kbd.released_k = function() { }
|
||||
kbd.released_l = function() { }
|
||||
kbd.released_m = function() { }
|
||||
kbd.released_n = function() { }
|
||||
kbd.released_o = function() { }
|
||||
kbd.released_p = function() { }
|
||||
kbd.released_q = function() { }
|
||||
kbd.released_r = function() { }
|
||||
kbd.released_s = function() { }
|
||||
kbd.released_t = function() { }
|
||||
kbd.released_u = function() { }
|
||||
kbd.released_v = function() { }
|
||||
kbd.released_w = function() { }
|
||||
kbd.released_x = function() { }
|
||||
kbd.released_y = function() { }
|
||||
kbd.released_z = function() { }
|
||||
|
||||
// more letter keys are available
|
||||
// in combination with control, shift or alt keys
|
||||
// define them as:
|
||||
kbd.released_ctrl_a = function() { }
|
||||
kbd.released_shift_b = function() { }
|
||||
kbd.released_alt_c = function() { }
|
||||
// .. and so on with other letters
|
||||
// you can also combine ctrl+shift+alt for example:
|
||||
kbd.released_ctrl_shift_alt_a = function() { }
|
||||
|
||||
// symbol keys:
|
||||
kbd.released_up = function() { }
|
||||
kbd.released_down = function() { }
|
||||
kbd.released_left = function() { }
|
||||
kbd.released_right = function() { }
|
||||
kbd.released_insert = function() { }
|
||||
kbd.released_home = function() { }
|
||||
kbd.released_end = function() { }
|
||||
kbd.released_pageup = function() { }
|
||||
kbd.released_pagedown = function() { }
|
||||
kbd.released_esc = function() { }
|
||||
|
||||
kbd.released_backspace = function() { }
|
||||
kbd.released_tab = function() { }
|
||||
kbd.released_return = function() { }
|
||||
kbd.released_space = function() { }
|
||||
kbd.released_plus = function() { }
|
||||
kbd.released_minus = function() { }
|
||||
kbd.released_less = function() { }
|
||||
kbd.released_greater = function() { }
|
||||
kbd.released_equals = function() { }
|
||||
|
||||
// numeric keypad keys:
|
||||
kbd.released_num_1 = function() { }
|
||||
kbd.released_num_2 = function() { }
|
||||
kbd.released_num_3 = function() { }
|
||||
kbd.released_num_4 = function() { }
|
||||
kbd.released_num_5 = function() { }
|
||||
kbd.released_num_6 = function() { }
|
||||
kbd.released_num_7 = function() { }
|
||||
kbd.released_num_8 = function() { }
|
||||
kbd.released_num_9 = function() { }
|
||||
kbd.released_num_0 = function() { }
|
||||
|
||||
kbd.released_num_period = function() { }
|
||||
kbd.released_num_divide = function() { }
|
||||
kbd.released_num_multiply = function() { }
|
||||
kbd.released_num_minus = function() { }
|
||||
kbd.released_num_plus = function() { }
|
||||
kbd.released_num_enter = function() { }
|
||||
kbd.released_num_equals = function() { }
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/* FreeJ example scripts
|
||||
* (c) Copyright 2005 Christoph Rudorff aka MrGoil <goil@dyne.org>
|
||||
*
|
||||
* This source code is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Public License as published
|
||||
* by the Free Software Foundation; either version 3 of the License,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* This source code is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* Please refer to the GNU Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Public License along with
|
||||
* this source code; if not, write to:
|
||||
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
Example usage of MidiController() by Mr Goil
|
||||
*/
|
||||
|
||||
|
||||
kbd = new KeyboardController();
|
||||
register_controller(kbd);
|
||||
kbd.released_q = function() { quit(); }
|
||||
|
||||
// put something on the stage
|
||||
i = new ImageLayer(100,100);
|
||||
i.open("scripts/1steps063.jpg");
|
||||
add_layer(i);
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
|
||||
mc = new MidiController();
|
||||
register_controller(mc);
|
||||
|
||||
// use 'aconnect -li' or aconnectgui to determine port values
|
||||
ret = mc.connect_from(0, 20, 0);
|
||||
echo("connect: " + ret);
|
||||
ret = mc.connect_from(0, 20, 0); // just test:
|
||||
echo("connect: " + ret); // -16 device busy
|
||||
ret = mc.connect_from(0, 123, 456); // illegal
|
||||
echo("connect: " + ret); // -22 Invalid argument
|
||||
|
||||
// assign callbacks
|
||||
mc.event_ctrl = function (ch, func, value) {
|
||||
midi_event("event_ctrl", ch, func, value);
|
||||
}
|
||||
|
||||
mc.event_pitch = function (ch, func, value) {
|
||||
midi_event("event_pitch", ch, func, value);
|
||||
}
|
||||
|
||||
mc.event_noteon = function (ch, func, value) {
|
||||
midi_event("event_noteon", ch, func, value);
|
||||
}
|
||||
|
||||
mc.event_noteoff = function (ch, func, value) {
|
||||
midi_event("event_noteoff", ch, func, value);
|
||||
}
|
||||
|
||||
mc.event_pgmchange = function (ch, func, value) {
|
||||
midi_event("event_pgm", ch, func, value);
|
||||
}
|
||||
|
||||
function midi_event(what, ch, func, value) {
|
||||
echo("midi js " + what + " called " + ch + ", " + func + ", " + value);
|
||||
if ( func % 2 )
|
||||
x = value;
|
||||
else
|
||||
y = value;
|
||||
i.set_position(x,y);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
[chris@hirnlego ~/Software/FREEJ/brain]$ aconnect -li
|
||||
client 0: 'System' [type=Kernel]
|
||||
0 'Timer '
|
||||
1 'Announce '
|
||||
Verbinde mit: 15:0, 130:0, 131:0
|
||||
client 14: 'Midi Through' [type=Kernel]
|
||||
0 'Midi Through Port-0'
|
||||
client 20: 'UC-33 USB MIDI Controller' [type=Kernel]
|
||||
0 'UC-33 USB MIDI Controller MIDI '
|
||||
1 'UC-33 USB MIDI Controller MIDI '
|
||||
|
||||
[chris@hirnlego ~/Software/FREEJ/brain]$ aconnect -lo
|
||||
client 14: 'Midi Through' [type=Kernel]
|
||||
0 'Midi Through Port-0'
|
||||
client 20: 'UC-33 USB MIDI Controller' [type=Kernel]
|
||||
0 'UC-33 USB MIDI Controller MIDI '
|
||||
client 128: 'freej MidiController' [type=Benutzer]
|
||||
0 'MIDI IN '
|
||||
1 'MIDI IN 2 '
|
||||
client 129: 'freej MidiController' [type=Benutzer]
|
||||
0 'MIDI IN '
|
||||
1 'MIDI IN 2 '
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
m = new MouseController();
|
||||
register_controller(m);
|
||||
|
||||
// MouseController.button(button, state, x, y)
|
||||
m.button = function(b, s, x, y) {
|
||||
echo("b"+b+" s"+s+" x"+x+" y"+y);
|
||||
this.grab(s);
|
||||
}
|
||||
|
||||
// MouseController.motion(buttonmask, x, y, xrel, yrel)
|
||||
m.motion = function(b, x, y, dx, dy) {
|
||||
echo("b"+b+" x"+x+" y"+y+" dx"+dx+" dy"+dy);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
m = new MouseController();
|
||||
register_controller(m);
|
||||
|
||||
m.zoomx = 1; m.zoomy = 1; m.maxzoom=4;
|
||||
|
||||
// MouseController.button(button, state, x, y)
|
||||
m.button = function(b, s, x, y) {
|
||||
echo("b"+b+" s"+s+" x"+x+" y"+y);
|
||||
this.grab(s);
|
||||
|
||||
if (s == 1)
|
||||
this.l=selected_layer();
|
||||
else
|
||||
delete this.l;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// MouseController.motion(buttonmask, x, y, xrel, yrel)
|
||||
m.motion = function(b, x, y, dx, dy) {
|
||||
echo("b"+b+" x"+x+" y"+y+" dx"+dx+" dy"+dy);
|
||||
|
||||
var l = this.l
|
||||
if (!l)
|
||||
return false;
|
||||
|
||||
if (b & 1) {
|
||||
l.set_position(l.x() + dx, l.y() + dy);
|
||||
}
|
||||
if (b & 2) {
|
||||
}
|
||||
if (b & 4) {
|
||||
this.zoomx += dx/100;
|
||||
this.zoomy += dy/100;
|
||||
if (Math.abs(this.zoomx)>this.maxzoom)
|
||||
this.zoomx=this.maxzoom;
|
||||
if (Math.abs(this.zoomy)>this.maxzoom)
|
||||
this.zoomy=this.maxzoom;
|
||||
l.zoom(this.zoomx, this.zoomy);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
animation_file = "Desktop/Bart_Simpson_2.gif";
|
||||
anim = new MovieLayer(animation_file);
|
||||
anim.set_fps(25);
|
||||
add_layer(anim);
|
||||
anim.activate(true);
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// testing OSC messaging
|
||||
|
||||
osc = new OscController("9696"); // open an OSC listener on port 9696
|
||||
|
||||
// auxiliary keyboard
|
||||
kbd = new KeyboardController();
|
||||
register_controller( kbd );
|
||||
kbd.released_q = function() { quit(); };
|
||||
|
||||
// pressing 'm' will send a test message to itself
|
||||
kbd.released_m = function() {
|
||||
osc.send("/test","ifs",123,4.5,"hello");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// define the function that will be called
|
||||
osc.test_callback = function test_callback(i,f,s) {
|
||||
echo("OSC remote call to my test function");
|
||||
echo("int argument is: " + i);
|
||||
echo("float argument is: " + f);
|
||||
echo("string argument is: " + s);
|
||||
return true;
|
||||
};
|
||||
|
||||
// create a /my_new_method call on OSC, taking one integer as argument, that
|
||||
// will call the remote_called_function() defined in javascript:
|
||||
osc.add_method("/test","ifs","test_callback");
|
||||
osc.send_to("localhost","9696");
|
||||
|
||||
// starts the osc listener thread
|
||||
osc.start();
|
||||
// to stop it during execution use osc.stop();
|
||||
|
||||
// and don't forget to register the controller
|
||||
register_controller(osc);
|
||||
@@ -0,0 +1,62 @@
|
||||
/* FreeJ example scripts
|
||||
* (c) Copyright 2005 Christoph Rudorff aka MrGoil <goil@dyne.org>
|
||||
*
|
||||
* This source code is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Public License as published
|
||||
* by the Free Software Foundation; either version 3 of the License,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* This source code is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* Please refer to the GNU Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Public License along with
|
||||
* this source code; if not, write to:
|
||||
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
include("keyboard.js");
|
||||
|
||||
w=400; h=300;
|
||||
|
||||
tile_x=128;
|
||||
tile_y=128;
|
||||
|
||||
max_m=Math.ceil(w/tile_x) * 2;
|
||||
max_n=Math.ceil(h/tile_y) * 2;
|
||||
|
||||
imgs = new Array();
|
||||
for (m=0; m<max_m; m++) {
|
||||
imgs[m] = new Array()
|
||||
for (n=0; n<max_n; n++) {
|
||||
i = new ImageLayer(tile_x,tile_y);
|
||||
i.open("1steps063.jpg");
|
||||
add_layer(i);
|
||||
i.set_position(tile_x*m, tile_y*n);
|
||||
imgs[m][n] = i;
|
||||
}
|
||||
}
|
||||
|
||||
run(1);
|
||||
|
||||
|
||||
dx=dy=0;
|
||||
bx = max_m * tile_x / 2;
|
||||
by = max_n * tile_y / 2;
|
||||
while (1) {
|
||||
for (m=0; m<max_m; m++) {
|
||||
for (n=0; n<max_n; n++) {
|
||||
i = imgs[m][n];
|
||||
i.set_position ( tile_x*m - dx, tile_y*n - dy);
|
||||
}
|
||||
}
|
||||
run(0.01);
|
||||
dx++;
|
||||
dy++;
|
||||
dx = dx % bx
|
||||
dy = dy % by;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
/* FreeJ example scripts
|
||||
* (c) Copyright 2007 Christoph Rudorff aka MrGoil <goil@dyne.org>
|
||||
*
|
||||
* This source code is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Public License as published
|
||||
* by the Free Software Foundation; either version 3 of the License,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* This source code is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* Please refer to the GNU Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Public License along with
|
||||
* this source code; if not, write to:
|
||||
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
// freej script example by Mr.Goil
|
||||
// this one can tile a seamless image and pan a plane with it
|
||||
// $Id: $
|
||||
|
||||
w=800; h=600;
|
||||
set_resolution(w, h);
|
||||
|
||||
tile_x=128;
|
||||
tile_y=128;
|
||||
|
||||
max_m=Math.ceil(w/tile_x) * 2;
|
||||
max_n=Math.ceil(h/tile_y) * 2;
|
||||
|
||||
curr_img=0;
|
||||
//images = scandir("./*.jpg");
|
||||
images = new Array("1steps063.jpg");
|
||||
|
||||
imgs = null;
|
||||
function init() {
|
||||
imgs = new Array();
|
||||
for (m=0; m<max_m; m++) {
|
||||
imgs[m] = new Array();
|
||||
for (n=0; n<max_n; n++) {
|
||||
try {
|
||||
i = new ImageLayer(tile_x,tile_y);
|
||||
i.open(images[curr_img]);
|
||||
i.set_fps();
|
||||
i.start();
|
||||
add_layer(i);
|
||||
i.set_position(tile_x*m, tile_y*n);
|
||||
i.activate();
|
||||
imgs[m][n] = i;
|
||||
// echo ("size " + i.get_width() + "x" + i.get_height() );
|
||||
} catch (e) {
|
||||
echo("Failed to open " + e);
|
||||
//echo("Failed to open " + images[curr_img] + ": " + e);
|
||||
if (++curr_img<images.length-1)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
init();
|
||||
|
||||
try {
|
||||
jc = new JoystickController();
|
||||
register_controller(jc);
|
||||
jc.axismotion = function (which, axis, value) {
|
||||
value = value/100000; //equilaze
|
||||
if(!last_js[which]) {
|
||||
last_js[which] = new Array();
|
||||
}
|
||||
last_js[which][axis] = value;
|
||||
}
|
||||
|
||||
jc.button = function (which, button, state) {
|
||||
if(state==1)
|
||||
switch (button) {
|
||||
case 6:
|
||||
prev_img();
|
||||
break;
|
||||
|
||||
case 7:
|
||||
next_img();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
echo("mh, no joystick?! " + e);
|
||||
// quit();
|
||||
}
|
||||
|
||||
last_js = new Array();
|
||||
|
||||
function axismotion(which, axis, value) {
|
||||
// mh, on macbookporn, the hd joystick is funny ... and must be inverted
|
||||
// if (which==0) return;
|
||||
if (which==0) value=-value;
|
||||
switch(axis) {
|
||||
case 0:
|
||||
sx -= value;
|
||||
break;
|
||||
case 1:
|
||||
sy -= value;
|
||||
break;
|
||||
/* case 3:
|
||||
g=data[1];
|
||||
g.sx += value;
|
||||
break;
|
||||
case 4:
|
||||
g=data[1];
|
||||
g.sy += value;
|
||||
break;
|
||||
*/
|
||||
}
|
||||
max_speed();
|
||||
}
|
||||
max_s=100;
|
||||
function max_speed () {
|
||||
if (sx > max_s) sx=max_s;
|
||||
if (sx < -max_s) sx=-max_s;
|
||||
if (sy > max_s) sy=max_s;
|
||||
if (sy < -max_s) sy=-max_s;
|
||||
}
|
||||
|
||||
// kbd = new KeyboardController();
|
||||
// register_controller(kbd);
|
||||
// kbd.released_q = function() { quit(); }
|
||||
// kbd.released_a = next_img;
|
||||
// kbd.released_z = prev_img;
|
||||
|
||||
function next_img() {
|
||||
//curr_img++;
|
||||
if (++curr_img>images.length-1)
|
||||
curr_img=0;
|
||||
//init();
|
||||
clean_up();
|
||||
}
|
||||
|
||||
function prev_img () {
|
||||
//curr_img++;
|
||||
if (--curr_img<0)
|
||||
curr_img=images.length-1;
|
||||
//init();
|
||||
clean_up();
|
||||
}
|
||||
|
||||
function clean_up() {
|
||||
for (m=0; m<max_m; m++) {
|
||||
for (n=0; n<max_n; n++) {
|
||||
var i = imgs[m][n];
|
||||
i.open(images[curr_img]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dx=dy=0;
|
||||
sx=sy=1;
|
||||
bx = max_m * tile_x / 2;
|
||||
by = max_n * tile_y / 2;
|
||||
|
||||
tr=new TriggerController();
|
||||
register_controller(tr);
|
||||
tr.frame = function() {
|
||||
for (m=0; m<max_m; m++) {
|
||||
for (n=0; n<max_n; n++) {
|
||||
i = imgs[m][n];
|
||||
i.set_position ( tile_x*m - dx, tile_y*n - dy);
|
||||
//echo ( "set " + m + "," + n + "to" + (tile_x*m - dx) + " " + (tile_y*n - dy) );
|
||||
}
|
||||
}
|
||||
dx += Math.floor(sx);
|
||||
dy += Math.floor(sy);
|
||||
dx = dx % bx
|
||||
dy = dy % by;
|
||||
if (dx < 0)
|
||||
dx += bx;
|
||||
if (dy < 0)
|
||||
dy += by;
|
||||
for (which=0; which <= last_js.length; which++) {
|
||||
//echo("whch " + which);
|
||||
if (last_js[which]) {
|
||||
for (axis=0; axis <= (last_js[which]).length; axis++) {
|
||||
//echo("axis " + axis);
|
||||
value = last_js[which][axis];
|
||||
if ((value) && (value !=0)) {
|
||||
//echo("val " + last_js[which][axis]);
|
||||
axismotion(which, axis, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
init();
|
||||
@@ -0,0 +1,90 @@
|
||||
/* FreeJ example scripts
|
||||
* (c) Copyright 2008 Christoph Rudorff aka MrGoil <goil@dyne.org>
|
||||
*
|
||||
* This source code is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Public License as published
|
||||
* by the Free Software Foundation; either version 3 of the License,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* This source code is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* Please refer to the GNU Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Public License along with
|
||||
* this source code; if not, write to:
|
||||
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/* a nice helper to set script values with controler values
|
||||
automagicly check ranges and sets values by name in the caller context
|
||||
*/
|
||||
|
||||
function Param(obj, name, in_min, in_max, out_min, out_max, out_start_value) {
|
||||
if (arguments.length != 7)
|
||||
throw "Wrong no of Args.";
|
||||
if ( (out_max-out_min == 0) || (in_max-in_min == 0))
|
||||
throw "Argument value error";
|
||||
this.frac = 0; // default output Integer
|
||||
this.obj = obj;
|
||||
this.name = name;
|
||||
this.in_min = in_min;
|
||||
this.in_max = in_max;
|
||||
this.out_min = out_min;
|
||||
this.out_max = out_max;
|
||||
|
||||
this.out_value = Math.round(out_start_value);
|
||||
obj[name] = out_start_value;
|
||||
|
||||
this.mult = (out_max-out_min)/(in_max-in_min);
|
||||
this.in_value = Math.int((this.out_value -this.out_min)/this.mult + this.in_min);
|
||||
}
|
||||
|
||||
Param.prototype.setValue = function(in_value) {
|
||||
in_value = this.range(Math.int(in_value));
|
||||
var out_value = (this.mult*(in_value-this.in_min) + this.out_min).round(this.frac);
|
||||
this.obj[this.name] = out_value;
|
||||
this.in_value = in_value;
|
||||
this.out_value= out_value;
|
||||
// echo(this.name + "in: " + in_value + " out: " + this.out_value);
|
||||
}
|
||||
|
||||
Param.prototype.step = function(n) {
|
||||
// if this.mult<1 ...
|
||||
var in_value = this.range(this.in_value + n);
|
||||
this.setValue(in_value);
|
||||
}
|
||||
|
||||
Param.prototype.range = function(v) {
|
||||
return Math.min(this.in_max, Math.max(this.in_min, v));
|
||||
}
|
||||
|
||||
Param.prototype.print = function(textlayer) {
|
||||
if (textlayer instanceof TextLayer) {
|
||||
var msg = this.name + ": " + this.out_value;
|
||||
textlayer.print(msg);
|
||||
} else {
|
||||
throw("I want a TextLayer!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// goodies ... return js_int(!)
|
||||
|
||||
Math.int = function(i) {
|
||||
if (i>0)
|
||||
return this.floor(i)
|
||||
else
|
||||
return this.ceil(i)
|
||||
}
|
||||
Number.prototype.int = function() {
|
||||
return Math.int(this);
|
||||
}
|
||||
Number.prototype.round = function(d) {
|
||||
if (d == 0)
|
||||
return Math.round(this);
|
||||
d = Math.pow(10,d);
|
||||
return Math.round(this*d)/d;
|
||||
}
|
||||
|
||||
echo("param included");
|
||||
@@ -0,0 +1,31 @@
|
||||
/// simple example script for streaming
|
||||
/// do any action above here and then include the code below to stream
|
||||
// don't forget to edit it with your streaming authentication
|
||||
|
||||
// create a jack audio input
|
||||
// port name buffer size samlerate
|
||||
//audio = new AudioJack("alsaplayer", 2048, 44100);
|
||||
// in case the port named is not already present:
|
||||
// you should connect the input manually using jack
|
||||
|
||||
// create a video encoder object
|
||||
// values 1-100 video quality video bitrate audio quality audio_bitrate
|
||||
encoder = new VideoEncoder(50, 64000, 0, 0);
|
||||
|
||||
kbd = new KeyboardController();
|
||||
register_controller( kbd );
|
||||
|
||||
|
||||
// add the audio channel in the video encoded
|
||||
//encoder.add_audio(audio);
|
||||
|
||||
//encoder.start_stream();
|
||||
|
||||
kbd.pressed_s = function() {
|
||||
encoder.stop_filesave();
|
||||
delete encoder;
|
||||
}
|
||||
|
||||
kbd.pressed_r = function() {
|
||||
register_encoder(encoder);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
Freej fading image slideshow script - (c)2007 by Jaromil
|
||||
|
||||
usage:
|
||||
configure image directory for scandir
|
||||
press arrows left/right to browse through images
|
||||
*/
|
||||
|
||||
|
||||
set_resolution(1024,768);
|
||||
//fullscreen();
|
||||
|
||||
include("keyboard.js");
|
||||
|
||||
images = scandir("img");
|
||||
|
||||
c = 0;
|
||||
|
||||
lay1 = new ImageLayer();
|
||||
lay2 = new ImageLayer();
|
||||
|
||||
|
||||
// fade in the first image
|
||||
lay1.open(images[c]);
|
||||
lay1.set_blit("ALPHA");
|
||||
lay1.set_blit_value(0.0);
|
||||
add_layer(lay1);
|
||||
lay1.fade_blit_value (1.0, 0.1);
|
||||
|
||||
flip = 0;
|
||||
|
||||
function crossfade(img) {
|
||||
|
||||
if(flip=0) {
|
||||
slidein = lay2;
|
||||
slideout = lay1;
|
||||
flip = 1;
|
||||
} else {
|
||||
slidein = lay1;
|
||||
slideout = lay2;
|
||||
flip = 0;
|
||||
}
|
||||
|
||||
|
||||
slideout.spin(0, 0.1);
|
||||
|
||||
slidein.open(img);
|
||||
|
||||
slidein.set_blit("0ALPHA");
|
||||
|
||||
add_layer(slidein);
|
||||
|
||||
|
||||
slideout.fade_blit_value(0.0, 0.1);
|
||||
|
||||
slidein.fade_blit_value (1.0, 0.1);
|
||||
|
||||
rem_layer(slideout);
|
||||
|
||||
}
|
||||
|
||||
|
||||
kbd.pressed_left = function() {
|
||||
if(c>0) c--;
|
||||
crossfade(images[c]);
|
||||
}
|
||||
|
||||
kbd.pressed_right = function() {
|
||||
if(c<images.length) c++;
|
||||
crossfade(images[c]);
|
||||
}
|
||||
|
||||
kbd.pressed_space = kbd.pressed_right;
|
||||
kbd.pressed_q = quit();
|
||||
|
||||
while(true)
|
||||
run();
|
||||
|
||||
quit();
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
// freej example script by jaromil
|
||||
// this simply draws i kind of star
|
||||
// it also shows the usage of keyboard controller
|
||||
// press 'q' to quit while running
|
||||
|
||||
x = 100;
|
||||
y = 100;
|
||||
s = 30 / 0.383;
|
||||
s2 = s;
|
||||
|
||||
PI = 3.141592654;
|
||||
c = PI * 2;
|
||||
o = -PI / 2;
|
||||
|
||||
function drawStar(lay, s_mul, s2_mul) {
|
||||
s = s_mul / 0.383;
|
||||
s2 = s / s2_mul;
|
||||
|
||||
var cx;
|
||||
for(cx=0; cx<10; cx++) {
|
||||
k = cx/10;
|
||||
kn = k+0.1;
|
||||
|
||||
x1 = x+s * Math.cos(o + k*c);
|
||||
y1 = y+s * Math.sin(o + k*c);
|
||||
x2 = x+s2 * Math.cos(o + kn*c);
|
||||
y2 = y+s2 * Math.sin(o + kn*c);
|
||||
x1 = Math.floor(x1);
|
||||
y1 = Math.floor(y1);
|
||||
x2 = Math.floor(x2);
|
||||
y2 = Math.floor(y2);
|
||||
|
||||
// debug("drawing star line:" + x1 + "," + y1 + " " + x2 + "," + y2);
|
||||
// lay.line( x.toPrecision()+s.toPrecision() * Math.cos(o + k*c),
|
||||
// y+s * Math.sin(o + k*c),
|
||||
// x+s2 * Math.cos(o + kn*c),
|
||||
// y+s2 * Math.sin(o + kn*c) );
|
||||
lay.aaline(x1, y1, x2, y2);
|
||||
}
|
||||
}
|
||||
|
||||
running = true;
|
||||
kbd = new KeyboardController();
|
||||
kbd.pressed_esc = function() { running = false; }
|
||||
register_controller( kbd );
|
||||
|
||||
star = new GeometryLayer();
|
||||
star.color(255,255,255,255);
|
||||
star.set_blit("alpha");
|
||||
//star.set_name("star.js");
|
||||
star.set_blit_value(0.1);
|
||||
//star.start();
|
||||
star.activate(true);
|
||||
add_layer(star);
|
||||
|
||||
drawStar(star,30,1);
|
||||
|
||||
srand();
|
||||
|
||||
cc = 1;
|
||||
|
||||
bang = new TriggerController();
|
||||
register_controller(bang);
|
||||
bang.frame = function() {
|
||||
|
||||
cc += 0.05;
|
||||
|
||||
star.color(rand()%255, rand()%255, rand()%255, 0xff);
|
||||
drawStar(star, 30, Math.sin(cc));
|
||||
|
||||
if(cc>4.0) {
|
||||
cc = 1;
|
||||
srand();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/// simple example script for streaming
|
||||
/// do any action above here and then include the code below to stream
|
||||
// don't forget to edit it with your streaming authentication
|
||||
|
||||
// create a jack audio input
|
||||
// port name buffer size samlerate
|
||||
audio = new AudioJack("alsaplayer", 2048, 44100);
|
||||
// in case the port named is not already present:
|
||||
// you should connect the input manually using jack
|
||||
|
||||
// create a video encoder object
|
||||
// values 1-100 video quality video bitrate audio quality audio_bitrate
|
||||
encoder = new VideoEncoder(10, 120000, 5, 24000);
|
||||
|
||||
// add the audio channel in the video encoded
|
||||
encoder.add_audio(audio);
|
||||
|
||||
encoder.stream_host("giss.tv");
|
||||
encoder.stream_port(8000);
|
||||
encoder.stream_title("testing new freej");
|
||||
encoder.stream_username("source");
|
||||
encoder.stream_password("2t645");
|
||||
encoder.stream_mountpoint("freej-test.ogg");
|
||||
|
||||
register_encoder(encoder);
|
||||
encoder.start_stream();
|
||||
//function record() {
|
||||
// encoder.start_filesave('/mnt/hd1/2/capture.ogm');
|
||||
//}
|
||||
@@ -0,0 +1,135 @@
|
||||
// freej script to test randomness
|
||||
// this also shows keyboard interactivity
|
||||
// and smart use of function pointers
|
||||
// (C)2005 Denis Jaromil Rojo - GNU GPL
|
||||
|
||||
width = 400;
|
||||
height = 300;
|
||||
drawer = draw_triangles;
|
||||
|
||||
function draw_pixels(geo) {
|
||||
var x, y;
|
||||
|
||||
x = rand()%width;
|
||||
y = rand()%height;
|
||||
|
||||
if(x<0) x = -x;
|
||||
if(y<0) y = -y;
|
||||
|
||||
geo.pixel(x,y);
|
||||
}
|
||||
|
||||
|
||||
function draw_triangles(geo) {
|
||||
var x1, x2, x3;
|
||||
var y1, y2, y3;
|
||||
|
||||
x1 = rand()%width;
|
||||
x2 = rand()%width;
|
||||
x3 = rand()%width;
|
||||
y1 = rand()%height;
|
||||
y2 = rand()%height;
|
||||
y3 = rand()%height;
|
||||
|
||||
if(x1<0) x1 = -x1;
|
||||
if(x2<0) x2 = -x2;
|
||||
if(x3<0) x3 = -x3;
|
||||
if(y1<0) y1 = -y1;
|
||||
if(y2<0) y2 = -y2;
|
||||
if(y3<0) y3 = -y3;
|
||||
|
||||
geo.trigon_fill(x1,y1,x2,y2,x3,y3);
|
||||
}
|
||||
|
||||
|
||||
function draw_ellipses(geo) {
|
||||
var x, y;
|
||||
var rx, ry;
|
||||
|
||||
x = rand()%width;
|
||||
y = rand()%height;
|
||||
rx = rand()%(width/2);
|
||||
ry = rand()%(height/2);
|
||||
|
||||
if(x<0) x = -x;
|
||||
if(y<0) y = -y;
|
||||
if(rx<0) rx = -rx;
|
||||
if(ry<0) ry = -ry;
|
||||
|
||||
geo.ellipse_fill(x, y, rx, ry);
|
||||
}
|
||||
|
||||
function randomize_color(geo) {
|
||||
var r, g, b;
|
||||
|
||||
r = rand() % 255;
|
||||
g = rand() % 255;
|
||||
b = rand() % 255;
|
||||
|
||||
if(r<0) r = -r;
|
||||
if(g<0) g = -g;
|
||||
if(b<0) b = -b;
|
||||
|
||||
geo.color(r,g,b,150);
|
||||
}
|
||||
|
||||
set_fps(10);
|
||||
|
||||
geo = new GeometryLayer(400,300);
|
||||
geo.set_blit("alpha");
|
||||
geo.set_blit_value(0.5);
|
||||
add_layer(geo);
|
||||
|
||||
txt = new TextLayer();
|
||||
txt.print("FreeJ 0.9 test stream");
|
||||
txt.set_position(20,10);
|
||||
txt.set_blit("add");
|
||||
add_layer(txt);
|
||||
|
||||
running = true;
|
||||
kbd = new KeyboardController();
|
||||
kbd.released_q = function() { running = false; }
|
||||
kbd.released_p = function() { drawer = draw_pixels; }
|
||||
kbd.released_t = function() { drawer = draw_triangles; }
|
||||
kbd.released_e = function() { drawer = draw_ellipses; }
|
||||
register_controller( kbd );
|
||||
|
||||
// create a video encoder object
|
||||
// values 1-100 video quality video bitrate audio quality audio_bitrate
|
||||
encoder = new VideoEncoder(10, 128000, 4, 32000);
|
||||
|
||||
/*
|
||||
encoder.stream_host("10.66.66.133");
|
||||
encoder.stream_port(8000);
|
||||
encoder.stream_title("testing new freej");
|
||||
encoder.stream_username("source");
|
||||
encoder.stream_password("Revolution");
|
||||
encoder.stream_mountpoint("freej-test.ogg");
|
||||
*/
|
||||
|
||||
encoder.stream_host("10.66.66.69");
|
||||
encoder.stream_port(8000);
|
||||
encoder.stream_title("testing new freej");
|
||||
encoder.stream_username("source");
|
||||
encoder.stream_password("hackme");
|
||||
encoder.stream_mountpoint("freej-test.ogg");
|
||||
|
||||
|
||||
register_encoder(encoder);
|
||||
//encoder.start_stream();
|
||||
encoder.start_filesave("prova.ogg");
|
||||
|
||||
while(running) {
|
||||
|
||||
randomize_color(geo);
|
||||
|
||||
drawer(geo);
|
||||
|
||||
run(0.001);
|
||||
|
||||
}
|
||||
|
||||
encoder.stop_filesave();
|
||||
//encoder.stop_stream();
|
||||
quit();
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
// freej script to test randomness
|
||||
// this also shows keyboard interactivity
|
||||
// and smart use of function pointers
|
||||
// (C)2005 Denis Jaromil Rojo - GNU GPL
|
||||
|
||||
width = 400;
|
||||
height = 300;
|
||||
drawer = draw_triangles;
|
||||
|
||||
function draw_pixels(geo) {
|
||||
var x, y;
|
||||
|
||||
x = rand()%width;
|
||||
y = rand()%height;
|
||||
|
||||
if(x<0) x = -x;
|
||||
if(y<0) y = -y;
|
||||
|
||||
geo.pixel(x,y);
|
||||
}
|
||||
|
||||
|
||||
function draw_triangles(geo) {
|
||||
var x1, x2, x3;
|
||||
var y1, y2, y3;
|
||||
|
||||
x1 = rand()%width;
|
||||
x2 = rand()%width;
|
||||
x3 = rand()%width;
|
||||
y1 = rand()%height;
|
||||
y2 = rand()%height;
|
||||
y3 = rand()%height;
|
||||
|
||||
if(x1<0) x1 = -x1;
|
||||
if(x2<0) x2 = -x2;
|
||||
if(x3<0) x3 = -x3;
|
||||
if(y1<0) y1 = -y1;
|
||||
if(y2<0) y2 = -y2;
|
||||
if(y3<0) y3 = -y3;
|
||||
|
||||
geo.trigon_fill(x1,y1,x2,y2,x3,y3);
|
||||
}
|
||||
|
||||
|
||||
function draw_ellipses(geo) {
|
||||
var x, y;
|
||||
var rx, ry;
|
||||
|
||||
x = rand()%width;
|
||||
y = rand()%height;
|
||||
rx = rand()%(width/2);
|
||||
ry = rand()%(height/2);
|
||||
|
||||
if(x<0) x = -x;
|
||||
if(y<0) y = -y;
|
||||
if(rx<0) rx = -rx;
|
||||
if(ry<0) ry = -ry;
|
||||
|
||||
geo.ellipse_fill(x, y, rx, ry);
|
||||
}
|
||||
|
||||
function randomize_color(geo) {
|
||||
var r, g, b;
|
||||
|
||||
r = rand() % 255;
|
||||
g = rand() % 255;
|
||||
b = rand() % 255;
|
||||
|
||||
if(r<0) r = -r;
|
||||
if(g<0) g = -g;
|
||||
if(b<0) b = -b;
|
||||
|
||||
geo.color(r,g,b,150);
|
||||
}
|
||||
|
||||
geo = new GeometryLayer(400,300);
|
||||
geo.set_blit("alpha");
|
||||
geo.set_blit_value(0.5);
|
||||
geo.activate(true);
|
||||
geo.start();
|
||||
geo.set_fps(24);
|
||||
add_layer(geo);
|
||||
|
||||
running = true;
|
||||
kbd = new KeyboardController();
|
||||
kbd.released_q = function() { running = false; }
|
||||
kbd.released_p = function() { drawer = draw_pixels; }
|
||||
kbd.released_t = function() { drawer = draw_triangles; }
|
||||
kbd.released_e = function() { drawer = draw_ellipses; }
|
||||
register_controller( kbd );
|
||||
|
||||
while(running) {
|
||||
|
||||
randomize_color(geo);
|
||||
|
||||
drawer(geo);
|
||||
|
||||
run(0.001);
|
||||
|
||||
}
|
||||
|
||||
quit();
|
||||
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
// freej script for a simple text scroller
|
||||
// it makes smart use of arrays as FIFO pipes
|
||||
// and the file_to_strings(filename) function
|
||||
// to read a text file into an array of strings
|
||||
|
||||
// (C)2005 Denis Jaromil Rojo - GNU GPL
|
||||
|
||||
W = 640;
|
||||
H = 480;
|
||||
|
||||
set_resolution(W, H);
|
||||
set_fps(25);
|
||||
|
||||
wordspacing = 5;
|
||||
|
||||
// setup the keyboard quit
|
||||
running = true;
|
||||
kbd = new KeyboardController();
|
||||
kbd.released_esc = function() { running = false; }
|
||||
register_controller( kbd );
|
||||
|
||||
// read a text file into an array
|
||||
words = file_to_strings("test.txt");
|
||||
|
||||
// debug
|
||||
echo ( words.length + " words read" );
|
||||
|
||||
idx = 0;
|
||||
// words.length property says how big it is
|
||||
// access words with words[0] words[1] and so on
|
||||
|
||||
|
||||
// make a black background
|
||||
/*
|
||||
background = new GeometryLayer();
|
||||
background.color(0x00000000);
|
||||
background.set_blit("alpha");
|
||||
background.set_blit_value(0.2);
|
||||
background.rectangle(0, 0, background.w(), background.h() );
|
||||
add_layer( background );
|
||||
*/
|
||||
|
||||
// setup the array of rendered words
|
||||
// each one is a TextLayer object
|
||||
scroll = new Array();
|
||||
|
||||
/*
|
||||
scroll[] is an Array object
|
||||
we will use it as a FIFO pipe, thru the push() and shift()
|
||||
methods of javascript arrays:
|
||||
|
||||
t(n): scroll.push( txt ) pushes in text from the right (here below)
|
||||
array scroll [ 0 ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] _/
|
||||
screen -> | <- bla - bla - bla - bla - bla - bla - | <- screen
|
||||
|
||||
t(n+1):
|
||||
[ 0 ] | <- [ 1 ] - [ 2 ] - [ 3 ] ...
|
||||
scroll.shift() returns scroll[0] (which we delete)
|
||||
|
||||
so let's go on...
|
||||
*/
|
||||
|
||||
function render_word(wrd) {
|
||||
|
||||
lay = new TextLayer();
|
||||
|
||||
lay.size( 50 ); // set the size
|
||||
|
||||
lay.print( wrd ); // print the string in the layer
|
||||
|
||||
|
||||
lay.set_fps(25);
|
||||
|
||||
lay.start();
|
||||
|
||||
|
||||
add_layer( lay ); // add it to the screen
|
||||
|
||||
lay.set_position( W, 400 ); // start from the right of the scree
|
||||
|
||||
|
||||
// lay.slide_position( 0 - lay.w() , 200, 2); // slide to the right
|
||||
|
||||
return lay;
|
||||
}
|
||||
|
||||
// MAIN
|
||||
|
||||
// create a new TextLayer with the word
|
||||
txt = render_word( words[idx] );
|
||||
|
||||
// append it as last element of the scroll[] array
|
||||
scroll.push( txt );
|
||||
|
||||
// advance the index of words
|
||||
idx++;
|
||||
|
||||
trigger = new TriggerController();
|
||||
register_controller( trigger );
|
||||
trigger.frame = function() {
|
||||
|
||||
|
||||
// slide all to the left
|
||||
for(i=0; i<scroll.length; i++) {
|
||||
echo("- " + i + " is at " + scroll[i].x() + "x" + scroll[i].y());
|
||||
|
||||
scroll[i].set_position( scroll[i].x() - 2, scroll[i].y() );
|
||||
echo("- " + i + " now at " + scroll[i].x() + "x" + scroll[i].y());
|
||||
|
||||
}
|
||||
|
||||
|
||||
// check if the leftmost is out of screen
|
||||
if( scroll[0].x() + scroll[0].w() < 0) {
|
||||
// pull it out from the array
|
||||
txt = scroll.shift();
|
||||
// remove it from the screen
|
||||
rem_layer( txt );
|
||||
// delete it
|
||||
delete txt;
|
||||
}
|
||||
|
||||
|
||||
// check if the rightmost all entered the screen
|
||||
rightmost = scroll[ scroll.length -1 ];
|
||||
if( rightmost.x() + rightmost.w() < W - wordspacing ) {
|
||||
// then we need a new one on the left
|
||||
|
||||
// create a new TextLayer with the word
|
||||
txt = render_word( words[idx] );
|
||||
|
||||
// append it as last element of the scroll[] array
|
||||
scroll.push( txt );
|
||||
|
||||
// advance the index
|
||||
idx++;
|
||||
}
|
||||
|
||||
// if the words are finished: stop
|
||||
if(idx >= words.length)
|
||||
this.frame = function() { };
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// video mouse test script
|
||||
|
||||
echo("VideoMouse");
|
||||
vm = new ViMoController("/dev/ttyUSB0");
|
||||
register_controller(vm);
|
||||
|
||||
// inner wheel
|
||||
vm.wheel_i = function(dir, hist) {
|
||||
var msg = "wi "+dir+" "+hist;
|
||||
echo(msg);
|
||||
}
|
||||
|
||||
// outer wheel
|
||||
vm.wheel_o = function(s, so) {
|
||||
echo("speed: " + s + " / " + so);
|
||||
}
|
||||
|
||||
// ye butts
|
||||
vm.button = function(button, state, mask, mask_old) {
|
||||
echo("VM buttom: " + button + " " + state + " " + mask + "/" + mask_old);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
// freej example script by jaromil
|
||||
// this simply draws i kind of star
|
||||
// it also shows the usage of keyboard controller
|
||||
// press 'q' to quit while running
|
||||
|
||||
W=800
|
||||
H=480
|
||||
|
||||
set_resolution(W,H);
|
||||
|
||||
// the Param class is stabilizing values between some limits
|
||||
// this can be used also to adapt the calibration at realtime...
|
||||
// so far a simple boundary is set on width/height on screen.
|
||||
|
||||
include("param.js");
|
||||
|
||||
param = new Array();
|
||||
// name, min_in, max_in, min_out, max_out, default
|
||||
param[0] = new Param(this, "px", 100, 150, 0, W, W/2);
|
||||
param[1] = new Param(this, "py", 100, 150, 0, H, H/2);
|
||||
param[2] = new Param(this, "pz", 100, 150, 0, H, H/2);
|
||||
|
||||
|
||||
|
||||
wii = new WiiController();
|
||||
|
||||
px = 0; py = 0; pz = 0;
|
||||
x = 0; y = 0; z = 0;
|
||||
|
||||
wii.acceleration = function(ax,ay,az) {
|
||||
if(px != ax) {
|
||||
splash = true;
|
||||
param[0].setValue(ax);
|
||||
param[1].setValue(ay);
|
||||
param[2].setValue(az);
|
||||
x = param[0].out_value;
|
||||
y = param[1].out_value;
|
||||
z = param[2].out_value;
|
||||
px = ax;
|
||||
}
|
||||
}
|
||||
|
||||
if(wii.connect())
|
||||
register_controller(wii);
|
||||
|
||||
// wii.toggle_accel();
|
||||
|
||||
|
||||
kbd = new KeyboardController();
|
||||
kbd.pressed_esc = function() { quit(); }
|
||||
kbd.released_q = function() { quit(); }
|
||||
register_controller( kbd );
|
||||
|
||||
geo = new GeometryLayer();
|
||||
geo.color(255,255,255,255);
|
||||
geo.set_blit("alpha");
|
||||
geo.set_blit_value(0.2);
|
||||
geo.set_fps();
|
||||
geo.activate(true);
|
||||
add_layer(geo);
|
||||
|
||||
//drawStar(geo,30,1);
|
||||
|
||||
srand();
|
||||
|
||||
framec = 24;
|
||||
|
||||
bang = new TriggerController();
|
||||
register_controller(bang);
|
||||
bang.frame = function() {
|
||||
if(framec>0) {
|
||||
framec--;
|
||||
} else
|
||||
if(splash) {
|
||||
// paint on geo
|
||||
geo.color(rand()%255, rand()%255, rand()%255, 0xff);
|
||||
geo.ellipse_fill(x,y,z,y);
|
||||
splash = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
// freej example script by jaromil
|
||||
// this simply draws i kind of star
|
||||
// it also shows the usage of keyboard controller
|
||||
// press 'q' to quit while running
|
||||
|
||||
include("param.js");
|
||||
|
||||
param = new Array();
|
||||
param[0] = new Param(this, "px", 100, 150, 0, 1024, 500);
|
||||
param[1] = new Param(this, "py", 100, 150, 0, 768, 500);
|
||||
param[2] = new Param(this, "pz", 100, 150, 0, 1000, 500);
|
||||
|
||||
|
||||
wii = new WiiController();
|
||||
|
||||
x = 100;
|
||||
y = 100;
|
||||
s = 30 / 0.383;
|
||||
|
||||
s2 = s;
|
||||
|
||||
PI = 3.141592654;
|
||||
c = PI * 2;
|
||||
o = -PI / 2;
|
||||
|
||||
wii.acceleration = function(ax,ay,az) {
|
||||
param[0].setValue(ax);
|
||||
param[1].setValue(ay);
|
||||
param[2].setValue(az);
|
||||
x = param[0].out_value;
|
||||
y = param[1].out_value;
|
||||
z = param[2].out_value;
|
||||
}
|
||||
|
||||
|
||||
function drawStar(lay, s_mul, s2_mul) {
|
||||
s = s_mul / 0.383;
|
||||
s2 = s / s2_mul;
|
||||
|
||||
var cx;
|
||||
for(cx=0; cx<10; cx++) {
|
||||
k = cx/10;
|
||||
kn = k+0.1;
|
||||
|
||||
x1 = x+s * Math.cos(o + k*c);
|
||||
y1 = y+s * Math.sin(o + k*c);
|
||||
x2 = x+s2 * Math.cos(o + kn*c);
|
||||
y2 = y+s2 * Math.sin(o + kn*c);
|
||||
x1 = Math.floor(x1);
|
||||
y1 = Math.floor(y1);
|
||||
x2 = Math.floor(x2);
|
||||
y2 = Math.floor(y2);
|
||||
|
||||
// debug("drawing star line:" + x1 + "," + y1 + " " + x2 + "," + y2);
|
||||
// lay.line( x.toPrecision()+s.toPrecision() * Math.cos(o + k*c),
|
||||
// y+s * Math.sin(o + k*c),
|
||||
// x+s2 * Math.cos(o + kn*c),
|
||||
// y+s2 * Math.sin(o + kn*c) );
|
||||
lay.aaline(x1, y1, x2, y2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(wii.connect())
|
||||
register_controller(wii);
|
||||
|
||||
wii.toggle_accel();
|
||||
|
||||
|
||||
kbd = new KeyboardController();
|
||||
kbd.pressed_esc = function() { quit(); }
|
||||
kbd.released_q = function() { quit(); }
|
||||
register_controller( kbd );
|
||||
|
||||
geo = new GeometryLayer();
|
||||
geo.color(255,255,255,255);
|
||||
geo.set_blit("alpha");
|
||||
geo.set_blit_value(0.1);
|
||||
geo.set_fps();
|
||||
geo.start();
|
||||
geo.activate(true);
|
||||
add_layer(geo);
|
||||
|
||||
//drawStar(geo,30,1);
|
||||
cc = 1;
|
||||
|
||||
srand();
|
||||
|
||||
bang = new TriggerController();
|
||||
|
||||
register_controller(bang);
|
||||
|
||||
|
||||
bang.frame = function() {
|
||||
|
||||
cc += 0.05;
|
||||
|
||||
geo.color(rand()%255, rand()%255, rand()%255, 0xff);
|
||||
drawStar(geo, 30, Math.sin(cc));
|
||||
|
||||
if(cc>4.0) {
|
||||
cc = 1;
|
||||
srand();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
// sample script for wiimote controller
|
||||
|
||||
|
||||
|
||||
kbd = new KeyboardController();
|
||||
register_controller(kbd);
|
||||
|
||||
kbd.released_q = function() { quit(); }
|
||||
|
||||
kbd.released_1 = function() { wii.toggle_led(1); }
|
||||
kbd.released_2 = function() { wii.toggle_led(2); }
|
||||
kbd.released_3 = function() { wii.toggle_led(3); }
|
||||
kbd.released_4 = function() { wii.toggle_led(4); }
|
||||
|
||||
wii = new WiiController();
|
||||
|
||||
wii.geo = new GeometryLayer(300,100);
|
||||
wii.geo.set_position(0,0);
|
||||
add_layer(wii.geo);
|
||||
|
||||
echo("connecting wii");
|
||||
wii.connect();
|
||||
|
||||
register_controller(wii);
|
||||
|
||||
wii.acceleration = function(x,y,z) {
|
||||
draw_accel(this.geo,x,y,z);
|
||||
}
|
||||
|
||||
wii.toggle_accel(true);
|
||||
|
||||
function draw_accel(geo, x,y,z) {
|
||||
// echo("accel x" + x + " y " + y + " z " + z);
|
||||
geo.color(0,0,0,0);
|
||||
geo.clear();
|
||||
// geo.rectangle_fill(0,0,300,300);
|
||||
geo.color(255,0,0);
|
||||
geo.hline(0,x*2,10);
|
||||
geo.hline(0,x*2,11);
|
||||
geo.hline(0,x*2,12);
|
||||
|
||||
geo.color(0,255,0);
|
||||
geo.hline(0,y*2,20);
|
||||
geo.hline(0,y*2,21);
|
||||
geo.hline(0,y*2,22);
|
||||
|
||||
geo.color(0,0,255);
|
||||
geo.hline(0,z*2,30);
|
||||
geo.hline(0,z*2,31);
|
||||
geo.hline(0,z*2,32);
|
||||
}
|
||||
|
||||
function butt(b) {
|
||||
echo("wii button " + b);
|
||||
}
|
||||
|
||||
// echo("wii script finish 1");
|
||||
|
||||
// wii2 = new WiiController();
|
||||
// echo("connecting wii2");
|
||||
// wii2.connect("00:19:1D:66:91:D3");
|
||||
|
||||
// echo("connected wii2");
|
||||
// controllers.add(wii2);
|
||||
// wii2.toggle_accel(true);
|
||||
// wii2.toggle_buttons(true);
|
||||
|
||||
// wii2.acceleration = function(x,y,z) {
|
||||
// draw_accel(this.geo,x,y,z);
|
||||
// }
|
||||
|
||||
// wii2.button = function(button_no, state, mask, old_mask) {
|
||||
// echo("wii2 button " + button_no + " " + state + " " + mask + " " + old_mask);
|
||||
// }
|
||||
|
||||
// wii2.geo = new GeometryLayer(300,100);
|
||||
// wii2.geo.set_position(0,100);
|
||||
// layers.add(wii2.geo);
|
||||
|
||||
|
||||
function wiiup(w) {
|
||||
w.active(true);
|
||||
w.toggle_accel(true);
|
||||
w.toggle_buttons(true);
|
||||
}
|
||||
|
||||
//echo("wii2 script finish 2");
|
||||
/*
|
||||
JSCall("button_1", 0, NULL, &res);
|
||||
JSCall("button_2", 0, NULL, &res);
|
||||
JSCall("button_A", 0, NULL, &res);
|
||||
JSCall("button_B", 0, NULL, &res);
|
||||
JSCall("button_minus", 0, NULL, &res);
|
||||
JSCall("button_plus", 0, NULL, &res);
|
||||
JSCall("button_home", 0, NULL, &res);
|
||||
JSCall("button_left", 0, NULL, &res);
|
||||
JSCall("button_right", 0, NULL, &res);
|
||||
JSCall("button_up", 0, NULL, &res);
|
||||
JSCall("button_down", 0, NULL, &res);
|
||||
*/
|
||||
|
||||
/*
|
||||
JSCall("acceleration", 3, "uuu",
|
||||
input->accel.x, input->accel.y, input->accel.z );
|
||||
*/
|
||||
|
||||
/*
|
||||
[F] JSCall calling method released_w()
|
||||
[*] WII test
|
||||
[F] 592:context_js.cpp:include_javascript
|
||||
[F] 294:jsparser.cpp:open
|
||||
[*] int JsParser::open(JSContext*, JSObject*, const char*) eval: 0x1023e3c8
|
||||
[F] 52:wiimote_ctrl.cpp:js_wii_ctrl_constructor
|
||||
[F] Controller::Controller() this=0x10296808
|
||||
[*] WiiMote controller attached
|
||||
[*] connecting wii
|
||||
[F] 81:wiimote_ctrl.cpp:js_wii_ctrl_connect argc: 0
|
||||
. Detecting WiiMote (press A+B on it to handshake) << inv. in console
|
||||
Wiimote: Connecting to 00:00:00:00:00:00...
|
||||
Wiimote: Allocated command socket 5.
|
||||
|
||||
HANG HERE
|
||||
|
||||
Wiimote: Command connection failed (-1).
|
||||
Wiimote: init
|
||||
Wiimote: Request STATUS
|
||||
Wiimote: Command write failed: -1 (expected 3)
|
||||
Wiimote: Set MODE 0x37 CONTINUOUS
|
||||
Wiimote: Command write failed: -1 (expected 4)
|
||||
Wiimote: Turning ON IR
|
||||
Wiimote: Command write failed: -1 (expected 3)
|
||||
Wiimote: Set LEDs 0x60
|
||||
Wiimote: Command write failed: -1 (expected 3)
|
||||
[*] connected wii
|
||||
[F] 185:context_js.cpp:register_controller
|
||||
[F] 410:context.cpp:register_controller
|
||||
. registered WiiCtrl controller
|
||||
[F] JSvalcmp: 0x10262a48 / (nil)
|
||||
[*] wii script finish
|
||||
[F] open evalres: 1
|
||||
[F] JS: include scripts/wiimote.js
|
||||
Wiimote: error receiving report: -1 (max 32)
|
||||
[!] error processing wiimote reports
|
||||
Wiimote: error receiving report: -1 (max 32)
|
||||
.....
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,12 @@
|
||||
// this script grabs the desktop
|
||||
// discover your desktop id number using the command xwininfo from terminal
|
||||
// then click on your desktop background and read the information
|
||||
|
||||
grab = new XGrabLayer();
|
||||
grab.open(0x85);
|
||||
grab.set_fps(25);
|
||||
grab.activate(true);
|
||||
grab.start();
|
||||
|
||||
add_layer(grab);
|
||||
|
||||
Reference in New Issue
Block a user