create and apply a transform that moves our path down by that amount, centering the shape vertically Let unusedSpace = (rect.height / 2 - bottomEdge) / 2 ![]() figure out how much unused space we have at the bottom of our drawing rectangle track the lowest point we draw to, so we can center later Path.move(to: CGPoint(x: center.x * cos(currentAngle), y: center.y * sin(currentAngle))) we're ready to start with our path now figure out how much we need to move X/Y for the inner points of the star calculate how much we need to move with each star corner start from directly upwards (as opposed to down or to the right) Let center = CGPoint(x: rect.width / 2, y: rect.height / 2) For example, we could create a Star shape that is capable of representing a variety of star shapes, or even other polygons, with just a little mathematics. Once you understand SwiftUI’s basic path drawing system, you can add all sorts of shapes easily.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |