Im新增至處理。我想將.jpg或.png放在曲線和橢圓上,以便它們只能看到圖像透明的位置。 我的代碼如下。問題在於透明區域不完全透明,但是透明白色和不透明部分也降低了不透明度。處理:曲線上的透明圖像
PImage img;
void setup() {
size(300,500);
frameRate(30);
strokeWeight(4);
img = loadImage("sziluettmeret.jpg");
}
void draw() {
background(0, 50, 70);
stroke(0,70,90);
noFill();
beginShape();
curveVertex(-100, -100);
curveVertex(10, 10);
curveVertex(250, 250);
curveVertex(300, 300);
endShape();
fill(255);
ellipse(20 ,20,15,15);
noFill();
tint(255, 100);
image(img, 0, 0);
}
UPDATE:
我有這個在我的代碼:
loadPixels();
for(int i=0; i < img.pixels.length; i++) {
tmpColor = img.pixels[i];
tmpRed = red(tmpColor);
tmpGreen = blue(tmpColor);
tmpBlue = green(tmpColor);
tmpAlpha = 255 - ((tmpRed + tmpGreen + tmpBlue)/3);
img.pixels[i] = color(2*tmpRed,tmpGreen/2,tmpBlue,0);
if(0xFFFFFF == tmpColor)
}
updatePixels();
圖片不變得透明。 (但它變成紫色,所以循環肯定會在每個像素上運行)
「,以便他們只能看到圖像透明的位置。」誰可以看到什麼?你只想在抽獎中看到圖像嗎?也許是面具?請讓自己更清楚。 – 2013-03-19 07:42:58