简体   繁体   English

如何在处理中加载的 png 图像上创建颜色剪贴蒙版?

[英]How do I create a color clipping mask on a loaded png image in processing?

Im using processing with java.我正在使用 java 进行处理。 I have a transparent background png drawing I made, it sort of looks like an abstract leaf, sort of like matisse.我有一个透明的背景 png 绘图,它看起来有点像抽象的叶子,有点像马蒂斯。 I know how to create shapes with random colors chosen from an array, so i can display that shape with different background colors for each frame in a loop, saving each.我知道如何使用从数组中选择的随机 colors 创建形状,因此我可以为循环中的每个帧显示具有不同背景 colors 的形状,保存每个。 what I want to do next is create another layer over the drawing that is populated with a random color from my array, but to have that layer display only on the pixels from the underlying png that is loaded.我接下来要做的是在绘图上创建另一个图层,该图层填充了我的数组中的随机颜色,但是让该图层仅显示在加载的底层 png 的像素上。

the end result is the ability to put out an endless number of randomly colored versions of that leaf design, with a random background color.最终结果是能够推出无限数量的随机颜色版本的叶子设计,具有随机背景颜色。 I just havent figured out how to create this kind of clipping mask effect.我只是还没弄清楚如何创建这种剪贴蒙版效果。

You can use the leaf image as a mask for the dynamically colored object.您可以使用叶子图像作为动态着色 object 的mask This will apply the alpha channel (transparency) to the masked image.这会将 Alpha 通道(透明度)应用于蒙版图像。 mask operates on images, so you'll need to draw your color fill to a PGraphics or PImage and apply the mask to that image. mask对图像进行操作,因此您需要将颜色填充绘制到PGraphicsPImage并将遮罩应用于该图像。

Depending on the specifics of the effect you're trying to achieve, you might also be able to simply apply a color tint to the leaf image to change to the desired color.根据您要达到的效果的具体情况,您也可以简单地将tint应用到叶子图像以更改为所需的颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM