Finally had some time to start digging into Processing 2 and the shader API, and I've managed to get some simple shaders going. Is there any way to work out the screen co-ordinates of the fragment that the shader is operating on?
Say I want to have the shader colour every even numbered Y co-ordinate red, and every odd Y co-ordinate green.
The shader's main() method would, I guess, be something like this (in pseudo-ish code):
void main(){
vec2 pos= vec2(xpos, ypos); //this line is fiction
if(mod(pos.y, 2.0) == 0.0){
gl_FragColor= vec4(1.0, 0.0, 0.0, 1.0);
}
else
gl_FragColor= vec4(0.0, 1.0, 0.0, 1.0);
}
}
So far, so reasonably straightforward, but how do I convert from the co-ordinates the shader knows about to ones I can use? I thought it would be a simple case of passing in the values of width and height and mapping them to vertTexCoord or gl_FragCoord but I can't seem to make that work. Any hints appreciated.
I'm trying to get my Android tablet to talk to Processing via OSC, using TouchOSC and the oscP5 send/receive example. On my Windows 7 machine it pretty much just works but on OSX I get nothing. I've set the IP addresses at both ends and tried turning the firewall off, to no avail.
I suspect it is an OSX thing rather than a Processing one as I tested with Reaper which has an OSC option and that got nothing on OSX, but did detect under WIn7, but I figure someone here might have had the same experience.
Do I need to open a specific port, or do some terminal hackery? Any advice appreciated.
Is it possible to have a controlP5 controller as a property of an object? I'd like to be able to create a number of objects and control their parameters without having to manually create each slider for each object as that gets unwieldy quickly!
When you create two of those objects, you get a cp5 error message: "WARNING: Controller with name "/theValue" already exists. overwriting reference of existing controller."
I'm also not quite sure whether the class should have it's own controlEvent method- I assume so, as I can't see any other way to do it without duplicating the code for each object (which is what I'm trying to avoid).
Hello, when I run this code using the default renderer (is that still JAVA2D?) in Processing 2.0b6 it runs as expected: the pixels from the source image are copied correctly to the PGraphics instance. Using P2D or P3D, though, the resulting image is flipped vertically and horizontally. Going through the pixels backwards means it's flipped horizontally only. Am I doing something wrong here or is this a bug?
Hello! I'm working on a project based on
live traffic speed data from New York (not really live at the moment for obvious hurricane related reasons, but the last updated data is still there). Problem is, there are a lot of extra line breaks inserted at different times (you can see where this happens about 75% of the way down the linked file), so the CSV style breaks down and using loadStrings() doesn't work the way it should.
At the moment I have a version working which is using brute force and ignorance to strip out any line which doesn't begin with a whole number (the ID attribute) and has at least 12 items, but this approach cuts out a significant portion of the useful data. Since the data is (theoretically) live I can't use Excel or whatever to clean it up, although opening it as a CSV in LibreOffice Calc and separating fields with " does a pretty good job.
So, tl;dr version: does anyone have any advice or strategies for dealing with irregular data with erroneous line breaks?
Thanks!
Stripped down version of what I'm doing at the moment, if you want to punish yourself:
I've just installed the Android SDK, but when I try and run a sketch on the emulator the emulator launches, but the sketch never appears. The PDE stays on "Waiting for device to become available" and nothing happens. Running the same sketch using "Run on device" works, and the sketch launches on the phone.
Anyone got any ideas for this? Processing 1.5.1, Win7 64 bit with 64 bit JDK.
I've been playing with the P5SunflowAPIAPI library, with some early success. One thing I'm really having trouble with is setting a background colour- everything I render is coming out with a black background. Looking at the docs would suggest that
sunflow.setBackground(255, 255, 255);
ought to set the background colour to white, but it's not working! Any thoughts would be appreciated.
p.s. I'm using the P5SunflowAPIAPI library rather than the SunflowAPIAPI Java wrapper.
I'm trying to combine Geomerative with
Lee Byron's Mesh library to create Voronoi and Delaunay meshes with the points from a Geomerative object. The issue I'm having is that the Voronoi class refuses to work with the points coming out of Geomerative. The Delaunay works, and the Voronoi works if I use random numbers instead, but using the points from Geomerative it throws an Array Index Out of Bounds: 0 error. Any suggestions? Here's some code:
I'm working on some sketches using the
Guardian Open Platform API which returns results as an XMLElement, which I can then run getChildren() on to get each result. This will return up to 50 results as a single XMLElement, so to get more than 50 results I have to run the query multiple times and combine the results in Processing. The issue I'm having is that I want to combine the XMLElement arrays returned from getChildren() , but I'm unsure how to go about this. Using
results= append(results, responseChild);
where results and reponseChild are both XMLElement arrays gives me the error "cannot convert from Object to XMLElement[]".
I'm working on some pieces to generate sound from the shape or form of an image, and I've got them working quite nicely using X and Y points. What I would like to try is to have the colour value of each pixel influence the output; its simple to get the colour of each using get(x, y) or similar, but is there a method to extract a value (an int or float) from each pixel?
Is there a simple way to clear all the elements of an array? I have a program which generates arrays of points to draw 3d geometry, and at the moment I'm just calling setup() to clear it and start over. The only problem with that is it resets the camera position (I'm using the PeasyCam library) which I'd rather it didn't do.
Any suggestions, other than using shorten() however many times?
Trying to get on top of ArrayLists but I keep on hitting errors I can't make sense of. When I try and run it I get the following error: "The method add(Component) in the type container is not applicable for the arguments (ArrayList.FadingLine)".
I've looked through the reference and searched this forum and the old one, to no avail. Any suggestions for what I'm doing wrong or further reading would be appreciated!