Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all 2896 articles
Browse latest View live

Target VM failed to initialize ?

$
0
0

I tried to run a simple sound example:

import processing.sound.*; WhiteNoise noise; void setup() { size(640, 360); background(255); // Create the noise generator noise = new WhiteNoise(this); noise.play();}
void draw() {}

But console says:

# A fatal error has been detected by the Java Runtime Environment: # # Internal Error (0x20474343), pid=8820, tid=0x0000000000001994 # # JRE version: Java(TM) SE Runtime Environment (8.0_102-b14) (build 1.8.0_102-b14) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.102-b14 mixed mode windows-amd64 compressed oops) # Problematic frame: # C [KERNELBASE.dll+0x17788] # # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows # # An error report file with more information is saved as: # R:\processing-3.2.1\hs_err_pid8820.log # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # Could not run the sketch (Target VM failed to initialize). For more information, read revisions.txt and Help ? Troubleshooting.

Hay to fix it ? I use Processing 3.2.1 on WIN10 64bit


Textual networks

$
0
0

I am new to Processing. I have been using Gephi and related applications to analyze networks of metaphors. My method has been to create a CSV of related metaphors. Each line starts with the leading metaphor followed by related metaphors:

"main metaphor","metaphor one","metaphor two","metaphor three","metaphor five"

I may have over 1,000 lines of uneven length, some longer and some shorter. When I import the file into Gephi it creates a network of metaphors that I can analyse. How can I analyze metaphors and text in a similar way with Processing?

Can someone point me to examples of something similar? Thanks!

How to change a loop using the G4P_button ?

$
0
0

Good morning everyone.

It is the first time I come in this place. Also, because my mother tongue is not english, I will try to explain my problem as clearly as possible.

I have difficulties to understand how the G4P button is working. My program has a loop "for" which create a curve. Now, I must create a button using the G4P library which change the formula of my curve, as soon as the user click on it. I am thinking about using a if(condition){}, like :

if(button == Clicked){
  formula1;
}else{
 formula2;
}

Something like that... But it does not work and I have no idea how to call the button into my "if condition". Is that clear ?

Here is my code, I let you try it out :

// fdm_2016_trans-geometrique_tp2

// Exemple similaire sur Processing : https://processing.org/examples/sinewave.html
// possibilité de dessiner avec "line" ou "point"

import g4p_controls.*; // importation de la librarie g4p
GSlider sAmpli;
GSlider sPhase;
GSlider sFreq;
GButton sincos;

float temps; // (ou période) En pixel et non en sec. Combien de pixel avant que la vague se répète ?
float ampli; // hauteur de la "vague"
float w; // vitesse angulaire : détermine le nombre de cycles/période dans le temps
float phase; // dans lequel figurera l'angle
float x, y;
float xc, yc;
boolean b;

void setup(){
  size(600, 400);

  sAmpli = new GSlider(this, 120, 265, 200, 20, 12); // slider : emplacement, coord X, coord Y, taille X, taille Y, épaisseur
  sAmpli.setLimits(50, 0, 100); // plage de valeur : valeur par défaut, minimum, maximum
  sAmpli.addEventHandler(this, "slider_change"); // écouteur d’événement : emplacement, fonction

  sPhase = new GSlider(this, 120, 305, 200, 20, 12); // slider : emplacement, coord X, coord Y, taille X, taille Y, épaisseur
  sPhase.setLimits(0, 0, 360); // plage de valeur : valeur par défaut, minimum, maximum
  sPhase.addEventHandler(this, "slider_change"); // écouteur d’événement : emplacement, fonction

  sFreq = new GSlider(this, 120, 345, 200, 20, 12); // slider : emplacement, coord X, coord Y, taille X, taille Y, épaisseur
  sFreq.setLimits(width/2, 0, width); // plage de valeur : valeur par défaut, minimum, maximum
  sFreq.addEventHandler(this, "slider_change"); // écouteur d’événement : emplacement, fonction
}

void draw(){
  background(240);

  strokeWeight(1);
  line(0, 100, width, 100);

  temps = sFreq.getValueI(); // fréquence
  ampli = sAmpli.getValueI();
  w = (2*(PI))/temps;
  phase = (radians(sPhase.getValueI()));
  x = 0; // incrémentation
  y = 0; // formule
  yc = 0;

  for(x = 0 ; x <= width ; x++){
    y = ampli*sin(w*x+phase); // a*sin(w.t+ph);
    yc = ampli*cos(w*x+phase); // a*cos(w.t+ph);
    // point(x, y);
    stroke(0, 0, 0);
    ellipse(x, 100+y, 1, 1); // utilisation de l'ellipse pour gérer la position Y de la courbe
    stroke(255, 0, 0);
    ellipse(x, 100+yc, 1, 1); // utilisation de l'ellipse pour gérer la position Y de la courbe
  }

  // Ligne de séparation
  stroke(0);
  strokeWeight(4);
  line(0, height/2, width, height/2);

  // Texte Commande + Formule
  fill(0);
  textSize(16);
  text("Commandes", 40, height/2 + 40);
  text("Formule : y(t) = a.sin(w.t+ph)", width/2 + 40, height/2 + 40);

  // Texte Slider
  textSize(12); // taille du texte
  text("Amplitude", 40, 279); // text("valeur", coord X, coord Y);
  text("Phase", 40, 319); // text("valeur", coord X, coord Y);
  text("Fréquence", 40, 359); // text("valeur", coord X, coord Y);

  // Texte valeur slider
  text(sAmpli.getValueI()+"px", 335, 279);
  text(sPhase.getValueI()+"°", 335, 319);
  text(sFreq.getValueI()+"px", 335, 359);

  sincos = new GButton(this, 440, 300, 90, 30, "Sin / Cos"); // slider : emplacement, coord X, coord Y, taille X, taille Y, épaisseur
  sincos.addEventHandler(this, "button_change");

}

void mouseClicked(){

}

public void slider_change(GSlider s, GEvent e) {
  // les paramètres présent ici changeront lorsque les valeurs du slider sont modifiées
  // GSlider s lit les données de tous les sliders présent dans le code
}

public void button_change(GButton b, GEvent e) {

}

Important : I tried the following code... but the change is only temporary. It only last when the user click on the button.

public void button_change(GButton b, GEvent e) {
  // les paramètres présent ici changeront lorsque le bouton est appelé
   if(b == sincos && e == GEvent.CLICKED){
       for(x = 0 ; x <= width ; x++){
          yc = ampli*cos(w*x+phase); // a*cos(w.t+ph);
          // point(x, y);
          stroke(0, 0, 0);
          ellipse(x, 100+yc, 1, 1); // utilisation de l'ellipse pour gérer la position Y de la courbe

        }
   }else{
     for(x = 0 ; x <= width ; x++){
        y = ampli*sin(w*x+phase); // a*sin(w.t+ph);
        // point(x, y);
        stroke(0, 0, 0);
        ellipse(x, 100+y, 1, 1); // utilisation de l'ellipse pour gérer la position Y de la courbe
      }
  }
}

Changing sound-value with camera tracking?

$
0
0

Hey guys, so I have this code. You can track two different colors by choosing them with right-click. As you can see I also got two sliders. One of them controls frequencies, the other controls the volume. Now I want to change the values by the color tracked objects. Lets say if I move my yellow object vertically, it changes the frequencies and if move my pink object horizontally, I want to change the volume with it. Does someone have any ideas on how to realise this? (I hope I explained everythin well).

best regards

//Importing librarys
import controlP5.*;
import ddf.minim.*;
import ddf.minim.ugens.*;
import processing.video.*;

//Declaration
ControlP5      cp5;
Minim          minim;
AudioOutput    out;
Oscil          wave;
Frequency      currentFreq;
Slider         sliderHertz;
Slider         sliderVolume;
Capture        video;

final int TOLERANCE = 20;

float XRc = 0;// XY coordinate of the center of the first target
float YRc = 0;
float XRh = 0;// XY coordinate of the center of the second target
float YRh = 0;

int ii=0; //Mouse click counter
int Hertz = 150; //Hertz-Slider
int Volume = 50; //Volume-Slider

color trackColor; //The first color is the center of the robot
color trackColor2; //The second color is the head of the robot

void setup() {

size(640,680);
video = new Capture(this,640,480);
video.start();

trackColor = color(255,0,0);
trackColor2 = color(255,0,0);
smooth();

//Hertz-Slider
cp5 = new ControlP5(this);
sliderHertz = cp5.addSlider("Hertz").setPosition(265,495).setRange(50,400);

//Volume-Slider
cp5 = new ControlP5(this);
sliderVolume = cp5.addSlider("Volume").setPosition(445,495).setRange(0,30);

// Initializating minim and out
minim = new Minim(this);
out   = minim.getLineOut();

currentFreq = Frequency.ofHertz( 50 );
wave = new Oscil( currentFreq, 0.6f, Waves.SINE );

wave.patch( out );
}

void draw() {
background( 0, 0, 0 );
stroke( 255, 255, 255 );

if (video.available()) {
    video.read();
}

//Slidervalue and Text
text( "Frequenz in Hertz: " + sliderHertz.getValue(), 35, 505 );

  wave.setFrequency( Frequency.ofHertz( sliderHertz.getValue() ) );

  wave.setAmplitude(sliderVolume.getValue());


 //Sinusfunction
  for( int i = 0; i < out.bufferSize() - 1; i++ )
  {
    float x1  =  map( i, 0, out.bufferSize(), 0, width );
    line( x1, 595 + out.left.get(i)*50, x1, 595 + out.left.get(i+1)*50);
  }


video.loadPixels();
image(video,0,0);

  float r2 = red(trackColor);
  float g2 = green(trackColor);
  float b2 = blue(trackColor);

  float r3 = red(trackColor2);
  float g3 = green(trackColor2);
  float b3 = blue(trackColor2);


  int somme_x = 0, somme_y = 0; // Calculating center
  int compteur = 0;

  int somme_x2 = 0, somme_y2 = 0; // Calculating center
  int compteur2 = 0;

  int somme_x3 = 0, somme_y3 = 0; // Calculating center
  int compteur3 = 0;

  int somme_x4 = 0, somme_y4 = 0; // Calculating center
  int compteur4 = 0;


  for(int x = 0; x < video.width; x++) {
    for(int y = 0; y < video.height; y++) {

      int currentLoc = x + y*video.width;
      color currentColor = video.pixels[currentLoc];

      float r1 = red(currentColor);
      float g1 = green(currentColor);
      float b1 = blue(currentColor);


      if(dist(r1,g1,b1,r2,g2,b2) < TOLERANCE) {
         somme_x += x;
         somme_y += y;
        compteur++;
      }

      else if(compteur > 0) {
        XRc = somme_x / compteur;
        YRc = somme_y / compteur;
      }


      if(dist(r1,g1,b1,r3,g3,b3) < TOLERANCE) {
         somme_x2 += x;
         somme_y2 += y;
        compteur2++;
      }

      else if(compteur2 > 0) {
        XRh = somme_x2 / compteur2;
        YRh = somme_y2 / compteur2;
      }

  }
  }




  if(XRc != 0 || YRc != 0) { // Draw a circle at the first target
    fill(trackColor);
    strokeWeight(0.05);
    stroke(0);
    ellipse(XRc,YRc,20,20);
  }


  if(XRh != 0 || YRh != 0) {// Draw a circle at the second target
    fill(trackColor2);
    strokeWeight(0.05);
    stroke(0);
    ellipse(XRh,YRh,20,20);
  }


}
void mousePressed() {
  if (mousePressed && (mouseButton == RIGHT)) { // Save color where the mouse is clicked in trackColor variable
  if(ii==0){

    if (mouseY>480){mouseY=0;mouseX=0;}
  int loc = mouseX + mouseY*video.width;

  trackColor = video.pixels[loc];
ii=1;
}
  else if(ii==1){
    if (mouseY>480){mouseY=0;mouseX=0;}
  int loc2 = mouseX + mouseY*video.width;
  trackColor2 = video.pixels[loc2];
ii=2;
}
  }
}

video warping with gsvideo

$
0
0

Hi, all!

I'm trying to warp a video signal, in order of making a section of it (inside 4 selected points/vectors) expand automatically to fit exactly the width and height of the processing screen image. The portion of the video inside the four vectors area should distort in correspondence of the deformation of that given area. In addition, I need to use gsvideo, dued to the reason that I am working with processing 1.5.1 in mac and I'm not able to install quicktime. Why processing 1.5.1? Because I'm running artoolkit library for augmented reality and only works for me in this old version of processing. Any idea or suggestion would be very welcome!

moving object(words)

$
0
0

hello, I'm studying for my project with the leap motion and processing. It's my first time to do programming, I'm trying to mix up some of sketches i found and to change little bit. based on https://www.openprocessing.org/collection/2560

whatever, Here is my Question.

  1. how to change WordPaint axis? It moves to the left around the edges. 1-1. how to make to move WordPaint automatically on Y axis only? (wants to move like BBQ)
  2. Wants to limit space. move inside on 'size'


   import peasy.*;
   import com.leapmotion.leap.*;

   int width = 400;
   int height = 400;

float turns = radians(360);
float xRotation = 0;
float yRotation = 0;
float zRotation = 0;
Controller leap = new Controller();
// variables =============================================

// Camera
PeasyCam cam;

int bufferSize = 1256;
int bufferWritePosition = 0;
String[] buffer = new String[bufferSize];

int factorBetweenBoxes = 3;
int factorBetweenLetters = 30;
float angle = 0.0001;
float angleAdd = 0.009;
float jitter;

// letterSpacing: use -6 for 'W' to put more space after the W
int letterSpacing = 0;

// functions =============================================

void setup () {

  size (1000, 1000, P3D);
  cam = new PeasyCam(this, 2000.0 );
  cam.pan(170, 400);


  noSmooth();
  fill(color(255, 255, 255));
  stroke(color(25,25,0));
}

void draw () {
  Frame frame = leap.frame();
  Hand hand = frame.hands().frontmost();
  if ( hand.isValid() )
  {
    InteractionBox box = frame.interactionBox();
    Vector controlPosition = hand.palmPosition();
    Vector normalizedPosition = box.normalizePoint(controlPosition, false);
    xRotation = turns * normalizedPosition.getX();
    yRotation = turns * (1 - normalizedPosition.getY());
    zRotation = turns * (1 - normalizedPosition.getZ());
  }

  background(0);

  rotateX(zRotation);
  rotateY(xRotation);
  rotateZ(yRotation);
  translate(width/2, height/8);
   if (second() % 2 == 0) {
    jitter = random(-0.0001, 0.0001);
  }
  angle = angle + jitter;
  float c = cos(angle/2);
  translate(width/2, height/2);
  rotate(c);

  WordPaint("I HATE YOU");
  angle += angleAdd/5;
}

void keyPressed() {
  if (key == CODED) {
    if (keyCode == UP) {
      factorBetweenBoxes-=1;
    } else if (keyCode == DOWN) {
      factorBetweenBoxes+=1;
    }
    if (keyCode == LEFT) {
      factorBetweenLetters-=1;
    } else if (keyCode == RIGHT) {
      factorBetweenLetters+=1;
    }
  } else {
    // not coded
    if (key == '1') {
      if (angleAdd==0.0) {
        angleAdd=0.009;
      } else {
        angleAdd=0.0;
      };
    } // SPACE
    else if (key == 'm') {
      angleAdd=0.1;
    }
  } // else not coded
} // func

void WordPaint(String InputWordOfFunction) {
  final int BoxWidth=3;
  letterSpacing=0;
  for (int i = 0; i < InputWordOfFunction.length(); i = i+1) {
    buffer = new String[bufferSize];
    bufferWritePosition=0;
    letterSpacing=0;
    keyPaintHelper(InputWordOfFunction.charAt(i));
    for (int  j = 0; j < bufferWritePosition; j = j+1) {
      for (int  k = 0; k < buffer[j].length(); k = k+1) {
        if (buffer[j].charAt(k) == '*') {
          pushMatrix();
          translate((j*factorBetweenBoxes)+(i*factorBetweenLetters)-100+letterSpacing,
            300-(k*factorBetweenBoxes)+100,
            -1);
          // rotateY(0.3); //  ;-)
          box (BoxWidth, BoxWidth, BoxWidth+BoxWidth+BoxWidth);
          popMatrix();
        }
      }
    }
  }
}

void keyPaintHelper(char InputKeyOfFunction) {
  char k = Character.toUpperCase(InputKeyOfFunction);
  letterSpacing=0;
  switch(k) {
  case 'A':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******  ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "   *   * ";
      buffer[bufferWritePosition + 3] = "   *   * ";
      buffer[bufferWritePosition + 4] = " ******* ";
      buffer[bufferWritePosition + 5] = " ******  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'B':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " *  *  * ";
      buffer[bufferWritePosition + 3] = " *  *  * ";
      buffer[bufferWritePosition + 4] = " ******* ";
      buffer[bufferWritePosition + 5] = "  ** **  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'C':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "  *****  ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " *     * ";
      buffer[bufferWritePosition + 3] = " *     * ";
      buffer[bufferWritePosition + 4] = " *     * ";
      buffer[bufferWritePosition + 5] = "  *   *  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'D':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " *     * ";
      buffer[bufferWritePosition + 3] = " **   ** ";
      buffer[bufferWritePosition + 4] = "  *****  ";
      buffer[bufferWritePosition + 5] = "   ***   ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'E':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " *  *  * ";
      buffer[bufferWritePosition + 3] = " *  *  * ";
      buffer[bufferWritePosition + 4] = " *  *  * ";
      buffer[bufferWritePosition + 5] = " *     * ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'F':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "    *  * ";
      buffer[bufferWritePosition + 3] = "    *  * ";
      buffer[bufferWritePosition + 4] = "    *  * ";
      buffer[bufferWritePosition + 5] = "       * ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'G':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "  *****  ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " ** *  * ";
      buffer[bufferWritePosition + 3] = " ** *  * ";
      buffer[bufferWritePosition + 4] = " **** ** ";
      buffer[bufferWritePosition + 5] = " **** *  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'H':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "    *    ";
      buffer[bufferWritePosition + 3] = "    *    ";
      buffer[bufferWritePosition + 4] = " ******* ";
      buffer[bufferWritePosition + 5] = " ******* ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'I':
    if (thereAreEnoughSlots(6)) {
      buffer[bufferWritePosition + 0] = "         ";
      buffer[bufferWritePosition + 1] = " *     * ";
      buffer[bufferWritePosition + 2] = " ******* ";
      buffer[bufferWritePosition + 3] = " ******* ";
      buffer[bufferWritePosition + 4] = " *     * ";
      buffer[bufferWritePosition + 5] = "         ";
      bufferWritePosition += 6;
    }
    break;
  case 'J':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "  **     ";
      buffer[bufferWritePosition + 1] = " ***     ";
      buffer[bufferWritePosition + 2] = " *     * ";
      buffer[bufferWritePosition + 3] = " ******* ";
      buffer[bufferWritePosition + 4] = "  ****** ";
      buffer[bufferWritePosition + 5] = "       * ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'K':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "   ***   ";
      buffer[bufferWritePosition + 3] = "  ** **  ";
      buffer[bufferWritePosition + 4] = " **   ** ";
      buffer[bufferWritePosition + 5] = " *     * ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'L':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " *       ";
      buffer[bufferWritePosition + 3] = " *       ";
      buffer[bufferWritePosition + 4] = " *       ";
      buffer[bufferWritePosition + 5] = " *       ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'M':
    if (thereAreEnoughSlots(9)) {
      buffer[bufferWritePosition + 0] = " ******  ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "    **** ";
      buffer[bufferWritePosition + 3] = "  ****   ";
      buffer[bufferWritePosition + 4] = "  ****   ";
      buffer[bufferWritePosition + 5] = "    **** ";
      buffer[bufferWritePosition + 6] = " ******* ";
      buffer[bufferWritePosition + 7] = " ******  ";
      buffer[bufferWritePosition + 8] = "         ";
      bufferWritePosition += 9;
    }
    break;
  case 'N':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "    **   ";
      buffer[bufferWritePosition + 3] = "   **    ";
      buffer[bufferWritePosition + 4] = " ******* ";
      buffer[bufferWritePosition + 5] = " ******* ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'O':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "  *****  ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " *     * ";
      buffer[bufferWritePosition + 3] = " *     * ";
      buffer[bufferWritePosition + 4] = " ******* ";
      buffer[bufferWritePosition + 5] = "  *****  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'P':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "    *  * ";
      buffer[bufferWritePosition + 3] = "    *  * ";
      buffer[bufferWritePosition + 4] = "    **** ";
      buffer[bufferWritePosition + 5] = "     **  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'Q':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "  *****  ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " **    * ";
      buffer[bufferWritePosition + 3] = " **    * ";
      buffer[bufferWritePosition + 4] = "******** ";
      buffer[bufferWritePosition + 5] = "* *****  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'R':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "   **  * ";
      buffer[bufferWritePosition + 3] = "  ***  * ";
      buffer[bufferWritePosition + 4] = " ** **** ";
      buffer[bufferWritePosition + 5] = " *   **  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'S':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "  ** **  ";
      buffer[bufferWritePosition + 1] = " ** **** ";
      buffer[bufferWritePosition + 2] = " *  *  * ";
      buffer[bufferWritePosition + 3] = " *  *  * ";
      buffer[bufferWritePosition + 4] = " **** ** ";
      buffer[bufferWritePosition + 5] = "  ** **  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'T':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "       * ";
      buffer[bufferWritePosition + 1] = "       * ";
      buffer[bufferWritePosition + 2] = " ******* ";
      buffer[bufferWritePosition + 3] = " ******* ";
      buffer[bufferWritePosition + 4] = "       * ";
      buffer[bufferWritePosition + 5] = "       * ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'U':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "  ****** ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " *       ";
      buffer[bufferWritePosition + 3] = " *       ";
      buffer[bufferWritePosition + 4] = " ******* ";
      buffer[bufferWritePosition + 5] = "  ****** ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'V':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "   ***** ";
      buffer[bufferWritePosition + 1] = "  ****** ";
      buffer[bufferWritePosition + 2] = " **      ";
      buffer[bufferWritePosition + 3] = " **      ";
      buffer[bufferWritePosition + 4] = "  ****** ";
      buffer[bufferWritePosition + 5] = "   ***** ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'W':
    letterSpacing=-6 ; // -6 for 'W'
    if (thereAreEnoughSlots(9)) {
      buffer[bufferWritePosition + 0] = "  ****** ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " **      ";
      buffer[bufferWritePosition + 3] = "  ****   ";
      buffer[bufferWritePosition + 4] = "  ****   ";
      buffer[bufferWritePosition + 5] = " **      ";
      buffer[bufferWritePosition + 6] = " ******* ";
      buffer[bufferWritePosition + 7] = "  ****** ";
      buffer[bufferWritePosition + 8] = "         ";
      bufferWritePosition += 9;
    }
    break;
  case 'X':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " **   ** ";
      buffer[bufferWritePosition + 1] = " *** *** ";
      buffer[bufferWritePosition + 2] = "   ***   ";
      buffer[bufferWritePosition + 3] = "   ***   ";
      buffer[bufferWritePosition + 4] = " *** *** ";
      buffer[bufferWritePosition + 5] = " **   ** ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'Y':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "     *** ";
      buffer[bufferWritePosition + 1] = "    **** ";
      buffer[bufferWritePosition + 2] = " ****    ";
      buffer[bufferWritePosition + 3] = " ****    ";
      buffer[bufferWritePosition + 4] = "    **** ";
      buffer[bufferWritePosition + 5] = "     *** ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'Z':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " **    * ";
      buffer[bufferWritePosition + 1] = " ***   * ";
      buffer[bufferWritePosition + 2] = " * **  * ";
      buffer[bufferWritePosition + 3] = " *  ** * ";
      buffer[bufferWritePosition + 4] = " *   *** ";
      buffer[bufferWritePosition + 5] = " *    ** ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case '.':
    if (thereAreEnoughSlots(3)) {
      buffer[bufferWritePosition + 0] = " **      ";
      buffer[bufferWritePosition + 1] = " **      ";
      buffer[bufferWritePosition + 2] = "         ";
      bufferWritePosition += 3;
    }
    break;
  case ',':
    if (thereAreEnoughSlots(4)) {
      buffer[bufferWritePosition + 0] = "*        ";
      buffer[bufferWritePosition + 1] = "***      ";
      buffer[bufferWritePosition + 2] = " **      ";
      buffer[bufferWritePosition + 3] = "         ";
      bufferWritePosition += 4;
    }
    break;
  case '\'':
    if (thereAreEnoughSlots(3)) {
      buffer[bufferWritePosition + 0] = "     *** ";
      buffer[bufferWritePosition + 1] = "     *** ";
      buffer[bufferWritePosition + 2] = "         ";
      bufferWritePosition += 3;
    }
    break;
  case '?':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "      *  ";
      buffer[bufferWritePosition + 1] = "      ** ";
      buffer[bufferWritePosition + 2] = " * *   * ";
      buffer[bufferWritePosition + 3] = " * **  * ";
      buffer[bufferWritePosition + 4] = "    **** ";
      buffer[bufferWritePosition + 5] = "     **  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case '!':
    if (thereAreEnoughSlots(4)) {
      buffer[bufferWritePosition + 0] = "         ";
      buffer[bufferWritePosition + 1] = " * ***** ";
      buffer[bufferWritePosition + 2] = " * ***** ";
      buffer[bufferWritePosition + 3] = "         ";
      bufferWritePosition += 4;
    }
    break;
  case '-':
    if (thereAreEnoughSlots(4)) {
      buffer[bufferWritePosition + 0] = "   **    ";
      buffer[bufferWritePosition + 1] = "   **    ";
      buffer[bufferWritePosition + 2] = "   **    ";
      buffer[bufferWritePosition + 3] = "         ";
      bufferWritePosition += 4;
    }
    break;
  case ' ':
    if (thereAreEnoughSlots(4)) {
      buffer[bufferWritePosition + 0] = "         ";
      buffer[bufferWritePosition + 1] = "         ";
      buffer[bufferWritePosition + 2] = "         ";
      buffer[bufferWritePosition + 3] = "         ";
      bufferWritePosition += 4;
    }
    break;
  default:
    /*
    if (key == CODED) {
     if (keyCode == UP) {
     timeToWait += 10;
     }
     else if (keyCode == DOWN && timeToWait >= 10) {
     timeToWait -= 10;
     if (timeToWait < 0) {
     timeToWait = 0;
     }
     }
     }
     break;
     */
  }
}

boolean thereAreEnoughSlots(int slotsRequired) {
  /*
  if((bufferSize - bufferWritePosition) 

Video playback / texture Error

Post an image with saveFrame to a website

$
0
0

I am using the saveFrame function to save images from a webcam. This works fine :) so far so good. What i want to do now, is to run some code (maybe i need a processing library maybe not (?)) that will use for example this website: myawesome-pic.tk/savedframe/1234566.jpg and will upload the saveFrame image to my website. Any hint please?


How to stop RGB from being multiplied by Alpha

$
0
0

Hey everyone,

Goal : Pack 32bit values into a single pixel and send via texture over Spout.

Problem : The RGB values of color() are multiplied by the alpha, so even if R, G, and B are set to 255, if the Alpha is set to 0, get() returns R,G,B values of 0.

Question : Is there a way to prevent RGB from being multiplied by Alpha? I've tested this in different software and it works fine.

I've made an example :

Sender > The canvas is split into 2, the left side has 0 Alpha, and the right has full Alpha. Other than that they are the same.

import spout.*;

Spout spout;

float rate = 1.0;
float amplitude = 255;

void setup() {

  size(640, 360, P3D);
  colorMode(RGB, 255);
  frameRate(30);

  // spout object
  spout = new Spout(this);
  // name sender
  spout.createSender("Spout Processing");

} // end setup

void draw() {

  background(0,0,0,0);

  int m = millis();
  float Hz = rate  * 1000;
  float lfo = map(sin(radians(360) * m % Hz), -1, 1, 0, amplitude); //Sinewave LFO

  // left -- 0 alpha
  noStroke();
  fill(lfo,lfo,lfo,0);
  rect(0,0,320,360);

  // right -- full alpha
  noStroke();
  fill(lfo,lfo,lfo,255);
  rect(321,0,640,360);

  spout.sendTexture();

} // end draw

Receiver > Captures the texture via spout and analyzes pixels from each half and prints out the values in the textport.

import spout.*;

Spout spout;

void setup() {

  size(640, 360, P3D);
  colorMode(RGB, 255);
  frameRate(30);

  spout = new Spout(this);

} // end setup

void draw() {

    background(0,0,0,0);

    spout.receiveTexture();

    // left -- 0 alpha
    color l = get(0,0);
    // right -- full alpha
    color r = get(321,0);

    print("0 ALPHA >>> ");
    print(red(l), blue(l), green(l), alpha(l));

    print(" --- FULL ALPHA >>> ");
    println(red(r), blue(r), green(r), alpha(r));

} // end draw

Thanks!

Graph translation error in simple parametric

$
0
0

Hey,

Very simple solution here. I'm trying to graph a figure 8 knot with particles, and the visual seems to be translating incorrectly around the z axis, as if there is only one quadrant repeating or something... is there a translate() solution for this?

import toxi.geom.*; import toxi.math.*; import toxi.util.*; import toxi.physics.*; import peasy.*; import toxi.physics.VerletParticle; import toxi.physics.VerletSpring;

int iteration = 50; PImage back; float w = 10;

Particle[] particles = new Particle[iteration]; ArrayList springs;

VerletPhysics physics; PeasyCam cam;

void setup(){ size(2560,1600, P3D); cam = new PeasyCam(this, 200); back = loadImage("backgroundKNUX.jpg");

}

void draw(){

float q = 0; background(back); lights();

for(int t =0; t < iteration; t++){

  float x = ((2+cos(2*q))*cos(3*q))*10;
  float y = ((2+cos(2*q))*sin(3*q))*10;
  float z = (sin(4*q))*10;

  Particle n = new Particle(x,y,z);
  particles[t] = n;
  q++;

} for(int p = 0; p < iteration; p++){ particles[p].display(); } }

Array of objects

$
0
0

Hello, i have this error when i'm running the sketch: NullPointerException. Here the code:

import ddf.minim.*;
import ddf.minim.analysis.*;

Minim minim;
AudioPlayer player;
BeatDetect beat;
FFT fft;
Obj obj;
// var metodi //////////////////////////
float xPan;
float eRadius;

// var temp ///////////////////////////
float band = 20;
float freq = 1000;
float xEasing;
float easing = 0.001;
// var Node //////////////////////////

float xPos, yPos;

void setup()
{
  size(1280, 800, P3D);
  smooth();
  minim = new Minim(this);
  player = minim.loadFile("homeostasie.aif");
  beat = new BeatDetect();
  fft = new FFT(player.bufferSize(), player.sampleRate());
  Obj[] obj = new Obj[player.bufferSize()];

  for (int i=0; i<obj.length; i++) {
    obj[i] = new Obj(width/2, height/2, 1, 0);
  }
}

void draw()
{
  fill(255, 200);
  rect(0, 0, width, height);
  for (int i = 0; i < player.bufferSize(); i++)
  {
    xPos = (player.left.get(i)*200 + width/2);
    yPos = (player.right.get(i)*200) + height/2;
    xEasing = xEasing + ((xPos + yPos)/2 - xEasing) * easing;
    float alpha = 255 - (i);
    noStroke();
    fill(0, map(alpha, 0, 255, 10, 255));
    obj.display(xPos, yPos, 1 + beatDetection(), alpha);
    //ellipse(xPos, yPos, beatDetection() + 1, beatDetection() + 1);
  }
}

If i write the line 49 like this : obj[i].display(xPos, yPos, 1 + beatDetection(), alpha); i have this error: The type of the expression must be an array type but it resolved to HomeostasieReactive2.Obj

Thank you in advance

[Toxiclibs] Is there a quicker method to test mesh inclusion

$
0
0

Hi

I was looking to see if I could test if a point was inside a mesh. I was looking online and found this article which suggested raytracing as a method and find the number of intersections. Using toxiclibs I could find if a ray intersected a mesh only according to the mesh normals. So I had to check against two meshes, one which is flipped.

It works but it just takes a long time to test and I also have to loop through the function a few times to get rid of all the points( even though I shouldnt need to).

Anyway is there a quicker method to check that, maybe with another library. Here is my code.

import java.util.*;
import peasy.*;
import toxi.geom.*;
import toxi.geom.mesh.*;
import toxi.processing.ToxiclibsSupport;


import wblut.processing.*;
import wblut.hemesh.*;
import wblut.geom.*;



private ToxiclibsSupport gfx;
TriangleMesh cave;
TriangleMesh cave2;




ArrayList<Vec3D> pts = new ArrayList<Vec3D>();


public void settings() {
  size(1400, 800, P3D);
  smooth();
}

public void setup() {


  cave = (TriangleMesh) new STLReader().loadBinary(sketchPath("data/" + "cave.stl"), STLReader.TRIANGLEMESH);
  cave2 = (TriangleMesh) new STLReader().loadBinary(sketchPath("data/" + "cave.stl"), STLReader.TRIANGLEMESH);
  cave2.flipVertexOrder();

  Vec3D a = cave.computeCentroid();
  PeasyCam cam = new PeasyCam(this, a.x, a.y, 0, 2200);

  gfx = new ToxiclibsSupport(this);

  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 20; j++) {
      for (int k = 0; k < 20; k++) {
        pts.add(new Vec3D(i * 70, j * 70, k * 30));
      }
    }
  }

  //Point in Mesh Function ( a bit slow)

  for (int j = 0; j < 10; j++) {    // Need to run it a few times
    for (int i = 0; i < pts.size(); i++) {
      Vec3D v = pts.get(i);
      Ray3D r = new Ray3D(v, new Vec3D(0, 0, 1));
      if (!cave.intersectsRay(r)) {
        pts.remove(v);
      } else {
        if (cave2.intersectsRay(r)) {
          pts.remove(v);
        }
      }
    }
  }

}


public void draw() {
  background(0);

  for (Vec3D a : pts) {
    stroke(255);
    strokeWeight(2);
    point(a.x, a.y, a.z);
  }

  pushMatrix();
  fill(40, 120);
  noStroke();
  lights();
  gfx.mesh(cave2, false, 0);
  popMatrix();

}

Minim Loop when If(true)

$
0
0
import ddf.minim.*;

Minim minim;
AudioPlayer player;

void setup() {
  minim = new Minim(this);
  player = minim.loadFile("alert.mp3");
}

void draw() {
  if (true) {
    player.loop();
  }
}

I want to do when If statement is true let the song loop. But, It always stay at first second, don't go around.

I have tried rewind + play, it has same problem. I want to loop, when If is true.

help me...

How to get x and y axis value from audio-in in real time

$
0
0

HI- I'm using the minim library to take in an audio signal from my computer's mic and show a waveform on the screen. I want to process the waveform into a different 2D image. Is there a way to get the audio file x and y axis values in real time? Ideally I'd bring them into an array and process from there. Thanks! Sophi

recording a video

$
0
0

Hello,

I wrote a programme for audio-reactive visuals … usually I perform live in clubs (like here), but this time I need to record a video (sound doesn’t matter). I tried to write out jpegs, and a screen capture with Quicktime, but both slows down the programme a bit. However it is pretty essential that the visuals react precisely to the audio.

Does anybody have some advice maybe?

Cheers!


Correlations library

$
0
0

Hi, First post overhere.

Any idea about correlations library for processing http://www.muehlseife.de/ It is a really awesome tool. Right now i am trying to delete nodes, but i havent succeed. Maybe there is other tool - library i can use for the same purpose = GUI noded based Any help i will appreciate it.

Best Regards.

how to improve this codes? (Interative object)

$
0
0

hello, I'm studying for my project with the leap motion and processing. It's my first time to do programming, I'm trying to mix up some of sketches i found and to change little bit. based on https://www.openprocessing.org/collection/2560

whatever, Here is my Question.

1.how to change WordPaint axis? It moves to the left around the edges.

1-1. how to make to move WordPaint automatically on Y axis only? (wants to move like BBQ)

2.Wants to limit space. move inside on 'size'

import peasy.*;
import com.leapmotion.leap.*;

int width = 400;
int height = 400;

float turns = radians(360);
float xRotation = 0;
float yRotation = 0;
float zRotation = 0;
Controller leap = new Controller();
// variables =============================================

// Camera
PeasyCam cam;

int bufferSize = 1256;
int bufferWritePosition = 0;
String[] buffer = new String[bufferSize];

int factorBetweenBoxes = 3;
int factorBetweenLetters = 30;
float angle = 0.0001;
float angleAdd = 0.009;
float jitter;

// letterSpacing: use -6 for 'W' to put more space after the W
int letterSpacing = 0;

// functions =============================================

void setup () {

  size (1000, 1000, P3D);
  cam = new PeasyCam(this, 2000.0 );
  cam.pan(170, 400);


  noSmooth();
  fill(color(255, 255, 255));
  stroke(color(25,25,0));
}

void draw () {
  Frame frame = leap.frame();
  Hand hand = frame.hands().frontmost();
  if ( hand.isValid() )
  {
    InteractionBox box = frame.interactionBox();
    Vector controlPosition = hand.palmPosition();
    Vector normalizedPosition = box.normalizePoint(controlPosition, false);
    xRotation = turns * normalizedPosition.getX();
    yRotation = turns * (1 - normalizedPosition.getY());
    zRotation = turns * (1 - normalizedPosition.getZ());
  }

  background(0);

  rotateX(zRotation);
  rotateY(xRotation);
  rotateZ(yRotation);
  translate(width/2, height/8);
   if (second() % 2 == 0) {
    jitter = random(-0.0001, 0.0001);
  }
  angle = angle + jitter;
  float c = cos(angle/2);
  translate(width/2, height/2);
  rotate(c);

  WordPaint("I HATE YOU");
  angle += angleAdd/5;
}

void keyPressed() {
  if (key == CODED) {
    if (keyCode == UP) {
      factorBetweenBoxes-=1;
    } else if (keyCode == DOWN) {
      factorBetweenBoxes+=1;
    }
    if (keyCode == LEFT) {
      factorBetweenLetters-=1;
    } else if (keyCode == RIGHT) {
      factorBetweenLetters+=1;
    }
  } else {
    // not coded
    if (key == '1') {
      if (angleAdd==0.0) {
        angleAdd=0.009;
      } else {
        angleAdd=0.0;
      };
    } // SPACE
    else if (key == 'm') {
      angleAdd=0.1;
    }
  } // else not coded
} // func

void WordPaint(String InputWordOfFunction) {
  final int BoxWidth=3;
  letterSpacing=0;
  for (int i = 0; i < InputWordOfFunction.length(); i = i+1) {
    buffer = new String[bufferSize];
    bufferWritePosition=0;
    letterSpacing=0;
    keyPaintHelper(InputWordOfFunction.charAt(i));
    for (int  j = 0; j < bufferWritePosition; j = j+1) {
      for (int  k = 0; k < buffer[j].length(); k = k+1) {
        if (buffer[j].charAt(k) == '*') {
          pushMatrix();
          translate((j*factorBetweenBoxes)+(i*factorBetweenLetters)-100+letterSpacing,
            300-(k*factorBetweenBoxes)+100,
            -1);
          // rotateY(0.3); //  ;-)
          box (BoxWidth, BoxWidth, BoxWidth+BoxWidth+BoxWidth);
          popMatrix();
        }
      }
    }
  }
}

void keyPaintHelper(char InputKeyOfFunction) {
  char k = Character.toUpperCase(InputKeyOfFunction);
  letterSpacing=0;
  switch(k) {
  case 'A':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******  ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "   *   * ";
      buffer[bufferWritePosition + 3] = "   *   * ";
      buffer[bufferWritePosition + 4] = " ******* ";
      buffer[bufferWritePosition + 5] = " ******  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'B':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " *  *  * ";
      buffer[bufferWritePosition + 3] = " *  *  * ";
      buffer[bufferWritePosition + 4] = " ******* ";
      buffer[bufferWritePosition + 5] = "  ** **  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'C':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "  *****  ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " *     * ";
      buffer[bufferWritePosition + 3] = " *     * ";
      buffer[bufferWritePosition + 4] = " *     * ";
      buffer[bufferWritePosition + 5] = "  *   *  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'D':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " *     * ";
      buffer[bufferWritePosition + 3] = " **   ** ";
      buffer[bufferWritePosition + 4] = "  *****  ";
      buffer[bufferWritePosition + 5] = "   ***   ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'E':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " *  *  * ";
      buffer[bufferWritePosition + 3] = " *  *  * ";
      buffer[bufferWritePosition + 4] = " *  *  * ";
      buffer[bufferWritePosition + 5] = " *     * ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'F':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "    *  * ";
      buffer[bufferWritePosition + 3] = "    *  * ";
      buffer[bufferWritePosition + 4] = "    *  * ";
      buffer[bufferWritePosition + 5] = "       * ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'G':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "  *****  ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " ** *  * ";
      buffer[bufferWritePosition + 3] = " ** *  * ";
      buffer[bufferWritePosition + 4] = " **** ** ";
      buffer[bufferWritePosition + 5] = " **** *  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'H':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "    *    ";
      buffer[bufferWritePosition + 3] = "    *    ";
      buffer[bufferWritePosition + 4] = " ******* ";
      buffer[bufferWritePosition + 5] = " ******* ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'I':
    if (thereAreEnoughSlots(6)) {
      buffer[bufferWritePosition + 0] = "         ";
      buffer[bufferWritePosition + 1] = " *     * ";
      buffer[bufferWritePosition + 2] = " ******* ";
      buffer[bufferWritePosition + 3] = " ******* ";
      buffer[bufferWritePosition + 4] = " *     * ";
      buffer[bufferWritePosition + 5] = "         ";
      bufferWritePosition += 6;
    }
    break;
  case 'J':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "  **     ";
      buffer[bufferWritePosition + 1] = " ***     ";
      buffer[bufferWritePosition + 2] = " *     * ";
      buffer[bufferWritePosition + 3] = " ******* ";
      buffer[bufferWritePosition + 4] = "  ****** ";
      buffer[bufferWritePosition + 5] = "       * ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'K':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "   ***   ";
      buffer[bufferWritePosition + 3] = "  ** **  ";
      buffer[bufferWritePosition + 4] = " **   ** ";
      buffer[bufferWritePosition + 5] = " *     * ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'L':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " *       ";
      buffer[bufferWritePosition + 3] = " *       ";
      buffer[bufferWritePosition + 4] = " *       ";
      buffer[bufferWritePosition + 5] = " *       ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'M':
    if (thereAreEnoughSlots(9)) {
      buffer[bufferWritePosition + 0] = " ******  ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "    **** ";
      buffer[bufferWritePosition + 3] = "  ****   ";
      buffer[bufferWritePosition + 4] = "  ****   ";
      buffer[bufferWritePosition + 5] = "    **** ";
      buffer[bufferWritePosition + 6] = " ******* ";
      buffer[bufferWritePosition + 7] = " ******  ";
      buffer[bufferWritePosition + 8] = "         ";
      bufferWritePosition += 9;
    }
    break;
  case 'N':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "    **   ";
      buffer[bufferWritePosition + 3] = "   **    ";
      buffer[bufferWritePosition + 4] = " ******* ";
      buffer[bufferWritePosition + 5] = " ******* ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'O':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "  *****  ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " *     * ";
      buffer[bufferWritePosition + 3] = " *     * ";
      buffer[bufferWritePosition + 4] = " ******* ";
      buffer[bufferWritePosition + 5] = "  *****  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'P':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "    *  * ";
      buffer[bufferWritePosition + 3] = "    *  * ";
      buffer[bufferWritePosition + 4] = "    **** ";
      buffer[bufferWritePosition + 5] = "     **  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'Q':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "  *****  ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " **    * ";
      buffer[bufferWritePosition + 3] = " **    * ";
      buffer[bufferWritePosition + 4] = "******** ";
      buffer[bufferWritePosition + 5] = "* *****  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'R':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " ******* ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = "   **  * ";
      buffer[bufferWritePosition + 3] = "  ***  * ";
      buffer[bufferWritePosition + 4] = " ** **** ";
      buffer[bufferWritePosition + 5] = " *   **  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'S':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "  ** **  ";
      buffer[bufferWritePosition + 1] = " ** **** ";
      buffer[bufferWritePosition + 2] = " *  *  * ";
      buffer[bufferWritePosition + 3] = " *  *  * ";
      buffer[bufferWritePosition + 4] = " **** ** ";
      buffer[bufferWritePosition + 5] = "  ** **  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'T':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "       * ";
      buffer[bufferWritePosition + 1] = "       * ";
      buffer[bufferWritePosition + 2] = " ******* ";
      buffer[bufferWritePosition + 3] = " ******* ";
      buffer[bufferWritePosition + 4] = "       * ";
      buffer[bufferWritePosition + 5] = "       * ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'U':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "  ****** ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " *       ";
      buffer[bufferWritePosition + 3] = " *       ";
      buffer[bufferWritePosition + 4] = " ******* ";
      buffer[bufferWritePosition + 5] = "  ****** ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'V':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "   ***** ";
      buffer[bufferWritePosition + 1] = "  ****** ";
      buffer[bufferWritePosition + 2] = " **      ";
      buffer[bufferWritePosition + 3] = " **      ";
      buffer[bufferWritePosition + 4] = "  ****** ";
      buffer[bufferWritePosition + 5] = "   ***** ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'W':
    letterSpacing=-6 ; // -6 for 'W'
    if (thereAreEnoughSlots(9)) {
      buffer[bufferWritePosition + 0] = "  ****** ";
      buffer[bufferWritePosition + 1] = " ******* ";
      buffer[bufferWritePosition + 2] = " **      ";
      buffer[bufferWritePosition + 3] = "  ****   ";
      buffer[bufferWritePosition + 4] = "  ****   ";
      buffer[bufferWritePosition + 5] = " **      ";
      buffer[bufferWritePosition + 6] = " ******* ";
      buffer[bufferWritePosition + 7] = "  ****** ";
      buffer[bufferWritePosition + 8] = "         ";
      bufferWritePosition += 9;
    }
    break;
  case 'X':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " **   ** ";
      buffer[bufferWritePosition + 1] = " *** *** ";
      buffer[bufferWritePosition + 2] = "   ***   ";
      buffer[bufferWritePosition + 3] = "   ***   ";
      buffer[bufferWritePosition + 4] = " *** *** ";
      buffer[bufferWritePosition + 5] = " **   ** ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'Y':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "     *** ";
      buffer[bufferWritePosition + 1] = "    **** ";
      buffer[bufferWritePosition + 2] = " ****    ";
      buffer[bufferWritePosition + 3] = " ****    ";
      buffer[bufferWritePosition + 4] = "    **** ";
      buffer[bufferWritePosition + 5] = "     *** ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case 'Z':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = " **    * ";
      buffer[bufferWritePosition + 1] = " ***   * ";
      buffer[bufferWritePosition + 2] = " * **  * ";
      buffer[bufferWritePosition + 3] = " *  ** * ";
      buffer[bufferWritePosition + 4] = " *   *** ";
      buffer[bufferWritePosition + 5] = " *    ** ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case '.':
    if (thereAreEnoughSlots(3)) {
      buffer[bufferWritePosition + 0] = " **      ";
      buffer[bufferWritePosition + 1] = " **      ";
      buffer[bufferWritePosition + 2] = "         ";
      bufferWritePosition += 3;
    }
    break;
  case ',':
    if (thereAreEnoughSlots(4)) {
      buffer[bufferWritePosition + 0] = "*        ";
      buffer[bufferWritePosition + 1] = "***      ";
      buffer[bufferWritePosition + 2] = " **      ";
      buffer[bufferWritePosition + 3] = "         ";
      bufferWritePosition += 4;
    }
    break;
  case '\'':
    if (thereAreEnoughSlots(3)) {
      buffer[bufferWritePosition + 0] = "     *** ";
      buffer[bufferWritePosition + 1] = "     *** ";
      buffer[bufferWritePosition + 2] = "         ";
      bufferWritePosition += 3;
    }
    break;
  case '?':
    if (thereAreEnoughSlots(7)) {
      buffer[bufferWritePosition + 0] = "      *  ";
      buffer[bufferWritePosition + 1] = "      ** ";
      buffer[bufferWritePosition + 2] = " * *   * ";
      buffer[bufferWritePosition + 3] = " * **  * ";
      buffer[bufferWritePosition + 4] = "    **** ";
      buffer[bufferWritePosition + 5] = "     **  ";
      buffer[bufferWritePosition + 6] = "         ";
      bufferWritePosition += 7;
    }
    break;
  case '!':
    if (thereAreEnoughSlots(4)) {
      buffer[bufferWritePosition + 0] = "         ";
      buffer[bufferWritePosition + 1] = " * ***** ";
      buffer[bufferWritePosition + 2] = " * ***** ";
      buffer[bufferWritePosition + 3] = "         ";
      bufferWritePosition += 4;
    }
    break;
  case '-':
    if (thereAreEnoughSlots(4)) {
      buffer[bufferWritePosition + 0] = "   **    ";
      buffer[bufferWritePosition + 1] = "   **    ";
      buffer[bufferWritePosition + 2] = "   **    ";
      buffer[bufferWritePosition + 3] = "         ";
      bufferWritePosition += 4;
    }
    break;
  case ' ':
    if (thereAreEnoughSlots(4)) {
      buffer[bufferWritePosition + 0] = "         ";
      buffer[bufferWritePosition + 1] = "         ";
      buffer[bufferWritePosition + 2] = "         ";
      buffer[bufferWritePosition + 3] = "         ";
      bufferWritePosition += 4;
    }
    break;
  default:
    /*
    if (key == CODED) {
     if (keyCode == UP) {
     timeToWait += 10;
     }
     else if (keyCode == DOWN && timeToWait >= 10) {
     timeToWait -= 10;
     if (timeToWait < 0) {
     timeToWait = 0;
     }
     }
     }
     break;
     */
  }
}

boolean thereAreEnoughSlots(int slotsRequired) {
  /*
  if((bufferSize - bufferWritePosition) 

Getting a sound live stream

Is there a library to parse GIS shape files ( .shp )?

$
0
0

I know there is GeoTools in Java and there is shp.js in javascript (https://github.com/kig/shp.js/)

But i cant find it for processing... so if i use the java lib then i wont be able to run my sketch in html5, and if i want to use the js parser i dont know how to connect it to the sketch in html5... any ideas?

Questions about draw function

$
0
0

The following is my code. Since I am using PeasyCam and thenShapes3D for the box, do I need to ask this question in the Libraries area also? The question I have is that I am only changing 1 box every second or so, but i am having to redraw all 8000 blocks each draw cycle. Is there a way to have draw only redraw the changed objects?

void draw() { int CPS=20; pushMatrix(); for (int i = 0; i < CPS; i++) { for (int j = 0; j < CPS; j++) { for (int k = 0; k < CPS; k++) { box[i][j][k].draw(); }}} popMatrix(); cam.rotateY(rotateAngle); cam.rotateX(rotateAngle); cam.rotateZ(rotateAngle); }

Viewing all 2896 articles
Browse latest View live