Joe*_*son 0 android drawing android-canvas
我正在将Skycons移植到Android上,我的大部分工作都在工作,除了月亮使用Canvas.arc带有逆时针参数的HTML5 .
我试图这样实现:
RectF rect = new RectF();
public void arcR( Path path, float x, float y, float radius, double startAngle, double endAngle, boolean anticlockwise ){
// Set bounds
rect.set( x - radius, y - radius, x + radius, y + radius );
// Convert to degrees
startAngle = Math.toDegrees(startAngle);
endAngle = Math.toDegrees(endAngle);
if(anticlockwise){
startAngle = 360 - startAngle;
endAngle = 360 - endAngle;
}
endAngle = endAngle - startAngle;
path.addArc(rect, (float)startAngle, (float)endAngle);
}
Run Code Online (Sandbox Code Playgroud)
我认为我没有正确实施逆时针,因为在我的设备上绘制月球(基于Skycons)看起来像这样:
对于逆时针弧,扫掠角需要为负
float sweepAngle = ((endAngle + 360) - startAngle) % 360;
if (anticlockwise) {
sweepAngle = sweepAngle - 360;
}
path.addArc(rect, startAngle, sweepAngle);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1089 次 |
| 最近记录: |