我正在尝试在图像中显示三角形。不幸的是,我没有显示三角形,我无法找到原因。我在哪里搞砸了? 这是代码:
double hypotenuse = Math.sqrt(Math.pow((width_index-standard),2)+Math.pow((high_index-base_index),2));
angle *= Math.asin(((width_index-standard)/hypotenuse));
angle = angle*(180/Math.PI);
angle = Math.round(angle);
TextView t = (TextView) findViewById(R.id.result_angle);
t.setText(String.valueOf(angle));
// return_b is the bitmap to be displayed
Canvas canvas = new Canvas(return_b);
Path p = new Path();
Paint paint = new Paint();
p.moveTo(standard, (base_index+(float)hypotenuse));
p.lineTo(standard, height-1);
p.moveTo(standard, height-1);
p.lineTo(width_index, high_index);
p.moveTo(width_index, high_index);
//p.addArc(standard, (base_index+(float)hypotenuse), width_index, high_index, 0, (float)((-1)*angle));
p.lineTo(standard, (base_index+(float)hypotenuse));
p.close();
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.FILL);
paint.setAntiAlias(true);
canvas.drawPath(p, paint);
感谢。
答案 0 :(得分:0)
问题发生在moveTo
。当我删除它们时,三角形出现了。