I have a view on which I am drawing some text using Path on canvas. Now I need to clear only the last drawn path i.e. drawn without clearing the whole view because I want to further redraw and re-clear path.
I have already used draw.Color(Color.BLACK) but this turns my whole screen into black, but I need to clear only the last drawn path not the whole view.
Related
Basically I'm trying to make a change to an already drawn canvas. There is a portion of it that will change based on user input. Redrawing the entire canvas takes too much time, so I was thinking of making a separate canvas using the same view and holder, and just drawing the item that changes on top of the canvas. The bitmap I'm drawing over it appears to completely wipe out the previous canvas once drawn. Any way around this?
To ask a simpler question, I need to be able to draw on top of an existing view(surfaceview in this case) without erasing it.
That doesn't make much sense since the Canvas instance is a single one that is propagated top-down through the view hierarchy. If you want to refresh just a piece of your custom view, you can use methods such as view.invalidate(Rect) or view.invalidate(left, top, right, bottom).
I have a fullscreen custom view in my activity where I have to draw paths that are formed by a line each one. Since my view supports scaling, depending on how zoomed in the view is, the paths get to big and therefore the view becomes slow, even crashing sometimes. What I want to know is if there's some built-in function where I can draw only the part of the path that is actually inside the canvas.
I've tried using Path.op with a rect the size of the screen, but didn't get any results; it either returns an empty path or a path that contours the screen. Same thing with Canvas.clipPath(). Passing a rect on through invalidate() also doesn't work for me since the said path IS insterecting the drawing area.
It's also worth metioning that I'm using paths because I need to use a PathDashPath effect. So, if there's a way os doing that with drawLine, it'd also help.
Hello All,
I have erased an image using mPaint.setXfermode(new PorterDuffXfermode(Mode.DST_OUT)); on touch events, now I want to undo this drawing (basically removing the path which were drawn earlier) on touch events. I don't want to draw the whole path at once instead clear the path point wise as finger move above these paths. I have stored all tha paths in an array list. Any Idea how can I do this. I'm able to remove the whole path but not point wise redrawing.
I've got the following problem:
Currently, I draw a picture within a SurfaceView. Moreover, the user is allowed to
draw on this picture. Thereby the draw "figures" are handled as path-objects. In addition, a user can pan as well as zoom the image. The handling of the zoom and pan is done by using a matrix. The picture as well as every path object has the its own matrix.
So, if the user for example started the app, a picture is shown. Then, the user can add one path object after the other and so on. We create for every object a new matrix. For example, if a user zooms in then the path objects as well as the picture are zoomed.
Now my goal is that if a path object is added while the picture is zoomed in or zoomed out, then the path object should be added at the touched position but it should be scaled to the scale of the other already drawn objects. In other, simpler words: If I add a path object it should have the same scale as the already exisitng objects, but it should appear at its new position:
Until now I tried different ways for solving the problem, but nothing did work:
First, of all I scaled the Canvas with one single matrix instead of scaling every path object on its own. But then, the added path objects appeared at a wrong position while the picture was zoomed in.
Next, I tried to get the current scale and afterwards, I scaled the path object when I created it. This did not work either. For non of the methodes preScale,postScale,setScale ... Either the whole path was wrong or it appeared again at a wrong position.
Does anyone know a solution?
I have two bitmap overlapped .The top bitmap is transparent and when user touch to screen i copy pixels from another bitmap to top bitmap.My goal is to give to users the feeling of erasing image with touching to see another image.However it is not working properly especially when user drags his finger too fast on the screen.I made a few tests and i beleive drawing bitmaps to the canvas every time cause the lag but i don't know how to fix it.
It looks like a Canvas or Bitmap isn't redrawn until you wipe it yourself. That means you just have change the alpha value of the pixels in the top Canvas/bitmap/thingy that are being "painted" rather than redrawing the entire canvas for every update.