Question on Metal Line width says that it is not possible to draw lines in metal with custom line width. However apple says that all its graphics frameworks like UIKit
, SpriteKit
, SceneKit
uses Metal
. I want to know how these frameworks have lines with different line widths? If they are made of triangles, is there some example that shows how to do it? Also how would then a circle, other primitive shapes be drawn with lines of varying width?
Asked
Active
Viewed 874 times
0

Lukas Würzburger
- 6,543
- 7
- 41
- 75

Aravindh S
- 1,185
- 11
- 19
-
Lines (and paths in general) are tessellated into triangles and/or scan-line rasterized, depending on the API you're using. This is actually what you want, since there is insufficient control over antialiasing quality and line joins when using hardware-accelerated line rasterization. But yes, it does make it more work if you want to draw thick lines with Metal. – warrenm Jul 23 '18 at 04:51
1 Answers
0
I don't know how Apple does their lines. But I have found this site to explain pretty simply how to do antialiased varying-width lines with triangles. It's for OpenGL but Metal would be pretty much the same. There are many other similar sites online with other explanations and approaches if you Google the subject.
http://merowing.info/2012/04/drawing-smooth-lines-with-cocos2d-ios-inspired-by-paper/

bsabiston
- 721
- 6
- 22