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