This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setup() { | |
createCanvas(1000, 600); | |
background(255); | |
strokeWeight(5); | |
smooth(); | |
var radius = 500; | |
var centx = 500; | |
var centy = 300; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func encode(_ s: String) -> String { | |
let data = s.data(using: .nonLossyASCII, allowLossyConversion: true)! | |
return String(data: data, encoding: .utf8)! | |
} | |
let emoji = "👪" | |
encode(emoji) // \ud83d\udc6a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension String { | |
func index(character: Character) -> String.Index? { | |
let index = self.characters.enumerated().filter { (idx, c) in c == character }.first?.0 | |
guard let offset = index else { | |
return nil | |
} | |
return self.index(self.startIndex, offsetBy: offset) | |
} |