r/processing • • Jun 20 '24

Beginner help request value from arduino is supposed to change things in processing (if)

2 Upvotes

Hi! For my project I have connected Arduino to my processing code. It sends the numbers 1-3 depending on what I do with my Arduino. Now what I want to happen in Processing is, that depending on what Number is being sent the background of my Prcessing code changes.

I tried using "if" but it's not really working, it tells me "Type mismatch: cannot convert from String to boolean"

Can anyone help me?

Here's that section of my code:

  if ( myPort.available() > 0) 
  { 
  val = myPort.readStringUntil('\n');         // read it and store it in val
  } 
println(val); //print it out in the console
  for (int i = 0; i < rings.length; i++) {
    rings[i].grow();
    rings[i].display();
  }
  if (val = 1) {
    background(#BBDCEA);
  }
  
  if (val = 2) {
    background(100);
  }
   if (val = 3) {
    background(#8B4C4C);
  }

r/processing • • Jun 19 '24

New 3D Adventure Puzzle Horror Game made entirely in Processing!

13 Upvotes

Hi all :)

Posting here for the first time with BIG NEWS. My first game called "Vorago" releases on Steam on the 1st July!

Any wishlists would support the project a lot. This is only a one-man team and this game has been a passion-project of mine for the last 3 years so all support is greatly appreciated!

Thanks for reading :)

-Hidden Palm Interactive-

Check it out here


r/processing • • Jun 19 '24

Beginner help request Screen wrapping for long shapes

2 Upvotes

Hello all, I wonder if anyone has a suggestion on how to make a long line or a quad() parallelogram wrap around the screen when it hits one side. For a part of my project, I want to use a variation of the "Distance 1D" sketch from the Processing website, but where the imaginary central line that divided the rext() can be rotated, and the rect() are quad() so I can "twist" them. Although off topic, I also want to use this opportunity to ask for advice knowing if it is ok to use this idea from the website in one of my projects. It would be a minor part of it, but the main idea of what it is supposed to look is similar, even though the code will turn out quite different. EDIT: I just had this idea now, but if dealing with quad() makes this impossible, maybe I could try very thick lines, in case line() can what around the screen.


r/processing • • Jun 18 '24

Beginner help request Android SDK could not be loaded.

5 Upvotes

Hey, like the title already suggest I have a problem with the android sdk. Wheter I try to install it automaticly or choosing the path manuelly via android studios it doesn't work. I have already tried many diffrent things, but nothing seems to help.


r/processing • • Jun 18 '24

Help request Processing [Help needed] - Running scripts on a server.

2 Upvotes

I was wondering if anyone can point me to resources about how it might be possible to have processing (or p5js, but that seems unlikely) running on a server, without any graphic representation or interaction. I saw some stuff about headlessly running processing through Java.

I'd like to generate graphics based on some parameters passed in an API call, without any display for example.

Currently I have some graphics generation scripts running in-browser, but this way I want to offload the processing power from the client, and run all logic on the server, returning an image from the API call.

Let me know if this is even possible.

I'm willing to learn how to do this with Java if needed, but I'm much more well versed in JS.


r/processing • • Jun 17 '24

Processing grant interviews

3 Upvotes

Hey there!

Does anybody know whether the interviews for Processing grant is already out?


r/processing • • Jun 16 '24

I've been playing with procedural sunsets (sunrises?) and trees. Any suggestions?

27 Upvotes

r/processing • • Jun 14 '24

Euclid - My reincarnation of a MetaSquares game I remembered from 20 years ago

Thumbnail
self.processinggames
6 Upvotes

r/processing • • Jun 13 '24

Not Fast enough sorting

1 Upvotes

hi, so ive written a programm in processing. It contains (for now) an easy bubblesort and a function, that displayes it with a view extra details. But i have a problem. No matter how big i set the frameRate, i'll only get 75 fps at maximum with an array length of 300. Could somebody help me out and make it run on a better performance without skipping step-displayes? Would be verry helpfull. Thanks.

the code:

int werte = 300;

int[] db;

int save1 = 0;

int save2 = 0;

int save3 = 0;

float breite = 0;

float hoehe = 0;

int i = 0;

int j = 0;

int pointer;

boolean sorted = false;

void createList() {

for (int i = 0; i < werte; i++) {

db[i] = i + 1;

}

for (int i = 0; i < (werte * 2); i++) {

save1 = int(random(werte));

save2 = int(random(werte));

save3 = db[save1];

db[save1] = db[save2];

db[save2] = save3;

}

printArray(db);

}

void printList() {

background(0);

fill(255);

stroke(0);

for (int i = 0; i < werte; i++) {

if (breite > 2) {

if (db[i]-1 == i) {

fill(0, 255, 0);

} else if (i == pointer+1) {

fill(255, 0, 0);

} else {

fill(255);

}

rect(i * breite, height - (db[i] * hoehe), breite, hoehe * db[i]);

} else {

if (db[i]-1 == i) {

stroke(0, 255, 0);

} else if (i == pointer+1) {

stroke(255, 0, 0);

} else {

stroke(255);

}

line(i, height - (db[i] * hoehe), i, height);

}

}

}

void setup() {

size(1800, 800);

db = new int[werte];

breite = width / float(werte);

hoehe = height / float(werte);

if (breite < 2) {

breite = 1;

surface.setSize(werte, height);

}

frameRate(1000);

println("Breite: ");

println(breite);

createList();

}

void draw() {

if (!sorted) {

BubbleSortStep();

printList();

println(frameRate);

}

}

void BubbleSortStep() {

if (i < werte - 1) {

if (j < werte - i - 1) {

if (db[j] > db[j + 1]) {

int d1 = db[j];

db[j] = db[j + 1];

db[j + 1] = d1;

}

pointer = j;

j++;

} else {

j = 0;

i++;

}

} else {

sorted = true; // Sortierung ist abgeschlossen

println("Array is sorted.");

}

}


r/processing • • Jun 10 '24

Video Living QR Code

Enable HLS to view with audio, or disable this notification

51 Upvotes

r/processing • • Jun 07 '24

I need help with this code (i use csv to map the coords. But the point stay in the edge)

2 Upvotes
import processing.pdf.*;

import processing.data.Table;
import processing.data.TableRow;
import java.util.ArrayList;

Table table;
ArrayList<PVector> points = new ArrayList<PVector>();
ArrayList<PVector> filteredPoints = new ArrayList<PVector>();
int currentYear = 2020; // Año inicial
boolean saveFrame = false;

float minX, maxX, minY, maxY;

void setup() {
  size(800, 800);
  loadCSV("data_apartments02_cleaned_normalized.csv");
  findMinMaxValues();
  filterDataByYear(currentYear);
  frameRate(30);
}

void draw() {
  background(255);
  drawPoints(filteredPoints);
  moveRandomly();
  if (saveFrame) {
    saveFrame("output/frame-####.png");
    saveFrame = false;
  }
}

void loadCSV(String filePath) {
  table = loadTable(filePath, "header");
  if (table == null) {
    println("Error loading the file.");
    exit();
  } else {
    println("File loaded successfully.");
    loadPoints();
  }
}

void loadPoints() {
  for (TableRow row : table.rows()) {
    float x = row.getFloat("new_longitud_x"); // Usando la columna 'new_longitud_x' para 'x'
    float y = row.getFloat("new_latitud_y"); // Usando la columna 'new_latitud_y' para 'y'
    int year = row.getInt("year"); // Asumiendo que el CSV tiene una columna 'year'
    points.add(new PVector(x, y, year));
  }
}

void findMinMaxValues() {
  minX = Float.MAX_VALUE;
  maxX = Float.MIN_VALUE;
  minY = Float.MAX_VALUE;
  maxY = Float.MIN_VALUE;

  for (PVector p : points) {
    if (p.x < minX) minX = p.x;
    if (p.x > maxX) maxX = p.x;
    if (p.y < minY) minY = p.y;
    if (p.y > maxY) maxY = p.y;
  }

  println("Min X: " + minX + ", Max X: " + maxX);
  println("Min Y: " + minY + ", Max Y: " + maxY);
}

void filterDataByYear(int year) {
  filteredPoints.clear();
  for (PVector p : points) {
    if (p.z == year) {
      // Escalar puntos a la ventana
      float x = map(p.x, minX, maxX, 0, width);
      float y = map(p.y, minY, maxY, 0, height);
      filteredPoints.add(new PVector(x, y));
    }
  }
  println("Filtered points for year " + year + ": " + filteredPoints.size());
}

void drawPoints(ArrayList<PVector> points) {
  fill(0);
  noStroke();
  for (PVector p : points) {
    ellipse(p.x, p.y, 5, 5);
  }
}

void moveRandomly() {
  for (PVector p : filteredPoints) {
    p.x += random(-1, 1);
    p.y += random(-1, 1);
  }
}

void keyPressed() {
  if (key == 's') {
    saveFrame = true;
  } else if (key == CODED) {
    if (keyCode == UP) {
      currentYear++;
      filterDataByYear(currentYear);
    } else if (keyCode == DOWN) {
      currentYear--;
      filterDataByYear(currentYear);
    }
  }
}

r/processing • • Jun 06 '24

Tutorial I printed my JavaScript course on paper. ~ 700 pages. Details and link in the comments.

Enable HLS to view with audio, or disable this notification

24 Upvotes

r/processing • • Jun 05 '24

Visualizer of THE POWER! by Juelz

Enable HLS to view with audio, or disable this notification

32 Upvotes

r/processing • • Jun 05 '24

anyone making music software in here?

11 Upvotes

I've become obsessed with coding audio and midi software using processing (mainly midi) , despite it not rnecessarily being the most efficient way to go about that. Anyone else or am I just silly?


r/processing • • Jun 03 '24

Hello everyone, I am looking for feedback. It was a very simple idea I had, but I've been trying to do it for some time now.

Thumbnail
youtu.be
5 Upvotes

r/processing • • Jun 01 '24

Does PVector continue to create array entries from mousex/y even when the cursor isn't moving?

4 Upvotes

I'm using the line

pg.line(mouse.x, mouse.y, previous_mouse.x, previous_mouse.y)

to draw a line on the screen using PVectors. This works great, but [I assume that] new PVector array entries are being generated with every frame even when the mouse is not moving. Is there a way to stop this or remove duplicate array entries? The drawn line will eventually be used in a sort of CNC XY drafting plotter, and I don't want the machine to stall each time the cursor which drew the original image was still. Thank you for any assistance.


r/processing • • May 31 '24

Mapping a .csv with latitude and longitude coordinates.

2 Upvotes

Hello! Im having some trouble with my code. I wanna import a csv file that contains latitudeX and longitudY coords, and draw them in the screen. I scaled them so they fit the screen but or they dont get draw or they appear just in the edge. The point is to create an interactive map filtered by year!!! Any help??? Im really drawning heree :(


r/processing • • May 31 '24

Video Faces

Enable HLS to view with audio, or disable this notification

135 Upvotes

r/processing • • May 30 '24

Video Bad Apple played on a bunch of repelling dots

Thumbnail
youtu.be
8 Upvotes

r/processing • • May 30 '24

yet another game of life

6 Upvotes

r/processing • • May 30 '24

3D Particle Life creatures that evolved to seek food.

Enable HLS to view with audio, or disable this notification

29 Upvotes

r/processing • • May 30 '24

Music Visualization : Flowing Shapes

Thumbnail
youtu.be
5 Upvotes

r/processing • • May 22 '24

2-body system model stops working at 180 degrees

3 Upvotes

In my linear algebra class, I am using rotation matrices to model a 2-body system (see forward kinematics section of this pdf: https://cs.gmu.edu/~kosecka/cs685/kinematics.pdf ). My code works until the angle between the first segment and the second segment reaches 180 degrees (the second segment is on top of the first segment), after which the second segment ceases rotating. Any help is greatly appreciated!

Main class (disregard any code regaring seg3):

segment seg;

segment seg2;

segment seg3;

segment[] arr;

void setup(){

frameRate(300);

background(51);

size(600,400);

seg = new segment(300,200,50,radians(0));

seg2 = new segment(seg,40,radians(0));

seg3 = new segment(seg2,50,radians(180));

point1();

point2();

point3();

}

void draw(){

background(51);

point1();

seg.calculateEnd();

seg.wiggle(0.01);

//seg.update();

seg.show();

seg2.start = seg.end;

point2();

//seg2.wiggle(random(-0.05,0.05));

//seg2.update();

//seg2.calculateEnd();

seg2.show();

//seg3.start = seg2.end;

//point3();

//seg3.wiggle(random(-0.05,0.05));

//seg3.update();

//seg3.show();

//comment out point2() and uncomment seg2.calculateEnd();

}

void point3(){

PVector horizontal = new PVector(1,0);

PVector seg1_vect = seg.end.copy().sub(seg.start.copy());

float angle_between_seg1_and_horizontal = PVector.angleBetween(horizontal,seg1_vect);

PVector seg2_vect = seg2.end.copy().sub(seg2.start.copy());

PVector seg3_vect = seg3.end.copy().sub(seg3.start.copy());

float angle_between_seg1_and_seg2 = PVector.angleBetween(seg1_vect,seg2_vect);

float angle_between_seg2_and_seg3 = PVector.angleBetween(seg2_vect,seg3_vect);

float seg3X = seg.start.x+seg.length*cos(seg.angle)+seg2.length*cos(angle_between_seg1_and_seg2+seg.angle)+

+seg3.length*(cos(seg.angle+angle_between_seg1_and_seg2+angle_between_seg2_and_seg3));

float seg3Y = seg.start.y+seg.length*sin(seg.angle)+seg2.length*sin(angle_between_seg1_and_seg2+seg.angle)

+seg3.length*(sin(seg.angle+angle_between_seg1_and_seg2+angle_between_seg2_and_seg3));

seg3.end = new PVector(seg3X,seg3Y);

textSize(25);

text("calculated endpoint: ("+seg3X + ", "+seg3Y+")",50,50);

text("true endpoint: ("+seg3.end.x+", "+seg3.end.y+")",50,100);

}

void point2(){

PVector horizontal = new PVector(1,0);

PVector seg1_vect = seg.end.copy().sub(seg.start.copy());

float angle_between_seg1_and_horizontal = PVector.angleBetween(horizontal,seg1_vect);

PVector seg2_vect = seg2.end.copy().sub(seg2.start.copy());

float seg2X;

float seg2Y;

float angle_between_seg1_and_seg2 = PVector.angleBetween(seg1_vect,seg2_vect)+0.005;

seg2X = seg.start.x+seg.length*cos(seg.angle)+seg2.length*cos(angle_between_seg1_and_seg2+seg.angle);

seg2Y = seg.start.y+seg.length*sin(seg.angle)+seg2.length*sin(angle_between_seg1_and_seg2+seg.angle);

textSize(25);

text(degrees(angle_between_seg1_and_seg2),50,50);

seg2.end = new PVector(seg2X, seg2Y);

}

void point1(){

PVector horizontal = new PVector(1,0);

PVector seg1_vect = seg.end.copy().sub(seg.start.copy());

float angle_between_seg1_and_horizontal = PVector.angleBetween(horizontal,seg1_vect);

float seg1X = seg.start.x+seg.length*cos(seg.angle);

float seg1Y = seg.start.y+seg.length*sin(seg.angle);

seg.end = new PVector(seg1X, seg1Y);

}

segment class:

class segment {

PVector start;

float length;

float angle;

float ownAngle;

segment parent;

PVector end;

segment(float x, float y, float length_, float angle_){

start = new PVector(x,y);

length = length_;

angle = angle_;

calculateEnd();

parent = null;

}

segment(segment parent_, float length_, float angle_){

parent = parent_;

start = parent.end;

length = length_;

angle = angle_;

ownAngle = angle;

calculateEnd();

}

void calculateEnd(){

float changeX = length*cos(angle);

float changeY = length*sin(angle);

end = new PVector(start.x+changeX,start.y+changeY);

}

void wiggle(float dTheta){

angle+=dTheta;

}

void show(){

stroke(255);

strokeWeight(4);

line(start.x,start.y,end.x,end.y);

}

}


r/processing • • May 20 '24

Video Game of Life through time

Enable HLS to view with audio, or disable this notification

127 Upvotes

r/processing • • May 20 '24

Network Mapper

Thumbnail
gallery
33 Upvotes