android - Erase paths that are redrawn out of a List -
I've been working on a drawing app for Android recently and I'm facing a problem now Whom I can not solve. The idea is to be able to draw on two drawing layers. While switching to the second layer, you only see the image of this layer, while while being in 1 layer you are looking at both the layers with a slightly transparent look.
To do this, I have been given two lists that have been prepared, Path and Paint.
Case MotionEvent.ACTION_DOWN: // Save Path to List Paint StrokePaint = New Paint (); Path stroke path = new path (); SetupDrawingPaint (strokePaint); // some initial strokes = new stroke (strokepath, strokepaint); // Object to save the path stroke. MovePath (touchX, touchY); If (drawing layer == 1) {strokeListL1.add (stroke); } And {stroke list L. 2.add (stroke); } // Draw Path Path.moveTo (touchX, touchY); break; Case MotionEvent.ACTION_MOVE: Stroke. LINEPath (Touch X, Touch Y); DrawingPath.lineTo (Touch X, Touch Y); break; Case Motion Event Action_up: canvas pathpath (drawingpath, drawing pent); DrawingPath.reset () Break; Invalid ();
Now the path in the onDraw () - method is drawn normally when the layer is changed, then the stroke object is pulled from the list.
canvas navbitmap (canvas bitmap, 0, 0, canvas paint); // layer (layers) if (layer changes) {if (drawing layer == 1) {for (stroke stroke: stroke list L1) canvas pathpath (stroke. Gatepath ()), stroke. Jetpent ()); (Stroke Stroke: Stroke List L2) {Paint Paint = Stroke. GatePint (); Paint.setAlpha (50); Canvas davarapath (stroke.artpath (), paint); }} And {for (stroke stroke: stroke list L2) {paint paint = stroke.gatepaint (); Paint.setAlpha (255); Canvas davarapath (stroke.artpath (), paint); }}} And canvas pathpath (drawingpath, drawing pent); LayerChanged = false;
And start the problems here until I change the layers, I'm working properly, but as soon as I change the layers instead of wiping it, the whole canvas Clears. The method of deletion looks like this:
Public Zero Setage (Boolean Errors) {eraseMode = erase; If (irsaidide) drawing picture SpaceFormode (new portterfix firmmode (porterdough.mod.clar)); And drawing papers Six exemptions (null); }
If I wipe something before changing the layer, then "earring stroke" will also be drawn in one color, once I change it back to that layer, I'm not sure If I want to take myself to a dead end or if I can not find it, hope you guys can help me.
OK, then this error was dumb. The problem was that the paint The object will be restarted when a new path is created by the user. This will definitely not set XFormodes set.
Case motion event. Action_DOWN: Paint Stroke Paint = New Paint ();
Solution is the object for the current paint maker.
Paint strokepaint = new paint (drawing pent);
Comments
Post a Comment