Domanda

I have calculated points to construct a bezierPath that would give something like this:

UIBezierPath *aaa = [UIBezierPath bezierPath];

[aaa moveToPoint:CGPointMake(92.909,94.233)];
[aaa addCurveToPoint:CGPointMake(127.000,153.500) controlPoint1:CGPointMake(92.909,94.233) controlPoint2:CGPointMake(97.675,142.103)];
[aaa addCurveToPoint:CGPointMake(207.409,138.733) controlPoint1:CGPointMake(154.889,164.339) controlPoint2:CGPointMake(207.409,138.733)];
[aaa addCurveToPoint:CGPointMake(153.000,111.500) controlPoint1:CGPointMake(207.409,138.733) controlPoint2:CGPointMake(170.182,78.674)];
[aaa addCurveToPoint:CGPointMake(127.000,91.500) controlPoint1:CGPointMake(141.348,133.759) controlPoint2:CGPointMake(136.058,94.088)];
[aaa addCurveToPoint:CGPointMake(92.909,94.233) controlPoint1:CGPointMake(109.480,86.494) controlPoint2:CGPointMake(92.909,94.233)];
[aaa closePath];
[aaa fill];

Does it make sense to declare these numbers with fractional parts? I ask this because this UIBezierPath, if drawn at 1:1 scale, will mean that each one of these vertices will be in "subpixels" and as far as I understand, points on graphics have to be without fraction parts. I mean, there is point (300,300) but there is no point (300.83, 233.33).

Does it makes sense do declare the bezier using fractional floats?

È stato utile?

Soluzione

For the most part, there's no advantage to using integer values. You might want to make the coordinates integers at the corners of your path (so the corners have less anti-aliasing), but for the rest (the control points, any vertices along the smooth portion of the curve), it really doesn't matter (because the rest of the curve is going to be at non-integral values anyway and you'll see lots of anti-aliasing along the whole curve, regardless of the vertices and control points).

But you should just visually compare the bezier path with integer values to that without (zoomed in by 1200%, below) and see what you think:

enter image description here

Altri suggerimenti

It makes sense if you're expecting to draw the path at a different scale (or just want to be prepared for that eventuality) or in the case of retina devices (or other future devices) which don't have a one-to-one mapping between points and pixels.

It may make sense anyway since CoreGraphics supports sub-pixel drawing through interpolation.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top