Skip to content

simple-color-palette/SimpleColorPaletteSwift

Repository files navigation

SimpleColorPalette

A Swift implementation of the Simple Color Palette format — a minimal JSON-based file format for defining color palettes

Feedback wanted on the API.

Install

Add the following to Package.swift:

.package(url: "https://github.com/simple-color-palette/SimpleColorPaletteSwift", from: "0.2.0")

Or add the package in Xcode.

Usage

API documentation

import SimpleColorPalette

let palette = ColorPalette(
	[
		.init(components: .init(red: 1, green: 0, blue: 0), name: "Red"),
		.init(components: .init(red: 0, green: 1, blue: 0), name: "Green")
	],
	name: "Traffic Lights"
)

let url = URL.downloadsDirectory.appending(path: "Traffic Lights.color-palette")

// Save palette
try palette.write(to: url)

// Load palette
let loadedPalette = try ColorPalette(contentsOf: url)

Related