Processing 如何将我画的颜料的图像放回原处?
我想做的东西类似于绘画程序。 问题是当我画一些线(不仅仅是线,我画的所有东西都包括在本例中)时,这些线只在我画之前画的图像的后面 起初,我认为这只是代码顺序的问题。但事实并非如此 我只想在图像上画一些线,就像画画程序一样。Processing 如何将我画的颜料的图像放回原处?,processing,Processing,我想做的东西类似于绘画程序。 问题是当我画一些线(不仅仅是线,我画的所有东西都包括在本例中)时,这些线只在我画之前画的图像的后面 起初,我认为这只是代码顺序的问题。但事实并非如此 我只想在图像上画一些线,就像画画程序一样。 如下所示:您可以使用绘制工具绘制到单独的“层”中。 初始化实例后,可以使用beginDraw()/endDraw()中的典型绘图方法(如参考示例所示) 剩下的唯一一件事就是保存最终的图像,使用 下面是一个修改后的Examples>Basics>Image>LoadDispla
如下所示:您可以使用绘制工具绘制到单独的“层”中。 初始化实例后,可以使用
beginDraw()
/endDraw()
中的典型绘图方法(如参考示例所示)
剩下的唯一一件事就是保存最终的图像,使用
下面是一个修改后的Examples>Basics>Image>LoadDisplay示例,它在拖动鼠标时使用单独的PGraphics实例进行绘制,并在按下s
键时保存最终图像:
/**
* Based on Examples > Basics > Image > Load and Display
*
* Images can be loaded and displayed to the screen at their actual size
* or any other size.
*/
PImage img; // Declare variable "a" of type PImage
// reference to layer to draw into
PGraphics paintLayer;
void setup() {
size(640, 360);
// The image file must be in the data folder of the current sketch
// to load successfully
img = loadImage("moonwalk.jpg"); // Load the image into the program
// create a separate layer to draw into
paintLayer = createGraphics(width,height);
}
void draw() {
// Displays the image at its actual size at point (0,0)
image(img, 0, 0);
// Displays the paint layer
image(paintLayer,0,0);
}
void mouseDragged(){
// use drawing commands between beginDraw() / endDraw() calls
paintLayer.beginDraw();
paintLayer.line(mouseX,mouseY,pmouseX,pmouseY);
paintLayer.endDraw();
}
void keyPressed(){
if(key == 's'){
saveFrame("annotated-image.png");
}
}
你能重新措辞吗?理解你想问的问题是很有必要的。它是否类似于Photoshop中在图像顶部绘制的图层,但下面的原始图像图层不受上面图层上笔划的影响?是的,但当我保存图像时,它应该被保存为“受影响”(我怀疑这是正确的表达,因为缺乏处理知识……)这正是我想要做的!关于PGraphic参考资料的链接非常有用,谢谢您的帮助!