Пример #1
0
void FormPlugin::drawPassword(ANPCanvas* canvas, TextInput passwordInput) {

    // get font metrics
    ANPFontMetrics fontMetrics;
    gPaintI.getFontMetrics(m_paintText, &fontMetrics);

    // comput the circle dimensions and initial location
    float initialX = passwordInput.rect.left + 5;
    float ovalBottom = passwordInput.rect.bottom - 2;
    float ovalTop = ovalBottom - (fontMetrics.fBottom - fontMetrics.fTop);
    float ovalWidth = ovalBottom - ovalTop;
    float ovalSpacing = 3;

    // draw circles instead of the actual text
    for (uint32_t x = 0; x < passwordInput.charPtr; x++) {
        ANPRectF oval;
        oval.left = initialX + ((ovalWidth + ovalSpacing) * (float) x);
        oval.right = oval.left + ovalWidth;
        oval.top = ovalTop;
        oval.bottom = ovalBottom;
        gCanvasI.drawOval(canvas, &oval, m_paintText);
    }
}
Пример #2
0
void PaintPlugin::paintMouse(int x, int y) {
    //TODO do not paint outside the drawing surface

    //create the paint color
    ANPPaint* fillPaint = gPaintI.newPaint();
    gPaintI.setFlags(fillPaint, gPaintI.getFlags(fillPaint) | kAntiAlias_ANPPaintFlag);
    gPaintI.setStyle(fillPaint, kFill_ANPPaintStyle);
    gPaintI.setColor(fillPaint, m_activePaintColor);

    // handle the simple "mouse" paint (draw a point)
    ANPRectF point;
    point.left =   (float) x-3;
    point.top =    (float) y-3;
    point.right =  (float) x+3;
    point.bottom = (float) y+3;

    // get a canvas that is only locked around the point and draw it
    ANPCanvas* canvas = getCanvas(&point);
    gCanvasI.drawOval(canvas, &point, fillPaint);

    // clean up
    releaseCanvas(canvas);
    gPaintI.deletePaint(fillPaint);
}