Giter VIP home page Giter VIP logo

publishcolorutils's Introduction

PublishColorUtils

A cross-platfrom color object, can generate Hex and CSS representation of color.

Usage

You can instantiate your color object using hex or RGBA/sRGBA component values.

Color(red: 255/255, green: 255/255, blue: 255/255, alpha: 1)

Color(hex: "#ff00ff")

Color(displayP3Red: 255/255, green: 255/255, blue: 255/255, alpha: 1)

Hex and CSS representation

To get a hex representation or hex with alpha, just call:

let color = Color(red: 255/255, green: 0/255, blue: 255/255, alpha: 1)

color.hex // #FF00FF

color.hexWithAlpha // #FF00FFFF

If you need a css representation of color:

// RGB 
let color = Color(red: 255/255, green: 0/255, blue: 255/255, alpha: 1)

color.rgbaDescription // rgba(255, 0, 255, 1)

/// sRGB

let p3Color = Color(displayP3Red: 255/255, green: 0/255, blue: 255/255, alpha: 1)

p3Color.rgbaDescription // color(display-p3 1 0 1 / 1)

Dark mode

Also, this color supports dark mode:

let color = Color(hex: "#efefef").adaptiveToDarkTheme(Color(hex: "#111111"))
color.dark.hex // #111111

iOS Colors

We also supports iOS 13 system colors

Color.red == UIColor.systemRed

Color.pink == UIColor.systemPink

publishcolorutils's People

Contributors

spectraldragon avatar

Watchers

 avatar  avatar

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.