Post

Replies

Boosts

Views

Activity

Reply to Is it possible to animate a path similar to how StrokeEnd works in SpriteKit ?
One technique that I've seen used successfully elsewhere is to use dashed lines where the 'draw' segment length is what's animated and covers the entire stroke. The 'don't draw' segment is set to be excessively long (i.e. at least as long as the overall stroke length itself.) Then by animating the length of the 'draw' segment between zero and whatever the stroke length is, it emulates 'drawing' the stroke as if it were a pen. Hope that makes sense.
Topic: Graphics & Games SubTopic: SpriteKit Tags:
Jan ’23
Reply to Check if character in character set?
Here's my approach. Handles both single- and multi-scalar characters equally thanks to allSatisfy. public extension CharacterSet { func contains(_ character: Character) -> Bool { character.unicodeScalars.allSatisfy(contains) } func containsAll(in string: String) -> Bool { string.unicodeScalars.allSatisfy(contains) } } Some other useful/helpful operators... public extension CharacterSet { static func + (lhs: CharacterSet, rhs: CharacterSet) -> CharacterSet { lhs.union(rhs) } static func - (lhs: CharacterSet, rhs: CharacterSet) -> CharacterSet { lhs.subtracting(rhs) } }
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’22
Reply to Is it possible to animate a path similar to how StrokeEnd works in SpriteKit ?
One technique that I've seen used successfully elsewhere is to use dashed lines where the 'draw' segment length is what's animated and covers the entire stroke. The 'don't draw' segment is set to be excessively long (i.e. at least as long as the overall stroke length itself.) Then by animating the length of the 'draw' segment between zero and whatever the stroke length is, it emulates 'drawing' the stroke as if it were a pen. Hope that makes sense.
Topic: Graphics & Games SubTopic: SpriteKit Tags:
Replies
Boosts
Views
Activity
Jan ’23
Reply to Check if character in character set?
Here's my approach. Handles both single- and multi-scalar characters equally thanks to allSatisfy. public extension CharacterSet { func contains(_ character: Character) -> Bool { character.unicodeScalars.allSatisfy(contains) } func containsAll(in string: String) -> Bool { string.unicodeScalars.allSatisfy(contains) } } Some other useful/helpful operators... public extension CharacterSet { static func + (lhs: CharacterSet, rhs: CharacterSet) -> CharacterSet { lhs.union(rhs) } static func - (lhs: CharacterSet, rhs: CharacterSet) -> CharacterSet { lhs.subtracting(rhs) } }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’22