Examples
Example 1: Turn the light on
// Turn the light on with white
cube?.turnLightOn( 'white' );
OpenProcessing Sample: Turn Light On
Example 2: Play MIDI melody
// Play sequence C-D-E
cube?.playMelody( [
{ note: 0x3C, duration: 0x1E },
{ note: 0x3E, duration: 0x1E },
{ note: 0x40, duration: 0x1E }
] );
OpenProcessing Sample: Play MIDI melody
Example 3: Interaction with mouse X.
// Keep on gazing at mouse point
for( const cube of connectedCubeArray ){
const x = Math.floor(mouseX * 300 / windowWidth + 200);
const y = 144;
const speed = 115;
cube?.turnToXY( x, y, speed );
}
OpenProcessing Sample: Keep on gazing at mouse point
Example 4: Interaction with 2 Cubes.
4-1: Keep on gazing at the othre Cube
// Keep on gazing at the othre Cube
const speed = 115;
cubeP?.turnToCube( cubeQ, speed );
OpenProcessing Sample: Keep on gazing at the other Cube
4-2: Keep on chasing the othre Cube
// Keep on chasing the othre Cube
const moveType = P5tCube.moveTypeId.withoutBack;
const speed = 80;
cubeP?.moveToCube( cubeQ, speed, moveType );
OpenProcessing Sample: Keep on chasing the other Cube
Example 5: Get color from ColorTileMat.
// Set background color with touched colored tile on mat
const color = P5tId.ColorTileMat.getTileColor(cube?.x, cube?.y);
background( color );
OpenProcessing Sample: Change background color with touched mat color
Example 6: Random tile move on SimpleMat.
const targetMat = P5tId.SimpleTileMat;
// const targetMat = P5tId.ColorTileMat; // can apply for ColorTileMat
const columnRand = Math.floor( Math.random() * targetMat.matrixColumns);
const rowRand = Math.floor( Math.random() * targetMat.matrixRows);
// Move to random tile.
cube?.moveTo(targetMat.getTileCenter(rowRand, columnRand), 80);
OpenProcessing Sample: Move random tiles on TileMat
Press Space Key
to move after connection.
Example 7: Move to start position on RingMat.
cubeP?.moveTo({
x: P5tId.RingMat.startPointGreenSideX,
y: P5tId.RingMat.startPointGreenSideY,
angle: -Math.PI / 2,
angleType: 0
}, 80);
cubeQ?.moveTo({
x: P5tId.RingMat.startPointBlueSideX,
y: P5tId.RingMat.startPointBlueSideY,
angle: Math.PI / 2,
angleType: 0
}, 80);
OpenProcessing Sample: Move to start position on RingMat.
Press Space Key
to move after connection.