【发布时间】:2013-03-07 11:46:03
【问题描述】:
我是处理新手。我想在曲线和椭圆上放一个 .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);
}
更新:
我的代码中有这个:
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();
图片不透明。 (但它会变成紫色,所以循环肯定会在每个像素上运行)
【问题讨论】:
-
"这样他们就只能看到图像透明的地方。"谁能看到什么?您是否希望仅在绘图中看到图像?也许是面具?请让自己更清楚。
标签: image png jpeg processing transparent