loopmode
YaBB Newbies
Offline
Posts: 1
Setting Background color and Sonia
Feb 21st , 2006, 11:47am
hi! It seems to me, when the sonia library is being used (import pitaru.sonia_v2_9.*;) the background() command is being either ignored or at least somehow overriddden or so. I simply get a grey background. If I comment out the line with 'import ...' it works just fine. Now I do definitely need a white background color for my project, so I ask for some help here. I can't be the first one to come across the problem, still I couldnt find any useful information on the web so far. Well i don't know if it is just about sonya or more general, here is my code, I guess it always helps to post it as well: import pitaru.sonia_v2_9.*; int w = 800; // stage width int h = 600; // stage height int line_count = 0; // counts total amount of lines int c = 0; // counter, used for speed control // float x1; float y1; float x2 = random(w); float y2 = random(h); // void setup() { size(w, h); framerate(500); Sonia.start(this); LiveInput.start(); background(255); } int line_length = 10; int line_density = 1; //how many lines are drawn each interval //################################################################# // lim is gonna be a value in a certain range (between loThresh and hiThresh) // the higher the volume, the lower is lim // if the counter c is higher then lim, lines will be drawn, and c reset to 0 //################################################################# int loThresh = 0; int hiThresh = 100; int sensitivity = 500; // sensitivityplies the (very low) values given by getLevel() void draw() { c++; float lim = LiveInput.getLevel()*sensitivity; // getLevel gives low values, so sensitivityply bu thresh value lim = (lim>hiThresh) ? hiThresh : lim; // limit to thresh value (if higher) lim = hiThresh-lim; // get inverted value lim = (lim<loThresh) ? loThresh : lim; // limit to zero (if lower) println(lim); if(c>lim){ c=0; for (int i=0; i<line_density; i++) { line_count ++; // println(line_count); // float l = line_length; x1 = x2; y1 = y2; x2 = x1+(random(l)-l/2); y2 = y1+(random(l)-l/2); x2 = (x2>w) ? w-random(l) : (x2<0) ? random(l) : x2; y2 = (y2>h) ? h-random(l) : (y2<0) ? random(l) : y2; //smooth(); stroke(0, 100); line(x1, y1, x2, y2); } } } Thanks, jovi