This file contains hidden or 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 CoreGraphics | |
import CoreImage | |
public struct ImageBufferMaker { | |
let diagonal: SIMD2<Int> | |
public init(diagonal: SIMD2<Int>) { | |
self.diagonal = diagonal | |
} |
This file contains hidden or 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
public protocol TwoDimensional { | |
associatedtype Measure: SignedNumeric, Comparable | |
var xmesure: Measure { get set } | |
var ymesure: Measure { get set } | |
} | |
/// * (0,3)(1,3)(2,3)(3,3) | |
/// * (0,2)(1,2)(2,2)(3,2) | |
/// * (0,1)(1,1)(2,1)(3,1) | |
/// * (0,0)(1,0)(2,0)(3,0) -> (0,0)(1,0)(2,0)(3,0), (0,1)(1,1)(2,1)(3,1) ... |
This file contains hidden or 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
/// [1, 2, 3, 4, 5, 6] -> (1,2) (1,3) (1,3) (1,4) (1,5) (1, 6) (2,3) (2,4) (2,5) (2,6) ... | |
public func eachToEachIn<C: Collection>(c: C) -> [(left: C.Element, right: C.Element)]? where C.Element: Hashable { | |
guard c.count > 1 else { return nil } | |
var rightindex = c.startIndex | |
var leftindex = c.startIndex | |
var controlSet = Set<CoupleUnorderer<C.Element>>() | |
while rightindex < c.endIndex { | |
while leftindex < c.endIndex { | |
let left = c[leftindex] |