i'm totally new to programming. when it goes well, the feeling of success is better than any videogame. when it goes poorly, i feel like a terrible human
I feel as if I'm missing something very basic indeed, so if someone could point out what I'm missing I'd appreciate it greatly.
I don't know how to build to android with ant.
I have completed all the steps successfully so far, including doing a test build from processing to a connected android device which is beautifully running ketai, and oscP5, communicating with a desktop app running oscP5 and minim. All seems to be well in test build.
However, when I export an android app and then go to the directory in terminal (OSX here) and run "ant", I get a
"Buildfile: /blah/blee/theFileITotallyWantToBuild.xml"
and then
BUILD SUCCESSFUL
and yet... no file? nothing has changed. I was under the impression, perhaps wrongly, that I'd get an .apk file out of this whole mess to move over to my android device. Or maybe the option to install this file directly to the device. But I'm not sure how to do that. I've been looking around for tutorials and help files for a while now, and I'm not sure how to proceed.
So, uh, what very simple thing do I not know about here?
Thanks!
/*
thinking about learning how to think in order to more effectively learn
*/
Not sure what's going on here, but I'm getting an error while trying to add a string to an OSC message.
My "print" functions are returning the information just fine, but the shoutOut.add(String) method is throwing the error:
"addrpattern: /ping### [2012/8/9 12:49:13] ERROR @ OscP5 ERROR. an error occured while forwarding an OscMessage"
Here's the code thats causing the problem:
void ping(){ for (int i = 0; i <= 255; i ++){ String pingAddr = baseAddr + i;
if(pingAddr.equals(ip) || pingAddr.equals(touchOSC)){}//println("not pinging self or phone controller");} else{ NetAddress pingLocation = new NetAddress(pingAddr, 8000); OscMessage shoutOut = new OscMessage("/ping"); shoutOut.add(ip); print(" ping sends: " + shoutOut.addrPattern() + " with stringvalue: " + shoutOut.get(0).stringValue()); println(" to pingAddr: " + pingAddr); oscP5.send(shoutOut, pingLocation); //this specifically right here isn't working } } pingSent = true; println("ping sent"); }
I imagine I'm just overlooking something rather simple. Thanks for the help!
/*
thinking about learning how to think in order to more effectively learn
*/
I've been reading about polymorphism and interfaces, and I was wondering if anyone could recommend a good tutorial on how to implement interfaces?
I've seen a few explanations and tutorials, but all of them do the bare minimum to illustrate what an interface is, and I haven't yet seen any tutorials with a concrete example. Most of them just have an empty interface implemented by an empty class with no examples on why / how you would want to use these.
I'm trying to take my skills a bit further, and I can see how I might want to use these on some upcoming projects.
Thanks!
/*
thinking about learning how to think in order to more effectively learn
*/
I've been dabbling elsewhere in some c# coding, and I've recently discovered the idea of a struct as a storage unit for data rather than a class.
Looking back at a few things I've written, I can see how it would be useful to have a class-like thing just to store pieces of data rather than a full class so as to avoid instantiating an object or series of objects to get, set, and store data.
Is there any such thing in processing, or a related idea?
Thanks!
/*
thinking about learning how to think in order to more effectively learn
*/
The math seems not too difficult, but I don't quite know how to translate unknown variables to code.
For example, in processing, I can't create an equation with pow(x, 2) when x isn't yet known. How could I make this work? I know that there is the papaya library that can handle some of this, but I struggle there for 2 reasons:
1) I'd like to know how to code this from scratch for my own understanding and
2) I'm not quite sure what to do with the polynomial functions that are included anyway
Thank you, I'd appreciate some direction on this
/*
thinking about learning how to think in order to more effectively learn
*/
I'm making a graffiti-type app with input via TouchOSC, and I'm having trouble mapping the diameter of the brush to speed without it obviously stepping between sizes.
The diameter problems only become apparent if you swipe the mouse across the screen really quickly (which is easy to do via OSC input, but you have to be a little more agressive to do it with the mouse).
What would be a better way to smooth this out?
Thanks in advance.
int cp = 5;
int r = 80;
int g = 10;
int b = 220;
float rinc = 1;
float ginc = 5;
float binc = 1.5;
float easing = 0.2;
float diamEase = 0.1;
float diam;
float distance;
float x, y, d;
PVector easeLoc;
PVector mLoc;
PVector pLocLoc;
PVector bPoints[];
color pencil = color(180, 20, 100);
void setup() {
size(800,800);
background(0);
smooth();
bPoints = new PVector[cp];
for(int i = 0; i < cp; i ++){
bPoints[i] = new PVector(0, 0);
}
}
void draw() {
cursor(CROSS);
mLoc = new PVector(mouseX, mouseY);
easeMovements(mLoc.x, mLoc.y);
distance = easeLoc.dist(bPoints[1]);
arrayIterate(easeLoc);
mainDraw();
fill(0, 1);
noStroke();
rect(0, 0, width, height);
}
void mainDraw() {
pencil = color(r, g, b);
stroke(pencil, 255);
diam = easeDiam(map(distance, 0, 50, 20, 4));
//diam = map(distance, 0, 60, 30, 4);
if(diam < 4){
diam = 4;
}
strokeWeight(diam); //brush size
r += rinc;
g += ginc;
b += binc;
if(r >= 255 || r <= 40){
rinc *= -1;
}
if(g >= 40 || g <= 10){
ginc *= -1;
}
if(b >= 180 || b <= 90){
binc *= -1;
}
lineShape();
}
void lineShape(){
beginShape();
curveVertex(bPoints[0].x, bPoints[0].y); //1st point is also control point
curveVertex(bPoints[0].x, bPoints[0].y);
curveVertex(bPoints[1].x, bPoints[1].y);
curveVertex(bPoints[2].x, bPoints[2].y);
curveVertex(bPoints[3].x, bPoints[3].y);
curveVertex(bPoints[3].x, bPoints[3].y); // the last point is also 2nd control point
endShape();
}
void arrayIterate(PVector _mouseLoc){
bPoints[4].set(bPoints[3]);
bPoints[3].set(bPoints[2]);
bPoints[2].set(bPoints[1]);
bPoints[1].set(bPoints[0]);
bPoints[0].set(_mouseLoc);
}
void easeMovements(float targetX, float targetY){
//pLoc.set(easeLoc);
float dx = targetX - x;
if(abs(dx) > .02){
x += dx * easing;
}
float dy = targetY - y;
if(abs(dy) > .02){
y += dy * easing;
}
easeLoc = new PVector(x, y);
//return easeLoc;
}
float easeDiam(float targetX){
float dx = targetX - d;
if(abs(dx) > .02){
d += dx * diamEase;
}
return d;
}
void keyPressed() {
switch(key) {
case ' ' :
background(0);
break;
}
}
/*
thinking about learning how to think in order to more effectively learn
*/
as a n00b to processing and programming in general, I found this difficult to achieve. I searched around on the forums, and I didn't find any help specific to streams of continuous input (like cursor input) to trigger events.
Anyway, hopefully someone finds this sketch helpful. I used a timer class that I found someone else had made here on the forums (unfortunately I don't remember who wrote it, and I can't find it again) in order to set this up.
Use this patch to start a fade event based on cursor input. timer will then enter a 'hold' phase as long as there is input, and then fade out again.
To my untrained brain, it seems like this could be accomplished in a much simpler fashion. If anyone knows how to make it simpler than this, I would appreciate feedback. At this stage of my learning, this is what I came to.
Hopefully it comes in handy
/*
//////////////////////////////////
//////////////////////////////////
this patch allows for a fade in if there is mouse input.
once mouse stops moving, the timer enters a 'hold' phase, and then a fadeout phase.
if mouse input occurs during 'hold' phase, the hold phase continues until there is
I'm struggling with setting up a timer to count down, but to be reset if there is input.
I have searched on the forums, and I have seen a few different timer sketches, but they all seem to be triggered once and then set to run down without further input.
I need a timer that begins counting when there is no input. When input is seen, the timer resets itself.
I tried modifying code that I found, but the sketch, once it starts the timer, will never reset it. The timer will only run once over the life of the sketch.
This is a pretty basic sketch, and could probably be written a lot more efficiently. BUT, I've gotten so much help here from the community that I wanted to give something back. Perhaps someone doing a project in the future might find this useful.
It's a simple mouseover detection sketch, but written as a class with the possibility for multiple buttons.
Anyway, that's all. This sketch uses a lot of info that I've gained here directly from users. So back out into the world it goes!
I've been trying to sort this out for hours ,since yesterday. I'm afraid I just don't know programming technique well enough to think my way around this one.
How can I randomly distribute circles without them overlapping? I've been banging my head against the wall!
I was trying to create my own from scratch while taking inspiration from these two sources. I feel like I'm close, but keep getting caught in infinite loop or null pointer exceptions (values don't get assigned).
Um, I'm probably over thinking this. Here's what I got so far.
int circleCount = 10;
float maxRadii = 200;
float minRadii = 20;
PVector circleArray[] = new PVector[circleCount];
float radArray[] = new float[circleCount];
PVector loc;
float radii;
void setup(){
size(800, 600);
background(0);
initCircles();
}
void draw(){
fill(150);
noStroke();
drawCircles();
}
void initCircles(){
boolean overlap;
boolean finalJ;
for (int i = 0; i < circleCount; i ++){
if (i < 2){ //added this because I kept getting caught in problems with i = 1 and j = 0, cancelling loop
loc = new PVector(width/2 + (i * maxRadii), height/2 + (i * maxRadii));
I'm having a tricky (to me) logic problem that I'm not sure how to solve.
I am iterating through an array to see if a cursor location is within a certain bounds. If it is true, I would like the cursor to disappear.
There are multiple points that the cursor could be over. So, the difficulty I'm having is that I have an array containing all of the points, and a loop comparing the cursor location to the various points. While the function correctly detects that the cursor is over one of the points, it is also, within the same loop, detecting that it is NOT over any of the other points, and so is being redrawn.
so, in psuedocode, it's like this:
float points = newList[numberOfPoints];
boolean isOver = false;
setup(){
size(the, universe);
allMySetupStuff();
cursorLocation(mouseX, mouseY);
for (i = 0; i < numberOfPoints; i ++){
points[i] = initializeThePointCoordinates();
}
}
void draw(){
if (isOver = true){
disappearCursor();
}
for (int i = 0; i < numberOfPoints; i ++){
if (cursorLocation isWithinCoordinates points[i]){
isOver = true;
}else{
isOver = false;
}
}
}
So, as you can see, it will be true once in the loop, but false for the rest of the loop. It will happen so fast that the cursor will never actually disappear. How can I get around this?
Thank you in advance.
/*
Please forgive my ignorance. I only know what I've already learned, and this world is a lot bigger than that.
I not sure where to limit TUIO cursors in the example code that they provide. I have looked and tweaked in several areas, but it has not yielded any results yet.
I've commented below in their code what I thought would work, but hasn't.
my comments are on line 11, line 35, line 38
any help would be appreciated, even if it is to tell me i can't do what i'm trying to do. it'd be nice to know.
// i thought that limiting the iteration loop to i < list.size AND i < 1 would keep the loop from listening for any additional points in the list, but it is not the case. Also, changing i<tuioObjectList.size() to i<0 yields an error of 0 >= 0
for (int i=0;i<tuioObjectList.size() && i < 1;i++) {
//changing the following if statement to 'if (pointList.size() > 0 && pointList.size < 2){ executeStuff();} makes it so that the cursor appears on screen only for a brief blip and then disappears.
if (pointList.size() > 0) {
// i created this conditional inside the previous conditional, and it works for displaying only 1 point. however, when an additional point appears, it takes over the cursor from the previous point. it hands it back to the lower index point when it disappears.
Hello, I am just learning to write sketches using OOP and I'm not quite sure how to implement the patch.
I have read the Object tutorial here on processing.org, and I've also read the OOP chapter out of Ira Greenberg's processing book. I get the concepts of OOP, but the specific implementation is baffling me.
I took a procedural patch I had written and attempted to rewrite it in OOP format. I've wrangled it such that the compiler doesn't complain at all, but when I run the sketch it just outputs a blank screen.
What I don't quite get is how to pass variables to constructors, how to write other methods that modify specific variables of constructors, etc.
In this patch I am trying to write a curve that follows the mouse cursor, and the cursor would also have a circle around it. I'd like to be able to modify the control point variables and have them constantly updating with a random() function or some similar thing. Currently, all I get is a black screen.
I've been fiddling around with MSAFluid, and I love it!
I've succeeded at getting single point data from the Kinect in to control it from Daniel Shiffman's avgpointtracking implementation, and have had a lot of fun learning about processing by pulling this all apart.
My question is this:
I'd like to alter the code in MSAFluid such that when the color drawing is finished, instead of fading to black it fades to a transparent background.
I've just started poking around in the code for it, and I will eventually figure it out. However, I feel like a beginner tracking a chess master's game. A lot of it is way beyond me at this point! I can see where the colors get assigned, but I'm not certain how to alter/add functions so that they affect transparency as well.
Is anyone familiar enough with this to give me pointers?
I'm just starting out in processing and I'm trying to get TUIO communication happening.
Is there a basic TUIO tutorial or other area where I can get info geared towards beginners? I've looked at the tuio.org page, but I'm afraid just the basic reference page is a little beyond what I know how to implement. I am beginning to get the concept, but I don't quite know how to make sense of it all just yet.
I taking tutorials and such on the side, but I'd like to dive right into practical applications with this.
Can anyone point me in the right direction? Thank you
that suggests it is bundled in with processing. In the thread, it is suggested that adding
import processing.opengl.*;
at the start of the sketch should solve the problem, andf i assume since that's the end of the thread that it worked for that person. It hasn't worked for me, however. What am I missing here?
I'm having a problem I don't quite understand (that's why I'm here! otherwise I would have solved it
)
I stumbled across Memo Atkins' example of simple harmonic motion, and I wanted to see if I could write that up.
I thought I had it, but I'm having problems when I increment the speed for each node. I've tried different ways of incrementing the speed of each node, but it always seems to result in groups of nodes operating at near the same speed, while other sections behave near properly.
I'm new to processing and to programming in general, so I figure this is something simple about math or procedure that I'm missing. Anyway, I'd much appreciate any help.