We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey - I'm running an eight-week Processing workshop in Berkhamsted, Hertfordshire starting Wednesday 31st.
For all the details and to book follow the link: http://www.d-lab.co.uk/coding-club/
We'll be aiming at creating generative 3D models for printing but it's a complete beginners course covering all aspects including interaction, sound, and image manipulation. Great for architects, artists, and designers.
Let me know if you have any questions!
Ed
You could try contacting the lab or their members.
http://vialab.science.uoit.ca/smt/contact.php
If this was a research project for a university lab then it may be over. In that case you would need to volunteer to help and/or hire someone to do the work.
Their site says:
"Simple Multi-Touch is open source and open to new contributions. If you want to help us out, check out our Github page and contact us by email!"
We are looking for some programming help to make an Interactive Wall. It will use the programming from this project:
Or https:// vimeo.com/71203556
We want to use a logo and have the action be the //float TYPO . which shows up at 2:51 on the vimeo video.
It calls for:
https://github.com/smmankad/float
We would like to hire someone to complete the programming and testing for this. Is this a good place to find freelancers with this type of expertise?
Hi, I'm very new to coding so please bare with me and explain things as simply as possible. I am trying to make a data program that displays a number (shown with an image such as the one below) when one of the US state names is clicked. I then need this number to change when a different state is clicked.
I find interactive features in processing very difficult so any help is greatly appreciated! Below is my code along with a screenshot of the program (a lot of it is made up of images which I'm aware you don't have access to), to give you a better idea of how it looks.
PImage invader;
PImage pointer;
PImage title;
void setup() {
size(1000, 800);
background(000);
invader = loadImage("invader.png");
image(invader, 0, 0);
pointer = loadImage("pointer.png");
title = loadImage("title.png");
}
void draw() {
background(0);
if(mousePressed == false) {
noCursor();
} else {
cursor(pointer);
}
PImage img;
img = loadImage("earthpicc.png");
image(img, 220, 550);
PImage img1;
img = loadImage("UFOO.png");
image(img, 395, 360);
PImage img2;
img = loadImage("title.png");
image(img, 345, 680);
//states
PImage img3;
img = loadImage("washington.png");
image(img, 95, 150);
PImage img4;
img = loadImage("oregon.png");
image(img, 70, 230);
PImage img5;
img = loadImage("california.png");
image(img, 95, 310);
PImage img6;
img = loadImage("nevada.png");
image(img, 60, 390);
PImage img7;
img = loadImage("arizona.png");
image(img, 85, 490);
PImage img8;
img = loadImage("utah.png");
image(img, 170, 250);
PImage img9;
img = loadImage("idaho.png");
image(img, 200, 200);
PImage img10;
img = loadImage("montana.png");
image(img, 170, 100);
PImage img11;
img = loadImage("wyoming.png");
image(img, 3900, 190);
PImage img12;
img = loadImage("colorado.png");
image(img, 150, 360);
PImage img13;
img = loadImage("newmexico.png");
image(img, 140, 440);
PImage img14;
img = loadImage("texas.png");
image(img, 160, 550);
PImage img15;
img = loadImage("oklahoma.png");
image(img, 240, 390);
PImage img16;
img = loadImage("kansas.png");
image(img, 250, 320);
PImage img17;
img = loadImage("nebraska.png");
image(img, 250, 240);
PImage img18;
img = loadImage("southdakota.png");
image(img, 250, 160);
PImage img19;
img = loadImage("northdakota.png");
image(img, 300, 60);
PImage img20;
img = loadImage("minnesota.png");
image(img, 340, 110);
PImage img21;
img = loadImage("iowa.png");
image(img, 330, 200);
PImage img22;
img = loadImage("missouri.png");
image(img, 380, 270);
PImage img23;
img = loadImage("arkansas.png");
image(img, 340, 340);
PImage img24;
img = loadImage("louisiana.png");
image(img, 230, 480);
PImage img25;
img = loadImage("mississippi.png");
image(img, 280, 530);
PImage img26;
img = loadImage("tennessee.png");
image(img, 500, 290);
PImage img27;
img = loadImage("alabama.png");
image(img, 550, 360);
PImage img28;
img = loadImage("kentucky.png");
image(img, 430, 225);
PImage img29;
img = loadImage("indiana.png");
image(img, 550, 150);
PImage img30;
img = loadImage("illinois.png");
image(img, 440, 150);
PImage img31;
img = loadImage("wisconsin.png");
image(img, 480, 85);
PImage img32;
img = loadImage("michigan.png");
image(img, 600, 50);
PImage img33;
img = loadImage("ohio.png");
image(img, 610, 95);
PImage img34;
img = loadImage("westvirginia.png");
image(img, 530, 200);
PImage img35;
img = loadImage("virginia.png");
image(img, 630, 250);
PImage img36;
img = loadImage("northcarolina.png");
image(img, 680, 390);
PImage img37;
img = loadImage("southcarolina.png");
image(img, 660, 460);
PImage img38;
img = loadImage("georgia.png");
image(img, 280, 430);
PImage img39;
img = loadImage("florida.png");
image(img, 780, 570);
PImage img40;
img = loadImage("pennsylvania.png");
image(img, 650, 140);
PImage img41;
img = loadImage("newyork.png");
image(img, 700, 75);
PImage img42;
img = loadImage("maryland.png");
image(img, 650, 330);
PImage img43;
img = loadImage("delaware.png");
image(img, 770, 270);
PImage img44;
img = loadImage("newjersey.png");
image(img, 780, 500);
PImage img45;
img = loadImage("connecticut.png");
image(img, 830, 440);
PImage img46;
img = loadImage("rhodeisland.png");
image(img, 820, 140);
PImage img47;
img = loadImage("massachusetts.png");
image(img, 630, 540);
PImage img48;
img = loadImage("vermont.png");
image(img, 830, 340);
PImage img49;
img = loadImage("newhampshire.png");
image(img, 740, 200);
PImage img50;
img = loadImage("maine.png");
image(img, 840, 100);
//
image(invader, mouseX,mouseY);
pushMatrix();
translate(width*0.10, height*0.8);
rotate(frameCount / 70.0);
noStroke ();
star(0, 0, 0.6, 10, 9);
popMatrix();
pushMatrix();
translate(width*0.45, height*0.1);
rotate(frameCount / 70.0);
noStroke ();
star(0, 0, 0.6, 10, 9);
popMatrix();
pushMatrix();
translate(width*0.9, height*0.8);
rotate(frameCount / 70.0);
noStroke ();
star(0, 0, 0.6, 12, 9);
popMatrix();
pushMatrix();
translate(width*0.4, height*0.9);
rotate(frameCount / 70.0);
noStroke ();
star(0, 0, 0.4, 7, 9);
popMatrix();
pushMatrix();
translate(width*0.86, height*0.25);
rotate(frameCount / 70.0);
noStroke ();
star(0, 0, 0.6, 10, 9);
popMatrix();
pushMatrix();
translate(width*0.2, height*0.9);
rotate(frameCount / 70.0);
noStroke ();
star(0, 0, 0.6, 10, 9);
popMatrix();
pushMatrix();
translate(width*0.88, height*0.08);
rotate(frameCount / 70.0);
noStroke ();
star(0, 0, 0.4, 6, 9);
popMatrix();
}
void star(float x, float y, float radius1, float radius2, int npoints) {
float angle = TWO_PI / npoints;
float halfAngle = angle/2.0;
beginShape();
for (float a = 0; a < TWO_PI; a += angle) {
float sx = x + cos(a) * radius2;
float sy = y + sin(a) * radius2;
vertex(sx, sy);
sx = x + cos(a+halfAngle) * radius1;
sy = y + sin(a+halfAngle) * radius1;
vertex(sx, sy);
}
endShape(CLOSE);
}
Hi, I'm extremely new to processing so apologies for my complete ignorance as to how any of this works. Basically I'm trying to create a map where each state turns a darker shade when hovered over by the mouse, but I've had a lot of trouble trying to figure our how to do this without coming up with any errors. Any help with how to achieve this would be greatly appreciated! Here is my code so far:
PImage UFO;
void setup(){
size(800, 650);
UFO = loadImage("UFObeam.png");
image(UFO, 0, 0);
}
void draw(){
background(0);
PImage img;
img = loadImage("1washington.png");
image(img, 400, 380);
PImage img3;
img = loadImage("2oregon.png");
image(img, 400, 380);
PImage img4;
img = loadImage("3california.png");
image(img, 400, 380);
PImage img5;
img = loadImage("4nevada.png");
image(img, 400, 380);
PImage img6;
img = loadImage("5idaho.png");
image(img, 400, 380);
PImage img7;
img = loadImage("6utah.png");
image(img, 400, 380);
PImage img8;
img = loadImage("7arizona.png");
image(img, 400, 380);
PImage img9;
img = loadImage("8montana.png");
image(img, 400, 380);
PImage img10;
img = loadImage("9wyoming.png");
image(img, 400, 380);
PImage img11;
img = loadImage("10newmexico.png");
image(img, 400, 380);
PImage img12;
img = loadImage("11colorado.png");
image(img, 400, 380);
PImage img13;
img = loadImage("12northdakota.png");
image(img, 400, 380);
PImage img14;
img = loadImage("13southdakota.png");
image(img, 400, 380);
PImage img15;
img = loadImage("14nebraska.png");
image(img, 400, 380);
PImage img16;
img = loadImage("15kansas.png");
image(img, 400, 380);
PImage img17;
img = loadImage("16oklahoma.png");
image(img, 400, 380);
PImage img18;
img = loadImage("17texas.png");
image(img, 400, 380);
PImage img19;
img = loadImage("18louisiana.png");
image(img, 400, 380);
PImage img20;
img = loadImage("19arkansas.png");
image(img, 400, 380);
PImage img21;
img = loadImage("20missouri.png");
image(img, 400, 380);
PImage img22;
img = loadImage("21iowa.png");
image(img, 400, 380);
PImage img23;
img = loadImage("22minnesota.png");
image(img, 400, 380);
PImage img24;
img = loadImage("23wisconsin.png");
image(img, 400, 380);
PImage img25;
img = loadImage("24illinois.png");
image(img, 400, 380);
PImage img26;
img = loadImage("25kentucky.png");
image(img, 400, 380);
PImage img27;
img = loadImage("26tennesse.png");
image(img, 400, 380);
PImage img28;
img = loadImage("27mississippi.png");
image(img, 400, 380);
PImage img29;
img = loadImage("28alabama.png");
image(img, 400, 380);
PImage img30;
img = loadImage("29florida.png");
image(img, 400, 380);
PImage img31;
img = loadImage("30georgia.png");
image(img, 400, 380);
PImage img32;
img = loadImage("31southcarolina.png");
image(img, 400, 380);
PImage img33;
img = loadImage("32northcarolina.png");
image(img, 400, 380);
PImage img34;
img = loadImage("33virginia.png");
image(img, 400, 380);
PImage img35;
img = loadImage("34indiana.png");
image(img, 400, 380);
PImage img36;
img = loadImage("35michigan.png");
image(img, 400, 380);
PImage img37;
img = loadImage("36ohio.png");
image(img, 400, 380);
PImage img38;
img = loadImage("37westvirginia.png");
image(img, 400, 380);
PImage img39;
img = loadImage("38pennsylvania.png");
image(img, 400, 380);
PImage img40;
img = loadImage("39maryland.png");
image(img, 400, 380);
PImage img41;
img = loadImage("40delaware.png");
image(img, 400, 380);
PImage img42;
img = loadImage("41conneticut.png");
image(img, 400, 380);
PImage img43;
img = loadImage("42newjersey.png");
image(img, 400, 380);
PImage img44;
img = loadImage("43newyork.png");
image(img, 400, 380);
PImage img45;
img = loadImage("44rhodeisland.png");
image(img, 400, 380);
PImage img46;
img = loadImage("45massachusetts.png");
image(img, 400, 380);
PImage img47;
img = loadImage("46vermont.png");
image(img, 400, 380);
PImage img48;
img = loadImage("47newhampshire.png");
image(img, 400, 380);
PImage img49;
img = loadImage("48maine.png");
image(img, 400, 380);
imageMode(CENTER);
image(UFO, mouseX,mouseY);
pushMatrix();
translate(width*0.10, height*0.8);
rotate(frameCount / 70.0);
noStroke ();
star(0, 0, 0.6, 10, 9);
popMatrix();
pushMatrix();
translate(width*0.45, height*0.1);
rotate(frameCount / 70.0);
noStroke ();
star(0, 0, 0.6, 10, 9);
popMatrix();
pushMatrix();
translate(width*0.9, height*0.8);
rotate(frameCount / 70.0);
noStroke ();
star(0, 0, 0.6, 12, 9);
popMatrix();
pushMatrix();
translate(width*0.4, height*0.9);
rotate(frameCount / 70.0);
noStroke ();
star(0, 0, 0.4, 7, 9);
popMatrix();
pushMatrix();
translate(width*0.86, height*0.25);
rotate(frameCount / 70.0);
noStroke ();
star(0, 0, 0.6, 10, 9);
popMatrix();
pushMatrix();
translate(width*0.2, height*0.9);
rotate(frameCount / 70.0);
noStroke ();
star(0, 0, 0.6, 10, 9);
popMatrix();
pushMatrix();
translate(width*0.88, height*0.08);
rotate(frameCount / 70.0);
noStroke ();
star(0, 0, 0.4, 6, 9);
popMatrix();
}
void star(float x, float y, float radius1, float radius2, int npoints) {
float angle = TWO_PI / npoints;
float halfAngle = angle/2.0;
beginShape();
for (float a = 0; a < TWO_PI; a += angle) {
float sx = x + cos(a) * radius2;
float sy = y + sin(a) * radius2;
vertex(sx, sy);
sx = x + cos(a+halfAngle) * radius1;
sy = y + sin(a+halfAngle) * radius1;
vertex(sx, sy);
}
endShape(CLOSE);
}
How weird, I was helping someone else with Tetris just last night!
With 12 days to do it, you could just learn to write code yourself and then write it yourself. But if you really do want to hire someone to help, reach out to me via email: tfguy44 at gmail dot com
Form a software startup. Find some investment capitalists who are willing to fund it. Then hire a bunch of really smart computer engineers who have spent years studying software, hardware, speech recognition, and AI. Also get some managers to motivate them, and some HR people to keep everyone in line. After a while, add a marketing team to push your brand and a sales team to sell the product they have created.
On a more serious note, your question is very broad. What exactly do you imagine such an assistant would do? Would it run on your computer, or some external hardware? Will it listen for your voice and accept voice commands? Or will you just type commands at it? Do you want it to look things up for you? Have access to edit your computers' files? Will it be integrated with your OS or not? Are you planning to write it in Processing?
Note that people on the forum also post work-for-hire here:
https://forum.processing.org/two/categories/events-opportunities
In general discussion it is usually assumed that you are wanting to learn to do things yourself.
On the forum there are freelancers ? Want to hire a person to hang an event handler on geometric shapes.
In my research to solve my usb 3.0 camera challenges i have found camera manufactures that supply a SDK with their API to call from other programs. They have versions for Windows but they don't say for java Can i import an api into processing to call directly?
If not I will need to write a utility in some version of C that I can call with switches from an open() command.
Never used windows C compiler
Anyway, if anybody can educate me i'd appreciate it.
An i may want to hire your services to write the utility.
Thanks Jeff Marc
Okay. Here are some edits that move the red squares in a random direction.
// =================================================================
//Variables
StopWatchTimer sw;
float x = 0;
float y = 100;
float speed = 1;
RedRectangle[] rrs = new RedRectangle[4];
// =================================================================
// Main
void setup() {
size(700, 560);
println (millis());
sw = new StopWatchTimer();
sw.start();
rectMode(CENTER);
rrs[0] = new RedRectangle(555, 275);
rrs[1] = new RedRectangle(345, 475);
rrs[2] = new RedRectangle(115, 275);
rrs[3] = new RedRectangle(345, 75);
}
// Draw
void draw () {
time();
println(mouseX);
println(mouseY);
stroke (153);
fill (204, 102, 0);
for(int i=0;i<rrs.length;rrs[i++].draw());
frame.setTitle(int(frameRate) + " fps");
fill (235, 235, 0);
noStroke();
rect (mouseX, mouseY, 30, 30);
}
// =================================================================
// Other
void time() {
background(#C9C9C9);
fill(#000000);
textAlign(CENTER);
text(nf(sw.minute(), 2)+":"+nf(sw.second(), 2), 656, 14);
}
// =================================================
// classes
class StopWatchTimer {
int startTime = 0, stopTime = 0;
boolean running = false;
void start() {
startTime = millis();
running = true;
}
void stop() {
stopTime = millis();
running = false;
}
int getElapsedTime() {
int elapsed;
if (running) {
elapsed = (millis() - startTime);
} else {
elapsed = (stopTime - startTime);
}
return elapsed;
}
int second() {
return (getElapsedTime() / 1000) % 60;
}
int minute() {
return (getElapsedTime() / (1000*60)) % 60;
}
}
// ====================================================
//High Rez
void saveHiRes(int scaleFactor) {
PGraphics hires = createGraphics(width*scaleFactor, height*scaleFactor, JAVA2D);
beginRecord(hires);
hires.scale(scaleFactor);
draw();
endRecord();
hires.save("hires.png");
}
//=======================================================
//collision
boolean mouseOverRect(int x, int y, int w, int h) {
return (mouseX >= x && mouseX <= x+w && mouseY >= y && mouseY <= y+h);
}
// =====================================================
void move() {
x = x + speed;
if (x > width) {
x = 0;
}
}
void display() {
rect(x,y,30,10);
}
PVector randomDirection = new PVector(random(-2,2),random(-2,2));
class RedRectangle {
PVector p;
RedRectangle(float ipx, float ipy){
p = new PVector(ipx, ipy);
}
void draw(){
p.add(randomDirection);
rect(p.x, p.y, 20, 20);
}
}
// =================================================================
//Variables
StopWatchTimer sw;
float x = 0;
float y = 100;
float speed = 1;
// =================================================================
// Main
void setup() {
size(700, 560);
println (millis());
sw = new StopWatchTimer();
sw.start();
rectMode(CENTER);
}
// Draw
void draw () {
time();
println(mouseX);
println(mouseY);
stroke (153);
fill (204, 102, 0);
rect (555, 275, 50, 50);
rect (345, 475, 50, 50);
rect (115, 275, 50, 50);
rect (345, 75, 50, 50);
frame.setTitle(int(frameRate) + " fps");
fill (235, 235, 0);
noStroke();
rect (mouseX, mouseY, 30, 30);
}
// =================================================================
// Other
void time() {
background(#C9C9C9);
fill(#000000);
textAlign(CENTER);
text(nf(sw.minute(), 2)+":"+nf(sw.second(), 2), 656, 14);
}
// =================================================
// classes
class StopWatchTimer {
int startTime = 0, stopTime = 0;
boolean running = false;
void start() {
startTime = millis();
running = true;
}
void stop() {
stopTime = millis();
running = false;
}
int getElapsedTime() {
int elapsed;
if (running) {
elapsed = (millis() - startTime);
} else {
elapsed = (stopTime - startTime);
}
return elapsed;
}
int second() {
return (getElapsedTime() / 1000) % 60;
}
int minute() {
return (getElapsedTime() / (1000*60)) % 60;
}
}
// ====================================================
//High Rez
void saveHiRes(int scaleFactor) {
PGraphics hires = createGraphics(width*scaleFactor, height*scaleFactor, JAVA2D);
beginRecord(hires);
hires.scale(scaleFactor);
draw();
endRecord();
hires.save("hires.png");
}
//=======================================================
//collision
boolean mouseOverRect(int x, int y, int w, int h) {
return (mouseX >= x && mouseX <= x+w && mouseY >= y && mouseY <= y+h);
}
// =====================================================
void move() {
x = x + speed;
if (x > width) {
x = 0;
}
}
void display() {
rect(x,y,30,10);
}``
@mbuck -- a few thoughts:
Here is a simplified example of some of these approaches, based on your code. Press RIGHT and LEFT keys to move through your sample data.
# forum.processing.org/two/discussion/22301/animating-through-a-for-loop-in-python-mode
import re
index = 0
datalist = []
statecoor = {
'Alabama': [732, 440],
'Alaska': [272, 573],
'Arizona': [260, 393],
'Arkansas': [620, 402],
'California': [120, 297],
'Colorado': [385, 300],
'Connecticut': [1076, 252],
'Delaware': [1072, 325],
'Florida': [853, 546],
'Georgia': [801, 440],
'Hawaii': [121, 562],
'Idaho': [252, 169],
'Illinois': [671, 273],
'Indiana': [725, 274],
'Iowa': [598, 234],
'Kansas': [512, 313],
'Kentucky': [756, 326],
'Louisiana': [624, 484],
'Maine': [982, 94],
'Maryland': [989, 340],
'Massachusetts': [1104, 174],
'Michigan': [744, 193],
'Minnesota': [578, 145],
'Mississippi': [676, 444],
'Missouri': [616, 317],
'Montana': [342, 102],
'Nebraska': [493, 245],
'Nevada': [196, 258],
'New Hampshire': [954, 156],
'New Jersey': [1002, 266],
'New Mexico': [366, 400],
'New York': [901, 177],
'North Carolina': [872, 358],
'North Dakota': [484, 110],
'Ohio': [782, 265],
'Oklahoma': [526, 385],
'Oregon': [149, 145],
'Pennsylvania': [865, 232],
'Rhode Island': [1016, 202],
'South Carolina': [842, 402],
'South Dakota': [482, 178],
'Tennessee': [734, 369],
'Texas': [494, 481],
'Utah': [280, 282],
'Vermont': [932, 144],
'Virginia': [870, 310],
'Washington': [180, 65],
'Wisconsin': [652, 173],
'West Virginia': [822, 292],
'Wyoming': [361, 201]
}
sppcolor = {
'Campylobacter': [204, 114, 62],
'Clostridium': [86, 204, 62],
'Escherichia': [255, 114, 103],
'Listeria': [167, 255, 179],
'Salmonella': [205, 153, 123]
}
def setup():
global map_blank
datafile = open('fooddata_1.txt', 'r')
map_blank = loadImage('map_blank.jpg')
for line in datafile:
txt_re = re.search(r'(\d{4}),(\d{1,2}),(\w+\s*\w*),(\w+),(\d+)', line)
datalist.append([txt_re.group(1), txt_re.group(
2), txt_re.group(3), txt_re.group(4), txt_re.group(5)])
background(0)
size(1280, 688)
loop()
def draw():
image(map_blank, 0, 0, width, height)
elements = datalist[index]
yr = elements[0]
mon = int(elements[1])
state = elements[2]
species = elements[3]
num = elements[4]
noStroke()
spp = sppcolor[species]
R = spp[0]
G = spp[1]
B = spp[2]
fill(R, G, B, 125)
csize = 10 * sqrt(float(num) / 3.1415) # 5 *
coor = statecoor[state]
x = coor[0]
y = coor[1]
ellipse(x, y, csize, csize)
fill(255)
estr = str(yr) + " " + str(mon) + " " + state + " " + species + " " + str(num)
text(estr, 1000, 600)
def keyPressed():
global index
if keyCode==RIGHT:
index = index+1
if keyCode==LEFT:
index = index-1
index = constrain(index, 0, len(datalist)-1)
I myself did find Processing when I was trying to learn coding (I learnt it as hobby), and it was really easy to learn from just the tutorials on the website. However, if you want more than that, there's a catch. Processing relies entirely on donations and volunteers for development and deployment both, and cannot afford to either hire developers to create better websites, nor teachers to write better tutorials (not really required, the existing ones are good enough), and probably not even host another website for the sake of what you're saying.
So unless you're willing to invest both time and money, I very much doubt that anything will be possible. For example, even if you build some sort of tutorial website, how will you promote it? Through the forum? Not likely, there's very few people who'll notice. The Processing website? I doubt they'd allow it, and even if they did, it may not help. Through advertisements? We'd need a lot of money.
Hello Guys and Gals,
I'm currently looking for a freelance programmer to hire who can help with a project of mine!
This may be an on-going role for the right person but initially will be short term paid work, but first, a little about the project!
I am in need of a program (GUI preferably) that can rip a Height map from a 3D engines and Topographical programs (Unity/Cryengine/Unreal/Google Earth ect), and convert this height map into a Gray-scale Array.
I then need this Array of '0-255' values to be sent to a Grid of Motors as an overlay. This Array data needs to scale (bigger/smaller) to the Motor Grid. It also needs to 'average' out the values over each Grid if there are too many Values for one Grid square.
This Data should be sent automatically to the Grid squares as soon as processed.
Similar to this example below, the first third represents a Height map from a program, second third the Gray-scale array and the far right third as a Grid of Motors, with the 0-255 values accordingly.
If you know you're able to do this, or know someone who is... Get them to message me either on this forum or at bdotthompsonatoutlookdotcom
If you have any questions feel free to ask!
Thanks for your time!
Ben.
@jeremydouglass -- Here it is. I've only had success with some minor changes. Thanks again!
import re
def setup():
datafile = open('fooddata_1.txt','r')
map_blank = loadImage('map_blank.jpg')
for line in datafile:
txt_re = re.search(r'(\d{4}),(\d{1,2}),(\w+\s*\w*),(\w+),(\d+)',line)
datalist.append([txt_re.group(1),txt_re.group(2),txt_re.group(3),txt_re.group(4),txt_re.group(5)])
background(0)
size(1280,688)
frameRate(1)
loop()
datalist = []
statecoor = {
'Alabama':[732,440],
'Alaska':[272,573],
'Arizona':[260,393],
'Arkansas':[620,402],
'California':[120,297],
'Colorado':[385,300],
'Connecticut':[1076,252],
'Delaware':[1072,325],
'Florida':[853,546],
'Georgia':[801,440],
'Hawaii':[121,562],
'Idaho':[252,169],
'Illinois':[671,273],
'Indiana':[725,274],
'Iowa':[598,234],
'Kansas':[512,313],
'Kentucky':[756,326],
'Louisiana':[624,484],
'Maine':[982,94],
'Maryland':[989,340],
'Massachusetts':[1104,174],
'Michigan':[744,193],
'Minnesota':[578,145],
'Mississippi':[676,444],
'Missouri':[616,317],
'Montana':[342,102],
'Nebraska':[493,245],
'Nevada':[196,258],
'New Hampshire':[954,156],
'New Jersey':[1002,266],
'New Mexico':[366,400],
'New York':[901,177],
'North Carolina':[872,358],
'North Dakota':[484,110],
'Ohio':[782,265],
'Oklahoma':[526,385],
'Oregon':[149,145],
'Pennsylvania':[865,232],
'Rhode Island':[1016,202],
'South Carolina':[842,402],
'South Dakota':[482,178],
'Tennessee':[734,369],
'Texas':[494,481],
'Utah':[280,282],
'Vermont':[932,144],
'Virginia':[870,310],
'Washington':[180,65],
'Wisconsin':[652,173],
'West Virginia':[822,292],
'Wyoming':[361,201]
}
sppcolor = {
'Campylobacter': [204,114,62],
'Clostridium': [86,204,62],
'Escherichia': [255,114,103],
'Listeria': [167,255,179],
'Salmonella': [205,153,123]
}
def draw():
map_blank = loadImage('map_blank.jpg')
image(map_blank,0,0)
moniter = 1
yriter = 1998
for elements in datalist:
yr = elements[0]
mon = int(elements[1])
state = elements[2]
species = elements[3]
num = elements[4]
csize = 5*sqrt(float(num)/3.1415)
spp = sppcolor[species]
R = spp[0]
G = spp[1]
B = spp[2]
coor = statecoor[state]
x = coor[0]
y = coor[1]
print(moniter)
if mon != moniter:
print(mon)
image(map_blank,0,0)
fill(R,G,B,125)
noStroke()
ellipse(x,y,csize,csize)
fill(255)
text(mon,1000,600)
moniter += 1
if mon == moniter:
fill(R,G,B,125)
noStroke()
ellipse(x,y,csize,csize)
I am attempting to loop through a 2D list in processing using python syntax drawing a map of food illness outbreaks for each month. I've been having numerous issues with bugs in the python module but this is what I have so far.
Example of file:
1998,1,Maryland,Salmonella,5
1998,1,California,Salmonella,26
1998,1,California,Salmonella,4
1998,2,Nebraska,Clostridium,45
1998,2,Florida,Clostridium,3
1998,2,Florida,Clostridium,3
1998,2,Colorado,Clostridium,10
Code: import re def setup(): datafile = open('fooddata_1.txt','r') map_blank = loadImage('map_blank.jpg')
for line in datafile:
txt_re = re.search(r'(\d{4}),(\d{1,2}),(\w+\s*\w*),(\w+),(\d+)',line)
datalist.append([txt_re.group(1),txt_re.group(2),txt_re.group(3),txt_re.group(4),txt_re.group(5)])
background(0)
size(1280,688)
frameRate(1)
noLoop()
datalist = []
statecoor = {
'Alabama':[732,440],
'Alaska':[272,573],
'Arizona':[260,393],
'Arkansas':[620,402],
'California':[120,297],
'Colorado':[385,300],
'Connecticut':[1076,252],
'Delaware':[1072,325],
'Florida':[853,546],
'Georgia':[801,440],
'Hawaii':[121,562],
'Idaho':[252,169],
'Illinois':[671,273],
'Indiana':[725,274],
'Iowa':[598,234],
'Kansas':[512,313],
'Kentucky':[756,326],
'Louisiana':[624,484],
'Maine':[982,94],
'Maryland':[989,340],
'Massachusetts':[1104,174],
'Michigan':[744,193],
'Minnesota':[578,145],
'Mississippi':[676,444],
'Missouri':[616,317],
'Montana':[342,102],
'Nebraska':[493,245],
'Nevada':[196,258],
'New Hampshire':[954,156],
'New Jersey':[1002,266],
'New Mexico':[366,400],
'New York':[901,177],
'North Carolina':[872,358],
'North Dakota':[484,110],
'Ohio':[782,265],
'Oklahoma':[526,385],
'Oregon':[149,145],
'Pennsylvania':[865,232],
'Rhode Island':[1016,202],
'South Carolina':[842,402],
'South Dakota':[482,178],
'Tennessee':[734,369],
'Texas':[494,481],
'Utah':[280,282],
'Vermont':[932,144],
'Virginia':[870,310],
'Washington':[180,65],
'Wisconsin':[652,173],
'West Virginia':[822,292],
'Wyoming':[361,201]
}
sppcolor = {
'Campylobacter': [204,114,62],
'Clostridium': [86,204,62],
'Escherichia': [255,114,103],
'Listeria': [167,255,179],
'Salmonella': [205,153,123]
}
def draw():
map_blank = loadImage('map_blank.jpg')
image(map_blank,0,0)
moniter = 1
yriter = 1998
for elements in datalist:
yr = elements[0]
mon = int(elements[1])
state = elements[2]
species = elements[3]
num = elements[4]
csize = 5*sqrt(float(num)/3.1415)
spp = sppcolor[species]
R = spp[0]
G = spp[1]
B = spp[2]
coor = statecoor[state]
x = coor[0]
y = coor[1]
if mon != moniter:
image(map_blank,0,0)
fill(R,G,B,125)
noStroke()
ellipse(x,y,csize,csize)
fill(255)
text(mon,1000,600)
moniter += 1
else:
fill(R,G,B,125)
noStroke()
ellipse(x,y,csize,csize)
Map:
Unfortunately, with my current code I just end up with a map of the last month's outbreaks. I assume that this is because draw() loops through the whole file and then draws the final image. Is there a way that I can modify my code to force it to draw each month individually?
Thanks for all of your help!
I am using a recursive trig function to make super high definition symmetrical spiral shapes that morph into one another, but because of the computation involved, it is very slow: ~6 hours for a minute of footage (1440 frames) on my mbp.
The P2D renderer doesn't make it go that much faster on my computer, but I thought there might be a way to make use of a GPU instance on EC2 via OpenGL?
Thanks to one of Daniel Shiffman's tutorials, I managed to get a sketch running on EC2 and exporting .png files using the default renderer - would I just be better off getting a compute instance and using the default renderer? I was curious so I hired a larger compute instance, but it rendered the frames only very slightly faster than the free tier instance.
Any advice / pointers / resources wrt rendering headless on EC2 would be amazing!!
Post calls for paid work under "Events and Opportunities":
...see previous examples:
@prince_polka That goes against the entire point of learning - if you just need a solution you can always hire a developer to give you a working solution.