Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
n.a.y.a.d
n.a.y.a.d's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
fun with letters & jMyron
[2 Replies]
09-Jan-2012 02:14 PM
Forum:
Contributed Library Questions
Hey!
I did this sketch where, using the webcam, you can interact with the form of the letters.
Does anyone have an idea about how I could do to make the points go bigger or smaller depending about who near I am from the webcam?
thanks!
import processing.opengl.*;
import geomerative.*;
import controlP5.*;
import JMyron.*;
String textTyped = "what's_up?_world";
String [] Sentence = splitTokens(textTyped, "_");
splitLetters[] words = new splitLetters [Sentence.length];
ControlP5 controlP5;
ControlWindow controlWindow;
JMyron m;
public float MYSIZE = 220;
int ligne = 0;
int counter = 0;
float chaos = 0;
void setup() {
println(Sentence.length);
size(1080, 1920, OPENGL);
smooth();
frameRate(30);
m = new JMyron(); //make a new instance of the object
m.start(320, 240); //start a capture at 320x240
m.trackColor(255, 255, 255, 256*3-100); //track white
m.update();
m.adaptivity(10);
m.adapt(); // immediately take a snapshot of the background for differencing
println("Myron " + m.version());
rectMode(CENTER);
stroke(255);
noFill();
RG.init(this);
RFont tmpFont = new RFont("FreeSans.ttf", round(MYSIZE), RFont.LEFT);
for (int k = 0; k < Sentence.length; k++) {
words[k] = new splitLetters(Sentence[k], tmpFont);
words[k].mySegmentLength();
}
}
void draw() {
background(255);
noSmooth();
smooth();
m.update(); //update the camera view
fill(30, 100, 0);
int[][][] mP = m.globPixels();
int numDiffPixels = 0;
if (mP.length > 0) {
for ( int i = 0; i < mP.length; i++ ) {
if (mP[i] != null) {
numDiffPixels += mP[i].length;
}
}
chaos = map(numDiffPixels, 0, width * height * 0.02, 0, 1);
}
else {
chaos = 0;
}
println(chaos);
for (int k = 0; k < Sentence.length; k++) {
words[k].mySplit(k, chaos);
}
}
class splitLetters {
RFont font;
String mySentence;
float transX = 300;
public float MYSIZE = 220;
// how fast and wild will the points be
int randDispl = 1000;
int segmentation = 6;
float x = 0;
float y = 0;
RGroup grp;
RPoint[] pnts;
PVector[] randVectors;
void mySegmentLength() {
RCommand.setSegmentLength(segmentation);
}
splitLetters (String _mySentence, RFont f) {
font = f;
mySentence = _mySentence;
grp = font.toGroup(mySentence);
grp = grp.toPolygonGroup();
pnts = grp.getPoints();
randVectors = new PVector[pnts.length];
for (int i = 0; i < randVectors.length; i++) {
randVectors[i] = new PVector(random(-randDispl, randDispl), random(-randDispl, randDispl));
}
}
void mySplit (int textDist, float trans) {
fill(0);
noStroke();
float diameter = 15;
if (mySentence.length() > 0) {
pushMatrix();
translate(25, 550 * textDist + 500); // calculate Sentence.length to fontsize
for (int j = 0; j < pnts.length; j++ ) {
ellipse(lerp(pnts[j].x, randVectors[j].x, abs(trans)), lerp(pnts[j].y, randVectors[j].y, abs(trans)), diameter, diameter);
}
popMatrix();
}
}
}
«Prev
Next »
Moderate user : n.a.y.a.d
Forum