All Projects → dqhieu → Uigradient

dqhieu / Uigradient

Licence: mit
A simple and powerful library for using gradient layer, image, color

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Uigradient

Extract-Color-Palette-Api
Create gradient drawable by extracting prominent colors from image⚫⚪
Stars: ✭ 16 (-92.31%)
Mutual labels:  color, gradient
Coolhue
Coolest Gradient Hues and Swatches
Stars: ✭ 3,307 (+1489.9%)
Mutual labels:  color, gradient
gradient-rs
A command line tool for playing with color gradients
Stars: ✭ 93 (-55.29%)
Mutual labels:  color, gradient
Rhplaceholder
Show pleasant loading view for your users 😍
Stars: ✭ 238 (+14.42%)
Mutual labels:  ios-lib, gradient
Complimentarygradientview
Create complementary gradients generated from dominant and prominent colors in supplied image. Inspired by Grade.js
Stars: ✭ 691 (+232.21%)
Mutual labels:  color, gradient
Height-Based-Gradient-Color-Shaders-for-Unity
Height Based 2 color gradient shaders for Unity
Stars: ✭ 18 (-91.35%)
Mutual labels:  color, gradient
Hue
🎨 Hue is the all-in-one coloring utility that you'll ever need.
Stars: ✭ 3,306 (+1489.42%)
Mutual labels:  color, gradient
colr
Easy terminal colors, with chainable methods.
Stars: ✭ 32 (-84.62%)
Mutual labels:  color, gradient
Fast Average Color
🍏🍊🍅 Fast Average Color
Stars: ✭ 531 (+155.29%)
Mutual labels:  color, gradient
Gradient String
🌈 Beautiful color gradients in terminal output
Stars: ✭ 476 (+128.85%)
Mutual labels:  color, gradient
Dynamiccolor
Yet another extension to manipulate colors easily in Swift and SwiftUI
Stars: ✭ 2,677 (+1187.02%)
Mutual labels:  color, gradient
Kaloader
Beautiful animated placeholders for showing loading of data
Stars: ✭ 99 (-52.4%)
Mutual labels:  color, gradient
elm-color-extra
🎨 Additional color handling for Elm
Stars: ✭ 28 (-86.54%)
Mutual labels:  color, gradient
Chromatic Sketch
Sketch plugin for creating good-looking and perceptually uniform gradients and color scales.
Stars: ✭ 445 (+113.94%)
Mutual labels:  color, gradient
Colorgrad
Go (Golang) color scales library for maps, charts, data-visualization & creative coding.
Stars: ✭ 96 (-53.85%)
Mutual labels:  color, gradient
Colorbands
Unity 3D's Gradient is a handy data type but comes with some limitations: for example you cannot set more than 8 color keys in its editor and RGB is the only color space available. ColorBand data type offers an alternative with less limitations. Creating ColorBands is fun and easy; they are stored as assets and can be accessed from code through an Evaluate method to get the color at time t, as for Gradient. RGB (or HSV) values are described by individual curves, allowing a better control over how the color function evolves between your points. Color bands are used in all kinds of applications including games, data visualization and other fields.
Stars: ✭ 137 (-34.13%)
Mutual labels:  color, gradient
Xamarin.forms.backgroundkit
🔨 A powerful Kit for customizing the background of Xamarin.Forms views
Stars: ✭ 167 (-19.71%)
Mutual labels:  gradient
Lmmediaplayer
A video and audio player with replaceable UI component.
Stars: ✭ 183 (-12.02%)
Mutual labels:  ios-lib
Color
A little library to deal with color conversions
Stars: ✭ 166 (-20.19%)
Mutual labels:  color
Shift
Animate gradient changes with time or motion for iOS Swift
Stars: ✭ 165 (-20.67%)
Mutual labels:  gradient



Platform Swift 5 Version License

Installation

UIGradient is now available on CocoaPods. Simply add the following to your project Podfile, and you'll be good to go.

pod 'UIGradient'

Usage

GradientLayer

Create a GradientLayer then add it to your view's

public extension UIView {

    func addGradientWithDirection(_ direction: GradientDirection, colors: [UIColor], cornerRadius: CGFloat = 0, locations: [Double]? = nil)

    func addGradient(_ gradientLayer: GradientLayer, cornerRadius: CGFloat = 0)
	
}

Example

let gradient = GradientLayer(direction: GradientDirection, colors: [UIColor])
view.addGradient(gradient)

UIGradient supports those directions below:

public enum GradientDirection {
    case topToBottom // top to bottom
    case bottomToTop // bottom to top
    case leftToRight // left to right
    case rightToLeft // right to left
    case topLeftToBottomRight // top left to bottom right
    case topRightToBottomLeft // top right to bottom left
    case bottomLeftToTopRight // bottom left to top right
    case bottomRightToTopLeft // bottom right to top left
}

You can also create a GradientLayer clone instance using this function:

open class GradientLayer: CAGradientLayer {
    ...
    public final func clone() -> GradientLayer
    ...
}

Gradient color

UIGradient allows you create gradient color

public extension UIColor {

    static func fromGradient(_ gradient: GradientLayer, frame: CGRect, cornerRadius: CGFloat = 0) -> UIColor?
	
    static func fromGradientWithDirection(_ direction: GradientDirection, frame: CGRect, colors: [UIColor], cornerRadius: CGFloat = 0, locations: [Double]? = nil) -> UIColor?
	
}

Example

let view1 = UIView(frame: frame)
view1.backgroundColor = UIColor.fromGradientWithDirection(.topToBottom, frame: frame, colors: [UIColor.blue, UIColor.green])
//view1.backgroundColor = UIColor.fromGradient(gradient, frame: frame)
let label = UILabel(frame: frame)
label.text = "some text"
label.textColor = UIColor.fromGradient(gradient, frame: frame)

Gradient image

UIGradient also allows you create gradient image

public extension UIImage {

    static func fromGradient(_ gradient: GradientLayer, frame: CGRect, cornerRadius: CGFloat = 0) -> UIImage?
	
    static func fromGradientWithDirection(_ direction: GradientDirection, frame: CGRect, colors: [UIColor], cornerRadius: CGFloat = 0, locations: [Double]? = nil) -> UIImage?
	
}

Example

let imageView = UIImageView(frame: frame)
imageView.image = UIImage.fromGradientWithDirection(.bottomLeftToTopRight, frame: frame, colors: [UIColor.blue, UIColor.green])

Gradient library

UIGradient was inspired by @lukedesigner. I created 24 gradients based on his website and make them static variables of GradientLayer so everyone can use those gradients for their projects.

let oceanBlueGradient 		= GradientLayer.oceanBlue
let sanguineGradient  		= GradientLayer.sanguine
let lusciousLimeGradient 	= GradientLayer.lusciousLime
let purpleLakeGradient 		= GradientLayer.purpleLake
...

You can explore them in my example project.

Author

UIGradient was created by Đinh Quang Hiếu ([email protected]) in 2017 using Swift. If you found any problem please create issue or pull request to help me improve this open source project. Thanks!

License

UIGradient is released and distributed under the terms and conditions of the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].