Giter Club home page Giter Club logo

pailead's Introduction

Pailead

Version License Platform

Pailead works just like the Palette library on Android and other tools like node-vibrant but is completely written in Swift and optimized for macOS, iOS, tvOS, and even watchOS.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Pailead into your Xcode project using CocoaPods, specify it in your Podfile:

pod "Pailead"

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding Pailead as a dependency is as easy as adding it to the dependencies value of your Package.swift.

Swift 4

dependencies: [
.package(url: "https://github.com/pducks32/Pailead.git", from: "1.4.0")
]

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate Pailead into your Xcode project using Carthage, specify it in your Cartfile:

github "pducks32/Pailead"

Usage

Extracting Palette

All images are resized to 1000 pixels to speed up extraction, but don't worry this hasn't been shown to degrade the quality of the palette.

let image = <#Image#>
Pailead.extractPalette(from: image) { palette in
<#Do Something with Palette#>
}

Palette Swatches

The generated palette generates useful swatches to use in your UI or as a loading background perhaps. All swatches are actual colors found in the MMCQ calculation though it will generate some if no suitable ones can be found. These are:

  • Muted Swatch (middle range luma and low saturation)
  • Dark Muted Swatch (low range luma)
  • Light Muted Swatch (high range luma)
  • Vibrant Swatch (middle range luma and high saturation)
  • Dark Vibrant Swatch (low range luma)
  • Light Vibrant Swatch (high range luma)

How it works

Modified Mean Cut Quantization

That's a big word. The image's pixels are grouped and counted. Then they are laid out in RGB space. From there the quantizer finds RGB boxes that encapsulate the pixels equally. From these boxes the average color is generated and then sorted by how common it is in the image.

Todo

  • Switch to swatches
  • Add palette
  • Paralleize pixel extraction (clustering is already parallized)
  • Add more performance tests
  • Make better docs with example uses
  • Optimize processing loop
  • Add support for other clustering algorithms

Name

If palette is pronounced pa-let then Pailead is pronounced pa-lid.

The word comes from the Irish word paileád meaning palette which is what this library extracts.

Author

pailead's People

Contributors

pducks32 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pailead's Issues

can i get representative point at color?

Hello.

Thank you for making pailead.

I wonder if can get the representative point of the color in palette.

Because I have to mark on image.

Please tell me about this.

Thank you again.

Pailead cannot be built --no-use-binaries on Carthage

if you run:

carthage bootstrap --no-use-binaries --use-ssh Pailead

Fails with code:

*** Checking out Pailead at "1.4.1"
*** xcodebuild output can be found in /var/folders/gm/slscg5cx0r161m3k37xv2xfw0000gp/T/carthage-xcodebuild.XcRdLO.log
*** Skipped building Pailead due to the error:
Dependency "Pailead" has no shared framework schemes

If you believe this to be an error, please file an issue with the maintainers at https://github.com/pducks32/Pailead/issues/new

I think this is because Pailed cannot be build with Xcode dev tools. The repo doesn't have an Xcode project. Out of interest how are you building this repo?

Provide Carthage Support

I like this library because it very closely matches the results from the material Palette library. I'd love to get Carthage support for it, if you can?

Provide a utility dominantSwatch method

I've a use case where I need to get the most dominant swatch in a palette. It'd be handy if the library provided this instead.

It could be a lazy var on the Palette class.

public lazy var dominantSwatch: Pailead.Swatch?

Crash possible in VBox.median method if lengthOfLongest is negative

It's not been easy to reproduce reliably but I see a crash happening in the VBox.median method on this line
var slicesSums = [Int](repeating: 0, count: lengthOfLongest + 1)

I believe the only thing that can trip this up is if somehow lengthOfLongest is negative. The only way this is possible is if somehow the minPixel values are larger than the maxPixel values.

Any idea how to best guard against this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.