GithubHelp home page GithubHelp logo

hardik27194 / coloradjuster Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ikemai/coloradjuster

0.0 1.0 0.0 232 KB

License: MIT License

Ruby 1.02% Objective-C 56.98% Swift 23.98% Shell 18.02%

coloradjuster's Introduction

Png

CI Status Version License Platform

ColorAdjuster is the library which can create a new color by HBS or RGB for the cause in base color, and create gradation view.

Demo

  • UIColor can regulate numerical value of HBS and RGB of the target color.

Gif Gif

  • UIView can make gradation of Gradation.
  • You can coordinate gradation colors with the number of any colors.

Gif

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • swift 2.0, iOS8.0 ~

Installation

ColorAdjuster is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "ColorAdjuster"

Example

  • Appoint it in hexadecimal and create UIColor.
let color = UIColor(hex: 0xB7EAE7)

HBS

  • Ajustment color of HBS.
let adjustmentColor = color.colorWithHBSComponent(hue: hueValue, brightness: brightnessValue, saturation: saturationValue)
adjustmentColorView.backgroundColor = adjustmentColor
  • Get HBS value of color.
if let hbs = adjustmentColor?.colorHBS() {
    print("Hue = \(hbs.hue)")
    print("Bridhtness = \(hbs.brightness)")
    print("Saturation = \(hbs.saturation)")
}

RGB

  • Ajustment color of RGB.
let adjustmentColor = color.colorWithRGBComponent(red: rValue, green: gValue, blue: bValue)
targetView.backgroundColor = adjustmentColor
  • Get RGB value of color.
if let rbg = adjustmentColor?.colorRGB() {
    print("Red = \(rbg.red)")
    print("Green = \(rbg.green)")
    print("Blue = \(rbg.blue)")
}

Create gradation view.

let targetView = UIView(frame: frame)
let colors: [CGColor] = [UIColor.redColor().CGColor, UIColor.magentaColor().CGColor]
view.addSubView(targetView)

Appoint locations

let locations: [CGFloat] = [0.0, 1.0]
targetView.gradientLayer.insertLayerVerticallyGradient(colors: colors, locations: locations)

Png

Appoint startPoint and endPoint

let startPoint = CGPointMake(1, 0.5)
let endPoint = CGPointMake(0, 0.5)
targetView.gradientLayer.insertLayerVerticallyGradient(colors: colors, startPoint: startPoint, endPoint: endPoint)

Png

Appoint Angle = Zero

targetView.gradientLayer.insertLayerVerticallyGradient(colors: colors, angle: .Zero)

Png

Appoint Angle = FortyFive

targetView.gradientLayer.insertLayerVerticallyGradient(colors: colors, angle: .FortyFive)

Png

Appoint Ninety

targetView.gradientLayer.insertLayerVerticallyGradient(colors: colors, angle: .Ninety)

Png

Function

  • Appoint it in hexadecimal and create UIColor.
public convenience init(hex: Int, alpha: CGFloat = 1)
  • UIColor ajustment color of HBS.
public func colorWithHBSComponent(hue hue: CGFloat, brightness: CGFloat, saturation: CGFloat) -> UIColor?
  • UIColor get HBS value of color.
public func colorHBS() -> ColorAdjuster.HBSProperties?
  • UIColor ajustment color of RGB.
public func colorWithRGBComponent(r r: CGFloat, g: CGFloat, b: CGFloat) -> UIColor?
  • UIColor get RGB value of color.
public func colorRGB() -> ColorAdjuster.RGBProperties?
  • UIView create gradation view.
public func insertLayerVerticallyGradient(colors colors: [CGColor], locations: [CGFloat]) 

Properties

  • Value of HBS
public struct HBSProperties {
    public var hue: CGFloat = 0
    public var brightness: CGFloat = 0
    public var saturation: CGFloat = 0
    public var alpha: CGFloat = 1
}
  • Value of RGB
public struct RGBProperties {
    public var r: CGFloat = 0
    public var g: CGFloat = 0
    public var b: CGFloat = 0
    public var alpha: CGFloat = 1
}

Author

ikemai

License

ColorAdjuster is available under the MIT license. See the LICENSE file for more info.

coloradjuster's People

Contributors

ikemaica avatar tasanobu avatar

Watchers

James Cloos 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.