Processing Objekte ausschneiden?

Hallo meine sehr geehrten Herren/innen! Ich hoffe Sie hatten einen angenehmen Tag… doch wie wir alle wissen soll man den Tag nicht vor dem Abend loben. Deswegen wollte ich fragen, ob jemand weiß, wie man Objekte voneinander differenzieren kann. Ich habe eine Variation an Himmelskörpern modelliert und bin bei dem Mond auf das Problem gestoßen, dass die Körper (wenn ich einen anderen Hintergrund nehme) nicht die gewünschte Form annehmen. Die frage ist jetzt, ob es irgendwie möglich ist zwei Körper auszuschneiden oder einen Körper transparent für den Hintergrund zu machen. Ich hoffe Ihr habt einen schönen Tag und könnt mir helfen, da bei mir mittlerweile Hopfen und Malz verloren ist!

Anbei der Processing Code:

<void setup () {

size (1920,1080);

background(255);

}

public void cloud(int a, int b, int c) {

noStroke();

fill(#F5F0F0);

ellipse(a,b,c,c);

ellipse(a-0.6c,b+0.15c,c,c);

ellipse(a-1.2c,b+0.5c,c,c);

ellipse(a+0.6c,b+0.15c,c,c);

ellipse(a+1.2c,b+0.5c,c,c);

rect(a-1.2c,b+0.4c,2.4c,0.6c);

}

public void moon(int a, int b, int c,int f){

//Mond

noStroke();

fill(#F5EEAF);

ellipse (a, b,c, c);

fill (f);

ellipse (a+0.4c, b,c1.1, c*1.1);

}

public void sun(int x, int y, int w, int h, int w1, int h1, int x1, int y1){

// Sonne

noStroke();

fill (255,255,0);

ellipse (x, y,w, h);

//Sonnenstrahlen

rect (x-w10.5, y-y1, w1, -h1);

rect(x-w10.5, y+y1, w1, h1);

rect (x-x1,y-w10.5,-h1,w1);

rect (x+x1,y-w10.5,h1,w1);

translate(x,y);

rotate(PI/4);

rect (0.5w1, -h-0.25h1, w1, h1);

rect (0.5w1, 0.5h+0.25h1, w1, h1);

rotate(PI/4);

rotate(PI/4);

rect (0.5w1, -h-0.25h1, w1, h1);

rect (0.5w1, 0.5h+0.25h1, w1, h1);

rotate(PI/4);

rotate(PI);

translate(-x,-y);

}

void draw(){

sun(700,250,200,200,5,100,115,115);

moon(1000,400,300, 0);

cloud(500,600,250);

(2 votes)
Loading...

Similar Posts

Subscribe
Notify of
2 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
QLQuadratAchtel
1 year ago

What would happen to me is that you simply use the rgba.

So not fill(f) but fill(red(f), green(f), blue(f), 100);

where 100 stands for transparency.

Alternatively, you would look at the mask() function of PGraphics, but I believe that the function only works with PGraphics objects and not with regular processing objects.