2017-02-14 325 views
0

我画了4条线,从中心朝向按钮,正如我在照片中显示的那样。我不知道如何绘制图片中呈红色的曲线。绘制曲线线android

[enter image description here]

[enter image description here (simpler)]

Bitmap bitmap = Bitmap.createBitmap((int) getWindowManager() 
      .getDefaultDisplay().getWidth(), (int) getWindowManager() 
      .getDefaultDisplay().getHeight(), Bitmap.Config.ARGB_8888); 
    Canvas canvas = new Canvas(bitmap); 
    drawingImageView.setImageBitmap(bitmap); 
    DisplayMetrics metrics = this.getResources().getDisplayMetrics(); 
    int x = metrics.widthPixels; 
    int y = metrics.heightPixels; 
    Paint paint1 = new Paint() ; 
    paint1.setStrokeWidth(10); 
    int margin = 100; 
    int margin1 = 300; 
    int top = 0 + margin; 
    int bottom = canvas.getHeight() - margin; 
    int left = 0 + margin1; 
    int right = canvas.getWidth() - margin1; 
    int centerX = x/2; 
    int centerY = y/2; 

    canvas.drawLine(centerX, top, centerX, bottom,paint1); 
    canvas.drawLine(left, centerY, right, centerY,paint1); 

回答

1

您需要将其在4个不同的部分(曲线)拆分为更容易拉 这里是我的草图(抱歉快速绘图)

所以你需要得到4分bezieres,应该是这样的东西 1日举下手(描绘点)

path.moveTo(x1, y1); 

然后用接下来的抽奖路径

cubicTo(x2, y2, x3, y3, x4,y4) 

enter image description here

最后

canvas.drawPath(path, paint); 

相同的步骤使休息3象限/部分 希望这可以帮助您归档你的目标

+0

我怎么能有四点的坐标? – CamlX

+0

这是更多的数学计算,你有按钮(1)的位置x,y相同的按钮(3)和xy的交点,你可以得到你需要的中点很容易(屏幕宽度/ 2和屏幕高度/ 2) –

+0

android对于点x2? – CamlX