I am a newbie, so this question might be very basic...
Is it possible in Processing to load a background image in, say, an 800x800 window, and then load other images over the top of this image, with the centre of these other images being placed precisely at specific coordinates?
I am looking for a freelancer who is able to implement a solution for me in Processing.
The project is relatively simple, involving a user interface with sequential visual images, user input, and storage of user input. I am relatively new to Processing, but wish to learn, so a required aspect of the solution is detailed information within the code about what each line does.
Please contact me if you are a good Processing programmer, and would be interested in this job. Then I will provide more details about the project. I prefer to work via Elance.com.
In the code below, when a key is pressed, a new .txt file is loaded. My question is, how could I introduce added functionality whereby the new file is loaded after 5 seconds, say, even if no key has been pressed? To clarify, a new .txt is loaded after key press, but is loaded in any case after 5 seconds...
/*-----------------------------------------------------------------------------
*** GLOBAL VARIABLES ***
-----------------------------------------------------------------------------*/
ArrayList pointList; // arraylist to store the points in
int currentFile = 1; // to keep track of the textfile, starts at 1
/*-----------------------------------------------------------------------------
*** GLOBAL INIT ***
-----------------------------------------------------------------------------*/
void setup(){
//-------------------------------- GENERAL
size(800,800);
background(0);
//-------------------------------- POINTS
pointList = new ArrayList(); // instantiate an ArrayList
importTextFile(); // call our custom function
}
/*-----------------------------------------------------------------------------
*** MAIN PROGRAM LOOP ***
-----------------------------------------------------------------------------*/
void draw(){
//-------------------------------- GENERAL
background(0);
stroke(210);
fill(210,90);
//-------------------------------- VISUALIZE THE POINT SET
for(int i = 0; i < pointList.size(); ++i){
PVector V = (PVector) pointList.get(i);
ellipse(V.x,V.y, 20, 20);
}
/*-----------------------------------------------------------------------------
*** CUSTOM IMPORT FUNCTION ***
-----------------------------------------------------------------------------*/
void importTextFile(){
String[] strLines = loadStrings(currentFile + ".txt"); // the name and extension of the file to import!
for(int i = 0; i < strLines.length; ++i){
String[] arrTokens = split(strLines[i], ','); // use the split array with character to isolate each component
float xx = float(arrTokens[0]); // cast string value to a float values!
float yy = float(arrTokens[1]); // cast string value to a float values!
pointList.add( new PVector(xx,yy) ); // add values to a new array slot
}
}
I am new to processing, and have a question, which is probably simple for many of you. I hope someone is willing to help me.
In the code below, you will notice at the bottom that a .txt file is being loaded. Suppose I have a whole library of .txt files named 1,2,3 and so forth. How do I load the next file (ie. 2 after 1, 3 after 2 etc) after the user presses a key?
The current code basically takes the text file, which contains coordinates for dots, and draws these dots. The effect I am after is after a user key press, a new drawing is made, because the code takes the data from 2.txt, key press, 3.txt, key press 4.txt and so forth...
/*
*** Our text file will look something like below, #
where each line corresponds to the x,y,z coordinate of a point!
coordX, coordY, coorzZ
coordX, coordY, coorzZ
coordX, coordY, coorzZ
... etc
*/
/*-----------------------------------------------------------------------------
*** GLOBAL VARIABLES ***
-----------------------------------------------------------------------------*/
ArrayList pointList; // arraylist to store the points in
/*-----------------------------------------------------------------------------
*** GLOBAL INIT ***
-----------------------------------------------------------------------------*/
void setup(){
//-------------------------------- GENERAL
size(800,800);
background(0);
//-------------------------------- POINTS
pointList = new ArrayList(); // instantiate an ArrayList
importTextFile(); // call our custom function
}
/*-----------------------------------------------------------------------------
*** MAIN PROGRAM LOOP ***
-----------------------------------------------------------------------------*/
void draw(){
//-------------------------------- GENERAL
background(0);
stroke(210);
fill(210,90);
//-------------------------------- VISUALIZE THE POINT SET
for(int i = 0; i < pointList.size(); ++i){
PVector V = (PVector) pointList.get(i);
ellipse(V.x,V.y, 20, 20);
}
}
/*-----------------------------------------------------------------------------
*** CUSTOM IMPORT FUNCTION ***
-----------------------------------------------------------------------------*/
void importTextFile(){
String[] strLines = loadStrings("1.txt"); // the name and extension of the file to import!
for(int i = 0; i < strLines.length; ++i){
String[] arrTokens = split(strLines[i], ','); // use the split array with character to isolate each component
float xx = float(arrTokens[0]); // cast string value to a float values!
float yy = float(arrTokens[1]); // cast string value to a float values!
pointList.add( new PVector(xx,yy) ); // add values to a new array slot
}
}
I am working on a simple program. Basically, the program is supposed to do the following:
A) Fetch co-ordinates for circles to be displayed on the screen from .txt file.
(Done, see code below) B) Display circles
(Done, see code below) C) Ask for user input (??)
D) Store user input in .txt file next to a value for the number of circles displayed (??) So, if there are 10 circles displayed, and the user types 12, the in the text file, the following should be displayed 12,10.
How can I amend the code below, to also include C and D?
/*
*** Our text file will look something like below, #
where each line corresponds to the x,y,z coordinate of a point!
coordX, coordY, coorzZ
coordX, coordY, coorzZ
coordX, coordY, coorzZ
... etc
*/
/*-----------------------------------------------------------------------------
*** GLOBAL VARIABLES ***
-----------------------------------------------------------------------------*/
ArrayList pointList; // arraylist to store the points in
/*-----------------------------------------------------------------------------
*** GLOBAL INIT ***
-----------------------------------------------------------------------------*/
void setup(){
//-------------------------------- GENERAL
size(800,800);
background(0);
//-------------------------------- POINTS
pointList = new ArrayList(); // instantiate an ArrayList
importTextFile(); // call our custom function
}
/*-----------------------------------------------------------------------------
*** MAIN PROGRAM LOOP ***
-----------------------------------------------------------------------------*/
void draw(){
//-------------------------------- GENERAL
background(0);
stroke(210);
fill(210,90);
//-------------------------------- VISUALIZE THE POINT SET
for(int i = 0; i < pointList.size(); ++i){
PVector V = (PVector) pointList.get(i);
ellipse(V.x,V.y, 20, 20);
}
}
/*-----------------------------------------------------------------------------
*** CUSTOM IMPORT FUNCTION ***
-----------------------------------------------------------------------------*/
void importTextFile(){
String[] strLines = loadStrings("points_16_9.txt"); // the name and extension of the file to import!
for(int i = 0; i < strLines.length; ++i){
String[] arrTokens = split(strLines[i], ','); // use the split array with character to isolate each component
float xx = float(arrTokens[0]); // cast string value to a float values!
float yy = float(arrTokens[1]); // cast string value to a float values!
pointList.add( new PVector(xx,yy) ); // add values to a new array slot
}
}
I am new to Processing. I am working on a problem, where I have an ArrayList of x and y coordinates. Now I wish to access a given line in the ArrayList. Having accessed that line, I wish to let the variable xcor be the x coordinate on that line, and ycor be the y coordinate on that line.
Could someone please show me the syntax for accessing a line in such an ArrayList and letting variables such as xcor and ycor be the accessed values?
Suppose I have the code shown at the bottom, which draws many circles at random on the screen (thank you drum whore for you effort in getting me that far). My question is:
How do I ensure that the image actually displayed does not have overlapping circles? (I am thinking, a trial and error process, but still, that needs to control for the position of each circle, right?)
PrintWriter positions;
int cycles = 100; //number of circles
Suppose that I have a program, which simply draws a number of squares on the scree. The attributes are size and rotation, which for each square are both random.
My question is, suppose I run the program many times times, how do I collect the data on these attributes for each square, for each program execution?
I wonder if someone can help me here. I am new to Processing. The following is a subset of a problem I am working on, and I hope that if someone can show me how to solve it, then I can work out the solution to the whole problem.
* I need to draw N squares on the screen (where N may be 1 to 25).
* The centre a given square is one of the corners of a 4 by 4 grid.
* The length of each square in this grid is G, so that the total length of the grid is 4G.
* To ensure non-overlapping squares, the maximum length of a given square is L = G/sqrt(2)
* The actual length of each drawn square is a random number from 0 to L.
* The rotation of each square drawn is random.
* No square may share the same centre (grid point).