All posts by /r/processing

How do I get an object to follow another object?

Hey everyone, so what I'm trying to do is I have a ball bouncing around the screen and I want another ball to be following the same path as the first ball but a tad bit behind so it looks somewhat like a caterpillar.

Here's my code:

float x = 600;

float y = 300;

float xSpeed = 5;

float ySpeed = 5;

void setup(){

size(800, 600);

}

void draw(){

background(0);

x += xSpeed;

if (x > width || x < 0){

xSpeed *= -1;

}

y += ySpeed;

if (y > height || y < 0){

ySpeed *= -1;

}

ellipse(x,y,50,50);

}

submitted by /u/tnickster
[link] [comments]

How to tint an svg but preserve brightness values?

I've been trying to figure this out for 2 days now, so I hope somebody can help.

I need to load in svg files that have multiple values of gray within them and tint them with colors. So for example, say the svg file is an image of a rock and has 4 values of gray. I need to be able to display the rock as red and keep the differences between values in the different child shapes. In other words, I would like it to work just like PImage.tint().

I see there are tint() and setTint() methods to PShape but I can't seem to get them to work. I also though about recursing through the child shapes and reading each color individually and recoloring appropriately, but I couldn't even figure out how to read the color out in a way I understand.

Help, anyone?

submitted by /u/mwiederrecht
[link] [comments]

Question about printing on paper.

I'm trying to print out a picture on glossy photo paper. The problem is that when it goes to print the program is treating the image as if it's trying to print on normal printer paper. my printer uses two different inks for black, one for photo and one for normal printing. I was wondering if there is a way to set my program to expect to be printing on glossy photo paper rather than normal printer paper.

submitted by /u/dplusave
[link] [comments]