使用触摸动态调整画布上绘制的线条的大小

时间:2014-03-12 05:44:45

标签: java android eclipse canvas

在我的Android应用程序中,我必须从WebView获取一个图像,然后在其上添加注释。所以,到目前为止,我已经成功实现了这一目标。问题是,一旦绘制了特定的注释,我找不到如何动态缩放它们的解决方案。对于一个直线,一个圆等等。

private void setupDrawing() {
    // get drawing area setup for interaction
    Log.d("onCreate", "" + "setupDrawing");
    drawPath = new Path();
    drawRect = new Rect();
    drawPaint = new Paint();
    drawPaint.setColor(paintColor);
    drawPaint.setAntiAlias(true);
    drawPaint.setStrokeWidth(5);
    drawPaint.setStyle(Paint.Style.STROKE);
    drawPaint.setStrokeJoin(Paint.Join.ROUND);
    drawPaint.setStrokeCap(Paint.Cap.ROUND);
    canvasPaint = new Paint(Paint.DITHER_FLAG);
}

public boolean onTouchEvent(MotionEvent event) {
    // detect user touch
    Log.d("Event", "onTouchEvent");
    if (canDrawFreeHand == true) {
        Log.d("", "canDrawFreeHand true");

        Log.d("Fag", "Got the Free hand flag " + currentflag);
        float touchX = event.getX();
        float touchY = event.getY();
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            // Log.d("freehand", "draw");
            drawPath.moveTo(touchX, touchY);
            break;
        case MotionEvent.ACTION_MOVE:
            // Log.d("freehand", "Drawing..");
            drawPath.lineTo(touchX, touchY);
            break;
        case MotionEvent.ACTION_UP:
            Log.d("freehand", "Drawn");
            drawCanvas.drawPath(drawPath, drawPaint);
            drawPath.reset();
            break;
        default:
            return false;
        }

}

我想以这样一种方式缩放它们,即在绘制一些注释之后,当用户点击该绘图时。它已准备好扩展。

0 个答案:

没有答案