Loading...
Logo
Processing Forum
hamoid's Profile
7 Posts
41 Responses
1 Followers

Activity Trend

Last 30 days
Show:
Private Message
    Hi! I'm wondering if anyone has suggestions about having a computer on a art gallery running Processing on OS X.
    It will use a webcam to capture images of people on demand.

    Things that come to my mind are:
    • Deactivate the screen saver
    • Adjusting the energy settings so the computer does not switch off on its own
    • Disable software updates
    There will be someone there who can restart the computer in case something goes wrong.

    Any suggestions or tricks?
    Hi, I've been switching between Processing and ProcessingJS often during the last days and I keep finding differences between them. Maybe you have some ideas about dealing with these:
    • isNaN(), a JavaScript function, is Float.isNaN() in Java. Float does not exist in JavaScript. How would you write code that uses isNaN() and is compatible with both? (isNaN stands for "is not a number")
    • In Java I can do myPImage.copy(g, ...) to copy from the main canvas into an image. But "g" does not exist in ProcessingJS. Is it doable? Is there a way to write compatible code? Or the only way is using pixels[]?
    Try/catch is not documented in the ProcessingJS reference, but it seems to work. I thought I could try to use isNaN and if it fails, catch and use the other isNaN. The funny thing is that Processing (Java) does not let me run something with an error, so I can not even attempt to call isNaN() in the Java version.
    Hi,

    I want to write a program that can smoothly pan and zoom in a photo. It should have keyframes and positions. It should pass each position at the right frame.

    Drawing a continuous curve using bezier curves is not hard. The problem comes when animating. If one segment has more frames than the next one there will be a sudden change in speed, which I want to avoid.

    You can see the speed change in this program I wrote (sometimes it's not so obvious, depends on the random values you get)  http://studio.sketchpad.cc/sp/pad/view/ro.91U$eaK67FtNp/latest

    TL;DR Does someone have code that allows that kind of animation?

    According to Wikipedia, "In computer graphics, Catmull–Rom splines are frequently used to get smooth interpolated motion between key frames. For example, most camera path animations generated from discrete key-frames are handled using Catmull–Rom splines. They are popular mainly for being relatively easy to compute, guaranteeing that each key frame position will be hit exactly, and also guaranteeing that the tangents of the generated curve are continuous over multiple segments. "

    I've read all the tech notes at  http://algorithmist.net/, downloaded  http://www.algorithmist.net/as3pc.html and  http://www.degrafa.org/code/ but as far as I can tell, there is no keyframe system to do spline animation. I only find formulas for drawing curves.
    This seems to be the right direction, but at least in the example all time segments have the same duration, and that ActionScript/MXML code is not that straightforward to translate. I can not try these demos (no Silverlight plug-in) but I think this is what I want to achieve, done the Microsoft way.
    Hi! I'm trying to optimize a program by dividing one task into four threads. On each frame I want to draw 10 collections of 600 lines, so I'm creating four threads. The first two draw 2 collections, the next two 3 collections (2+2+3+3=10).

    The lines must be drawn using rect() because if I use line() there are very ugly position rounding errors. That means I must translate() and rotate() the rect() into the right position. If I used lines I could just calculate the position of both ends and avoid translating and rotating.

    Now, the result is quite cool and messed up :) Not exactly what I want. The problem is (I think) that each traslate() and rotate() is interfering with the other calls to the same functions in the other threads, so the translations and rotations pile up. I even get some crazy huge rectangles for free.

    Can this problem be distributed at all into several threads?

    1. void setup() {
    2.   size(600, 300);
    3.   colorMode(HSB, 1);
    4.   noStroke();
    5.   smooth();
    6. }

    7. void draw() {
    8.   background(0);

    9.   float f = frameCount / 88.0;

    10.   SimpleThread t1 = new SimpleThread(0, 1, f);
    11.   t1.start();    
    12.   SimpleThread t2 = new SimpleThread(2, 3, f);
    13.   t2.start();    
    14.   SimpleThread t3 = new SimpleThread(4, 6, f);
    15.   t3.start();    
    16.   SimpleThread t4 = new SimpleThread(7, 9, f);
    17.   t4.start();    

    18.   if (frameCount % 50 == 0) {
    19.     println(int(frameRate));
    20.   }
    21. }

    22. class SimpleThread extends Thread {
    23.   int yfrom;
    24.   int yto;
    25.   float f;

    26.   SimpleThread (int from, int to, float rf) {
    27.     yfrom = from;
    28.     yto = to;
    29.     f = rf;
    30.   }

    31.   void run () {
    32.     for (int y = yfrom; y <= yto; y++) {
    33.       float they = y/10.0;
    34.       for (int x=0; x < width; x++) {
    35.         float thex = x/100.0;
    36.         fill((they + thex + f) % 1.0, 1, 1);
    37.         translate(x, 50+y*20);
    38.         rotate(they + thex + f);
    39.         rect(0, 0, 1, 15);
    40.         resetMatrix();
    41.       }
    42.     }
    43.   }

    44.   void quit() {
    45.     interrupt();
    46.   }
    47. }
    I know it would be more efficient to create 4 threads once instead of making new ones all the time, but I have no idea (yet) about how to keep them in sync with draw().
    1. import ddf.minim.*;

    2. Minim minim;
    3. AudioSample s1;
    4. AudioSample s2;

    5. void setup() { 
    6.   minim = new Minim(this);

    7.   // **** Not working: only the first loaded sample plays!
    8.   // **** If I swap the next two lines, then the other sample plays, but never both.
    9.   s2 = minim.loadSample("snd2.wav", 1024);
    10.   s1 = minim.loadSample("snd1.wav", 1024);
    11. }
    12. void draw() {
    13.   if(frameCount % 30 == 0) {
    14.     s1.trigger();
    15.   }  
    16.   if(frameCount % 33 == 1) {
    17.     s2.trigger();
    18.   }
    19. }
    20. void stop() {
    21.   s1.close();
    22.   s2.close();
    23.   minim.stop();  
    24.   super.stop();
    25. }