Permalink
Browse files

Better LOD for round line caps. See #19

  • Loading branch information...
1 parent 8609ebf commit c1c0c1cfa999a5f543d0a2d51c9b260ea9edf3a0 @phoboslab committed Jan 16, 2013
Showing with 6 additions and 2 deletions.
  1. +6 −2 Source/Ejecta/EJCanvas/2D/EJPath.mm
@@ -458,14 +458,18 @@ - (void)drawArcToContext:(EJCanvasContext2D *)context atPoint:(EJVector2)point v
// 1 step per 5 pixel
float pxScale = CGAffineTransformGetScale(state->transform);
- int numSteps = MAX( 1, (angle2 * width2 * pxScale) / 5.0f );
+ int numSteps = ceilf( (angle2 * width2 * pxScale) / 5.0f );
- if(numSteps==1) {
+ if( numSteps == 1 ) {
[context
pushTriX1:p1.x y1:p1.y x2:point.x y2:point.y x3:p2.x y3:p2.y
color:color withTransform:transform];
return;
}
+ // avoid "triangular" look
+ else if( numSteps == 3 && fabsf(angle2) > M_PI_2 ) {
+ numSteps = 4;
+ }
// calculate direction
float direction = (v2.x*v1.y - v2.y*v1.x < 0) ? -1 : 1;

0 comments on commit c1c0c1c

Please sign in to comment.