how to draw erase strokes programmatically using Samsung Pen SDK

325 Views Asked by At

I am using the pen SDK 4.0.7

I want to erase strokes programatically, pretty much the same thing a user will do with his finger or pen when the eraser is enabled.

I know that this code is used to draw pen strokes programatically:

SpenObjectStroke strokeObj = new SpenObjectStroke(penName, points, pressures, timestamps);

strokeObj.setPenSize(size);
strokeObj.setColor(color);
mSpenPageDoc.appendObject(strokeObj);
mSpenSurfaceView.update();

So my question is: how do I draw an Eraser stroke? (that cleans all the pen stokes it overlaps)

1

There are 1 best solutions below

0
On

The solution I implemented was to use the MagicPen which has the capability of erasing a stroke when the intensity is set to the max value.

    String penName = SpenPenManager.SPEN_MAGIC_PEN;
    float  penSize =  eraserSettingView.getInfo().size;
    int penColor  = -16777216; // gotten from the max transparent color value of the Magic pen

    SpenObjectStroke strokeObj = new SpenObjectStroke(penName, points, pressures, timestamps);

    strokeObj.setPenSize(size);
    strokeObj.setColor(color);
    mSpenPageDoc.appendObject(strokeObj);
    mSpenSurfaceView.update();