r/processing

How to draw on top of something in P3D?

How to draw on top of something in P3D?

https://preview.redd.it/aotiefmsewjh1.png?width=1424&format=png&auto=webp&s=0afeec034d032fa837f806e40b1cf48eb3a3e704

```java

void setup() {

size(600, 600, P3D);

}

void draw() {

background(0);

ortho();

hint(DISABLE_DEPTH_TEST);

hint(DISABLE_DEPTH_MASK);

stroke(30);

fill(255, 0, 0);

rect(10, 10, 100, 100);

fill(0, 255, 0);

rect(0, 0, 400, 400);

}

```

How can I draw the second rectangle on top of the first one?
Right now the stroke of the first is coming threw the second rectangle.

Using P2D is not a option, neither is using translate.

reddit.com
u/clankill3r — 3 days ago
▲ 13 r/processing+1 crossposts

A simple(ish) Physarum (slime mold) simulation tutorial using p5.js mode in Processing

In case anyone is interested, I recorded a complete walkthrough of building a simple(ish) Physarum simulation from scratch using p5.js mode in the Processing editor.

The tutorial covers:

  • agent sensing
  • chemotaxis
  • trail deposition
  • diffusion and decay
  • parameter exploration

I particularly like the Physarum simulation because the basic multiagent chemotaxis idea can be applied to so many interesting projects. I'm curious if anyone else has (or is) working on projects based around chemotaxis.

youtube.com
u/tsoule88 — 7 days ago
▲ 31 r/processing+1 crossposts

SKETCH 04: Density Gradients -- RULE: The size of squares is mapped directly to their collumn position

u/Linquitivity — 11 days ago

SKETCH 05: Negative Space System // RULE: Canvas is carved away using radial distance to expand black "eraser" circles closer to the center

u/Linquitivity — 11 days ago

Improving old sketch, segmented lines following the previous positions of the mouse cursor

I'm trying to get back into Processing, I grabbed one of my old solutions to improve it.
What the code currently does is record the last positions of the mouse cursor into a couple of lists, x and y, that are used to draw lines with their points being previous positions of the mouse offset from each other, thus creating a weird effect where the points of the line segments follow the mouse's path, but the lines drawn inbetween bend and stretch to connect them.

I thought one way I could improve this code would be to have two variables which controlled: 1, the number of line segments, and 2, the number of previous positions.

I have gotten change number 2...kinda?, but I am not sure how I could do number 1.
I also dont understand why I added those if statements that reset the variables to 0.

Here is the code:

    int number_of_previous_positions = 100;
    int[] pastXCoordinates = new int[number_of_previous_positions];
    int i1=int(number_of_previous_positions*0.1),
      i2=int(number_of_previous_positions*0.2),
      i3=int(number_of_previous_positions*0.3),
      i4=int(number_of_previous_positions*0.4),
      i5=int(number_of_previous_positions*0.5),
      i6=int(number_of_previous_positions*0.6);
    
    int[] pastYCoordinates = new int[number_of_previous_positions];
    int j1=int(number_of_previous_positions*0.1),
      j2=int(number_of_previous_positions*0.2),
      j3=int(number_of_previous_positions*0.3),
      j4=int(number_of_previous_positions*0.4),
      j5=int(number_of_previous_positions*0.5),
      j6=int(number_of_previous_positions*0.6);
    
    void setup()
    {
      size (400, 400);
      strokeWeight(1);
      for (int i = 0; i < pastXCoordinates.length-1; i++)
        pastXCoordinates[i] = 0;
    
      for (int i = 0; i < pastYCoordinates.length-1; i++)
        pastYCoordinates[i] = 0;
      frameRate(60);
    }
    
    void draw()
    {
      background(122);
      pastXCoordinates[i1] = mouseX;
      pastYCoordinates[j1] = mouseY;
      line(mouseX, mouseY, pastXCoordinates[i6], pastYCoordinates[j6]);
      line(pastXCoordinates[i6], pastYCoordinates[j6], pastXCoordinates[i5], pastYCoordinates[j5]);
      line(pastXCoordinates[i5], pastYCoordinates[j5], pastXCoordinates[i4], pastYCoordinates[j4]);
      line(pastXCoordinates[i4], pastYCoordinates[j4], pastXCoordinates[i3], pastYCoordinates[j3]);
      line(pastXCoordinates[i3], pastYCoordinates[j3], pastXCoordinates[i2], pastYCoordinates[j2]);
      i1++;
      i2++;
      i3++;
      i4++;
      i5++;
      i6++;
      if (i1>pastXCoordinates.length-1)
        i1=0;
      if (i2>pastXCoordinates.length-1)
        i2=0;
      if (i3>pastXCoordinates.length-1)
        i3=0;
      if (i4>pastXCoordinates.length-1)
        i4=0;
      if (i5>pastXCoordinates.length-1)
        i5=0;
      if (i6>pastXCoordinates.length-1)
        i6=0;
    
    
      j1++;
      j2++;
      j3++;
      j4++;
      j5++;
      j6++;
      if (j1>pastYCoordinates.length-1)
        j1=0;
      if (j2>pastYCoordinates.length-1)
        j2=0;
      if (j3>pastYCoordinates.length-1)
        j3=0;
      if (j4>pastYCoordinates.length-1)
        j4=0;
      if (j5>pastYCoordinates.length-1)
        j5=0;
      if (j6>pastYCoordinates.length-1)
        j6=0;
    }
reddit.com
u/D_Orangeyes24 — 13 days ago