Skip to content

Commit

Permalink
Colour map preview helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Kerr committed Jun 17, 2021
1 parent 2f8d96e commit 8e3a47d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sources/MandelbrotEngine/ColourMaps/ColourMapProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,24 @@ public protocol ColourMapProtocol {
var title: String { get }
var blackPixel: Pixel { get }
var pixels: [Pixel] { get }
var preview: [Pixel] { get }
func pixel(from test: MandelbrotSetPoint.Test) -> Pixel
}


extension ColourMapProtocol {
public var id: String { title }


public var preview: [Pixel] {
let count = pixels.count
var output: [Pixel] = []
for _ in 0..<count {
output.append(contentsOf: pixels)
}
return output
}


public func pixel(from test: MandelbrotSetPoint.Test) -> Pixel {
switch test {
Expand Down

0 comments on commit 8e3a47d

Please sign in to comment.