Git Product home page Git Product logo

Comments (5)

 avatar commented on August 17, 2024

+1

from acedrawingview.

prrane avatar prrane commented on August 17, 2024

well, that is how it's implemented! Eraser in real world is nothing but a magical pen which gives back you White Paper to scratch more!
Here, Eraser and a White Colored Pen are abstractions used to understand layman in a proper Domain Terms; I hope this clears the confusion.

from acedrawingview.

0xPr0xy avatar 0xPr0xy commented on August 17, 2024

To be able to set the background color to white, and still use the eraser tool change the following pieces of code:

In ACEDrawingTools.m
- (void)draw
{
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSaveGState(context);
    CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
    CGContextAddPath(context, path);
    CGContextSetLineCap(context, kCGLineCapRound);
    CGContextSetLineWidth(context, self.lineWidth);

    // disable blend mode and set stroke color to white since we do not want a transparent bg
    // https://github.com/acerbetti/ACEDrawingView/issues/8
    // CGContextSetBlendMode(context, kCGBlendModeClear);

    CGContextStrokePath(context);
    CGContextRestoreGState(context);
}
In ACEDrawingView.m
- (void)configure
{
    // init the private arrays
    self.pathArray = [NSMutableArray array];
    self.bufferArray = [NSMutableArray array];

    // set the default values for the public properties
    self.lineColor = kDefaultLineColor;
    self.lineWidth = kDefaultLineWidth;
    self.lineAlpha = kDefaultLineAlpha;

    // set the transparent background
    // set to white instead... 
    // https://github.com/acerbetti/ACEDrawingView/issues/8

    self.backgroundColor = [UIColor whiteColor];

    self.originalFrameYPos = self.frame.origin.y;
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];
}


- (void)updateCacheImage:(BOOL)redraw
{
    // init a context
    UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0);

    // draw white rectangle to use as background as workaround for
    // https://github.com/acerbetti/ACEDrawingView/issues/8

    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
    CGContextFillRect(context, self.bounds);

    if (redraw) {
        // erase the previous image
        self.image = nil;

        // load previous image (if returning to screen)
        [[self.prev_image copy] drawInRect:self.bounds];

        // I need to redraw all the lines
        for (id<ACEDrawingTool> tool in self.pathArray) {
            [tool draw];
        }
    } else {
        // set the draw point
        [self.image drawAtPoint:CGPointZero];
        [self.currentTool draw];
    }
    // store the image
    self.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
}

from acedrawingview.

xiao99xiao avatar xiao99xiao commented on August 17, 2024

@0xPr0xy 's code wouldn't solve it when the drawingView load a UIImage as background, Just to make it clear.

from acedrawingview.

Alisha786 avatar Alisha786 commented on August 17, 2024

In My project i can change the background color when i am drawing,any body resolve this issue?? please explain

from acedrawingview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.