Drawing Application need help !
in
Programming Questions
•
1 month ago
Hi,
I need help creating an erase for the this drawing application. It is a simple code and you can see that I have used PGraphics layer where I am drawing which is transparent too. So question is how to create an eraser for this transparent layer ?
I know I can do this other way around but
I just want it in this way.
- PGraphics fakeLayer;
- void setup()
- {
- size(800, 400);
- smooth();
- fakeLayer = createGraphics(width, height);
- }
- void draw()
- {
- background(255);
- grids();
- fakeLayer.beginDraw();
- if(mousePressed){
- fakeLayer.stroke(0);
- fakeLayer.line(mouseX, mouseY, pmouseX, pmouseY);
- }
- fakeLayer.endDraw();
- image(fakeLayer, 0, 0);
- }
- int dodge=50;
- void grids() {
- for (int i=0;i <width;i+=dodge) {
- for (int j=0;j<height;j+=dodge) {
- fill(0);
- textSize(8);
- text("+", i, j);
- }
- }
- }
1