I am working on a sketch to draw a filled vector shape and animate smoothly its three vertices. I include the code below. The sketch is interactive. If you run it, you will see the triangular vector shape--it looks like a guitar pick.
If you press the "a" key on the keyboard, the three vertices animate. When this is animated, the first and last vertex do not meet perfectly. There is a sharp point there instead of a smooth curve. I can't figure out why.
Here is a diagram of the vertices and control points. The three vertices are (curX, curY), (curX1, curY1) and (curX2, curY2). The values at the corners of the largest triangle are the control points. (curX, curY) is the first and last vertex specified. It is the vertex where the glitch occurs.
I need some advice on these two functions for a work I have in mind. I already posted on this and some folks asked to see code, so I have developed a couple of sketches to try to illustrate what I am after.
I want to be able to create organic shapes that animate smoothly and have beautiful, smooth curved edges. I also want them to fill fully and "normally".
I do not understand these two functions correctly and am not getting the results I need.
This first sketch uses the bezier() function. I can draw the static shape I want with it. Press the "a" key on the keyboard and one vertex is attached to the mouse pointer. No matter where it is dragged, the curve is continuous and smooth. However instead of the whole shape being filled, I have an unfilled triangle in the center.
// bezierInteractive
// Press the "a" key to toggle between interactive and fixed versions
bezier(400, 80, 500, 60, 657, 193, 600, 360); // v1, c1, c2, v2 MOUSE X = 480, Y = 80
bezier(600, 360, 543, 527, 237, 650, 160, 520);
bezier(160, 520, 83, 390, 250, 110, 400, 80);
endShape(CLOSE);
}
}
void keyPressed() {
if (key == 'a'){
interactive = !interactive;
}
}
Okay, now, here is my attempt to do something similar with the bezierVertex() function. The fill works as expected--no white triangle. I can draw the static shape fine, but when it is attached to the mouse pointer as this sketch shows, I get a sharp point when it is dragged instead of a smooth curve.
// bezierVertexInteractive sketch
void setup() {
size(1000, 1000);
}
void draw() {
background(200);
fill(255, 255, 0);
beginShape();
vertex(mouseX, mouseY);
bezierVertex(500, 60, 657, 193, 600, 360);
bezierVertex(543, 527, 237, 650, 160, 520);
bezierVertex(83, 390, 250, 110, mouseX, mouseY);
endShape();
}
Thanks for helping,
George
15" MacBook Pro, 2.4GHz Intel Core i5, OS X v.10.8.3 Mountain Lion,
QuickTime Player v.10.2, Processing v. 1.5.1 and v.2.0b8, Arduino Uno, Nano v.3.
On p. 77 of Reas and Fry
Processing a Programming Handbook for Artists and Designers, it is suggested to draw a shape in a structured drawing program such as Illustrator, then translate the coordinates of the vertices and control points into Processing code. I have tried to understand how to do this, but I can never get the figure I'm shooting for. Here is a diagram of my Illustrator vector shape with the vertices in green and the control points in red. Ignoring my "V1, C1, etc. labels, would someone who knows how to do this show me how to code for this shape in Processing?
Thanks is advance,
George
15" MacBook Pro, 2.4GHz Intel Core i5, OS X v.10.8.3 Mountain Lion,
QuickTime Player v.10.2, Processing v. 1.5.1 and v.2.0b8, Arduino Uno, Nano v.3.
I am using Processing v. 1.5.1 and, for many of my needs, I am happy with it. However, every time I start it, a few seconds into my work session, a notification pops up on my computer that there is a newer version of Processing available. Sometimes this notification completely freezes my computer. I cannot continue work and have to turn the computer off. This is exceedingly bad behavior for software to design an update notification that completely locks up someone's computer
I KNOW there is a newer version of Processing available.
Is there any way to stop Processing from interrupting my every work session with these annoying notices? Is there no way to defeat or turn off this behavior?
George
15" MacBook Pro, 2.4GHz Intel Core i5, OS X v.10.8.3 Mountain Lion,
QuickTime Player v.10.2, Processing v. 1.5.1 and v.2.0b8, Arduino Uno, Nano v.3.
I am trying to get a Processing program to work with an Arduino Uno with three potentiometers hooked up to the Arduino board.
The Arduino program I have so far seems to print to the serial port the correctly-formatted values, such as:
123, 180, 200*123, 180, 200* etc.
Here is that code:
// Arduinno Code Not Processing code=========
int sensor1 = 0;
int sensor2 = 0;
int sensor3 = 0;
void setup(){
Serial.begin (9600);
pinMode (3, INPUT);
}
void loop(){
if (Serial.available() > 0){
Serial.read();
sensor1 = analogRead(A0);
sensor2 = analogRead(A1);
sensor3 = analogRead(A2);
Serial.print (sensor1, DEC);
Serial.print (',');
Serial.print (sensor2, DEC);
Serial.print (',');
Serial.print (sensor3, DEC);
Serial.print ('*');
}
}
// end Arduino code ===================================
My problem is that my Processing code only works intermittently. Sometimes when I start it, it works fine, but mostly it shuts off after putting up the sketch window. I suspect there must be something wrong with my method of taking in and handling the stream of serial data coming in from the Arduino.
Here's the Processing code v 2.0b8 of Processing:
import processing.serial.*;
int r, g, b;
Serial port;
void setup() {
size(200, 200);
println(Serial.list());
port = new Serial(this, Serial.list()[4], 9600);
port.write(65);
}
void draw() {
background(r, g, b);
}
void serialEvent(Serial port) {
String input = port.readStringUntil('*');
if ( input != null) {
//println("Receiving: " + input);
int[] vals = int(splitTokens(input, ",*"));
r = vals[0];
g = vals[1];
b = vals[2];
r = r/4;
g = g/4;
b = b/4;
println(r + ", " + g + ", " + b);
}
port.write(65);
}
These examples were derived from Daniel Shiffman's code on pp. 376-7 in
Learning Processing.
I have tried adding a delay(xx); function to the Arduino code, but that hasn't helped. I'm still getting intermittent performance.
Any help or suggestions would be greatly appreciated.
Many thanks,
George
15" MacBook Pro, 2.4GHz Intel Core i5, OS X v.10.2.8 Mountain Lion,
QuickTime Player v.10.2, Processing v. 1.5.1 and v.2.0b8, Arduino Uno, Nano v.3.
I am trying to learn how to use Processing and multiple pots connected to an Arduino. There are lots of examples using one pot, but when there are several pots connected and data is streaming into the computer's serial port, how do you set Processing up so you can tell what data is coming from which pot?
Is "parsing" the correct term for this?
any thanks,
George
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 2.0b7
Is there a way to create a .pde sketch that will launch other .pde sketches? I have any number of student-authored Processing sketches that I would like to be able to show in a slide show-type format, either playing one after another in a loop (automated) or interactively with some sort of user-controlled interface (key presses, mouse-clicks, etc.)
Thanks for ideas,
George
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
I have my students creating little Processing programs, .pde files. Is it possible for me to write one Processing program that will launch the students' .pde files, detect when they are done or just stop them running and play another, perhaps by using a button interface?
Thanks,
George
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
I get a function does not exist error if I issue a player.stop() function for Minim to stop a sound playing. I cannot find such a function in the docs either.
What is the proper way to stop a sound file playing with a counter, keyperss or mouse click?
Thanks,
George
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
I have a sketch I am working on. In the edit window, the little block that encircles the curly brace paired with the one upon which the cursor is placed has stopped working.
Is there a way to restore this function? Other sketches work fine in this regard. It's just this one.
Editor bug?
George Roland
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
I can capture video fine from one connected camera (Fire-i firewire web cam). In the example GettingStartedCaptureMac, this code, listed as untested on a MAc:
String[] cameras = GSCapture.list();
produces errors.
Is there a way on Macs, to use multiple cams?
Thanks,
George
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
When I launch a file using your example program that demos isPlaying() the isPlaying() function indicates the file is not playing before the end of the file is reached, cutting the file playing off
before it is done.
When play() is called again, the cut-off end of the file plays before the file starts again from the beginning. Surely this cannot be correct.
I have tried this with two different sound files, one .aif and a different one .mp3. It does the same thing with either type of file.
the code:
import ddf.minim.*;
Minim minim;
AudioPlayer groove;
void setup()
{
size(512, 200, P3D);
minim = new Minim(this);
groove = minim.loadFile("friend.aif", 2048);
textFont(createFont("Arial", 12));
textMode(SCREEN);
}
void draw()
{
background(0);
if ( groove.isPlaying() )
{
text("The player is playing.", 5, 15);
}
else
{
text("The player is not playing.", 5, 15);
}
}
void keyPressed()
{
if ( key == 'l' )
{
groove.loop(1);
}
if ( key == 'p' )
{
groove.play(0);
}
if ( key == 's' )
{
groove.pause();
}
}
void stop()
{
// always close Minim audio classes when you are done with them
groove.close();
// always stop Minim before exiting.
minim.stop();
super.stop();
}
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
In Director and some other authoring platforms it is possible to place markers in a sound file that the authoring program can detect and use to launch an event. Do Minim or other Processing-compatible libraries detect such markers?
Thanks,
George
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
I have reviewed some of the discussion of using multiple video cameras with GS Video in Processing, but I cannot find a discussion of the proper hardware hookups for this.
I have iMacs, A 15" MacBook Pro and two Desktop Macs all new models with intel processors all of which have Firewire 800 connectors.
I have Unibrain "iFire" cams that have Firewire 400 cables. I can use an 800-400 Firewire adapter and, in iChat choose easily between the built-in Web cam and the attached iFire cam.
I can use a firewire hub to connect several firewire 400 devices to the compy's 800 connector. Can anyone verify that this hook-up is the best for multiple cams? Would USB cams work better in this situation?
Thanks,
George
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
I am working with Mac OSX v.10.6.1 on 27" iBooks and two MacPro desktops.
I am looking for recommendations for USB Webcams and Firewire video cams that would work well for video work using GSVideo or the built-in Video library.
I would like cams with tripod sockets so we could hook them up in any location.
Does not have to be HD video--SD video would be fine.
Any recommendations?
Many thanks,
George
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
I would like to set up a full screen display where my processing app is in the startup items of an auto-log on account so that when the computer is turned, the app simply comes up and runs.
However, the mouse pointer and menu are on screen and one has to move the mouse away from the menu to get it to disappear.
Is there any way to prevent this behavior?
Ideally, I'd like to have no keyboard or mouse attached to the machine at all so one can simply turn it on and off woith its power switch.
Thanks for any help,
George
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
I am developing an art work that I hope to exhibit using an LCD TV from a connected Macintosh.
I can use the mini display port on the computer to go to either the "Analog RGB PC Input" or the "HDMI" input on the TV.
My question is about color rendition which right now is pretty bad. Colors that are so dark they are nearly invisible on my MacBook Pro's LCD are middle-value on the TV--nothing there is every as saturated or as dark as it is on my computer.
There are lots of things that can be adjusted on the TV and on my Mac. On the TV are the usual:
Backlight, Contrats, Brightness, Color, Tint and Sharpness.
If I go into System Preferences>Displays the connected TV is listed as "SHARP LCD". In the "Color LCD" pane representing the MacBook, there is also a "SHARP LCD" COLOR profile.
Not wishing to reinvent the wheel, if anyone out there has come up with a system that gives good color rendition, I'd very much like to hear what has worked for you.
Am I correct in thinking the Analog RGB PC Input is the better way to go that HDMI?
Many thanks,
George
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
I am working on a project using sensors with Processing. In this specific instance, I am using potentiometers to allow users to input values to affect r,g,b color changes. I am using the Arduino board and rotary or slide pots, but the questions is, I think, more general.
When I run the sketch, there is a period of time before the sensors actually "kick in" during which the calls to the sensors produce 0, 0, 0. Once the sensors "kick in" the values (0-1023) are returned correctly.
What are good strategies to throw away the initial 0, 0, 0s returned until the sensors "kick in" with "real" values that I want to use?
George Roland
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
I have twelve shapes (int numShapes = 12). The RGB color values of each shape are stored in arrays, cRed[], cGreen[], cBlue[], and are changed every time the program loops through the draw() function, thus animating the color changes.
Right now, I am using a structure like this to draw the shapes:
for (int i = 0; i < numShapes; i ++) {
if( i == 0) {
fillColor(cRed[i], cGreen[i], cBlue[i]);
rect(x1, y1, wdth, ht);
}
if(i == 1) {
fillColor(cRed[i], cGreen[i], cBlue[i]);
rect(x2, y2, wdth, ht);
}
etc.
This works fine, but I have a nagging suspicion this is not good coding. Since each rect has a unique location and a constantly changing RGB value, I could not think of another technique for drawing the shapes.
Is this okay, or should I be using a different method?
Thanks,
George
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
I would like to use GSCapture to track a bright spot in the view of a videocam. When the bright spot goes into a "hit box" I want then to use GSMovie to play a QuickTime video. When the QT file is done playing, I want to redraw the interface and resume video capture/tracking.
Is it possible, then, to start both GSMovie and GSCapture in one sketch and switch between them? Does this require any special coding?
Many thanks,
George
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
I have been trying to figure out how to work with multiple videos and create a user interface to launch them. I have gotten to this point, where the screen is blank except for a button. When this button is clicked, the video plays fine. I cannot figure out how to set up, say, six videos that could each be played by clicking on one of six buttons.
When using Minim with .aif files, is it possible to play several files at once? I am familiar with Director where sounds are placed in channels and can be played individually or all at once. Is this possible in Processing and, if so, how would it be done?
many thanks,
George
MacBook Pro 15" 2.4GHz Intel Core i5, QuickTime v.10.0
Processing v. 1.2.1
I have been trying to get a QuickTime movie to play in Processing using the examples in the Video Library. The examples I have tried, such as
File>Examples>Library>Video(Movie)>Loop do NOT work. They run for awhile then put up error messages such as:
java(317,0xa0700540) malloc: *** error for object 0xfd0de00: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(317,0xb1ac2000) malloc: *** error for object 0xffffffff: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(317,0xa0700540) malloc: *** error for object 0xfd07850: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(317,0xb1ac2000) malloc: *** error for object 0x1277700: double free
*** set a breakpoint in malloc_error_break to debug
java(317,0xa0700540) malloc: *** error for object 0x166030: double free
*** set a breakpoint in malloc_error_break to debug
java(317,0xb1ac2000) malloc: *** error for object 0x1278150: double free
*** set a breakpoint in malloc_error_break to debug
java(317,0xb1ac2000) malloc: *** error for object 0xfb0a320: double free
*** set a breakpoint in malloc_error_break to debug
java(317,0xa0700540) malloc: *** error for object 0xfb12450: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(317,0xb1ac2000) malloc: *** error for object 0xffffffff: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
java(317,0xb1ac2000) malloc: *** error for object 0xfb123a0: double free
*** set a breakpoint in malloc_error_break to debug
Invalid memory access of location 0xffffffff eip=0x9068a5b0
By then, the video has disappeared from the screen.
I am not a computer scientist, and I have no idea what any of the above means outside of "this ain't working".