All Projects β†’ skydoves β†’ Rainbow

skydoves / Rainbow

Licence: apache-2.0
🌈 A fluent way to apply gradations and tinting for Android.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Rainbow

autodiff
A .NET library that provides fast, accurate and automatic differentiation (computes derivative / gradient) of mathematical functions.
Stars: ✭ 69 (-79.59%)
Mutual labels:  gradient
Cirque
An iOS component that enables you to draw multi color circle strokes with gradient trasitions between colors
Stars: ✭ 23 (-93.2%)
Mutual labels:  gradient
Flutter programs
Experiments with Mobile
Stars: ✭ 308 (-8.88%)
Mutual labels:  gradient
RainbowTaskbar
Customizable Windows taskbar effects.
Stars: ✭ 39 (-88.46%)
Mutual labels:  gradient
ngx-animated-gradient
Angular Directive that animates the gradient background
Stars: ✭ 16 (-95.27%)
Mutual labels:  gradient
Skeletonui
☠️ Elegant skeleton loading animation in SwiftUI and Combine
Stars: ✭ 275 (-18.64%)
Mutual labels:  gradient
GradientProgress
A gradient progress bar (UIProgressView).
Stars: ✭ 38 (-88.76%)
Mutual labels:  gradient
Coolhue
Coolest Gradient Hues and Swatches
Stars: ✭ 3,307 (+878.4%)
Mutual labels:  gradient
elm-color-extra
🎨 Additional color handling for Elm
Stars: ✭ 28 (-91.72%)
Mutual labels:  gradient
Co.revely.gradient
An Android library for easy gradient management
Stars: ✭ 298 (-11.83%)
Mutual labels:  gradient
tensorflow-mle
Some examples on computing MLEs using TensorFlow
Stars: ✭ 14 (-95.86%)
Mutual labels:  gradient
Adam-optimizer
Implemented Adam optimizer in python
Stars: ✭ 43 (-87.28%)
Mutual labels:  gradient
Gradient Widgets
Flutter widgets wrapped with gradients
Stars: ✭ 290 (-14.2%)
Mutual labels:  gradient
mixed-precision-pytorch
Training with FP16 weights in PyTorch
Stars: ✭ 72 (-78.7%)
Mutual labels:  gradient
Gradientprogressbar
πŸ“Š A customizable gradient progress bar (UIProgressView).
Stars: ✭ 311 (-7.99%)
Mutual labels:  gradient
Gradientable
Gradiention Protocol in iOS
Stars: ✭ 26 (-92.31%)
Mutual labels:  gradient
Svgwave
🌊 SVG Wave is a tiny, free and beautiful SVG gradient waves generator for your UI or website desgin. It offers dead simple UI to customize, and style your waves based on your theme specifications.
Stars: ✭ 255 (-24.56%)
Mutual labels:  gradient
Pastel
🎨 Gradient animation effect like Instagram
Stars: ✭ 3,355 (+892.6%)
Mutual labels:  gradient
Hue
🎨 Hue is the all-in-one coloring utility that you'll ever need.
Stars: ✭ 3,306 (+878.11%)
Mutual labels:  gradient
Skeleton
Skeleton Android
Stars: ✭ 293 (-13.31%)
Mutual labels:  gradient

Rainbow

License API BuildStatus Android Weekly KotlinWeekly Javadoc

🌈 An easy way to apply gradations and tinting for Android.

Download

Maven Central Jitpack

Gradle

Add below codes to your root build.gradle file (not your module build.gradle file).

allprojects {
    repositories {
        mavenCentral()
    }
}

And add a dependency code to your module's build.gradle file.

dependencies {
    implementation "com.github.skydoves🌈1.0.3"
}

Usage

We can apply gradations and tinting to any views easily using Rainbow class.

Palette

Palette lambda expression collects colors for creating gradation.
We can collect colors using contextColor and color functions.
contextColor gets a resource color from your colors.xml file, and color gets a ColorInt color.
They should be used with + operator in the palette lambda expression.

Rainbow(myCardView).palette { // constructs a palette for collecting colors.
  +contextColor(R.color.red_200) // getting a color from the resource
  +contextColor(R.color.yellow_200)
  +contextColor(R.color.green_200)
  +contextColor(R.color.blue_200)
  +color(Color.WHITE) // getting a color
}.withAlpha(225) // sets alpha (0~255)
 .foreground() // applies gradations to myCardView

Here is a kotlin-extesion way to apply gradations using View.rainbow() method to views.

myLinearLayout.rainbow().palette {
  +contextColor(R.color.skyBlue)
  +contextColor(R.color.colorPrimary)
}.background(orientation = RainbowOrientation.TOP_BOTTOM, radius = 8)

Background, Foreground

We can apply gradations composed with palette colors to the view's background or foreground.
The forground() method can be applied to your CardView or something others.

Rainbow(myCardView).palette {
  +contextColor(R.color.red_200)
  +contextColor(R.color.yellow_200)
}.background() or .foreground()

And we can control the gradient orientation and corner radius.
We can use 8 kinds of orientation which RainbowOrientation.

background(orientation = RainbowOrientation.RIGHT_LEFT, radius = 8)
background(orientation = RainbowOrientation.TOP_BOTTOM, radius = 8)
foreground(RainbowOrientation.DIAGONAL_TOP_LEFT, 8)
foreground(RainbowOrientation.DIAGONAL_BOTTOM_RIGHT, 8)

Tinting

We can change some kinds of view's tint colors which can be applied tint.
Here are views can be applied tint: TextView(drawable), ImageView, CompoundButton, TintableBackgroundView.

Rainbow(myCheckBox).palette {
  +contextColor(R.color.red_200)
}.tint()

Drawable

We can get a GradientDrawable using getDrawable method.

val drawable = Rainbow(myCheckBox).palette {
  +contextColor(R.color.red_200)
  +contextColor(R.color.yellow_200)
}.getDrawable()

RainbowView

RainbowView is a gradient view for implementing gradations.

Add following XML namespace inside your XML layout file.

xmlns:app="http://schemas.android.com/apk/res-auto"

RainbowView in xml layout

<com.skydoves.rainbow.RainbowView
  android:id="@+id/rainbow"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  app:rainbowView_colors="@array/colors" // colors for gradient.
  app:rainbowView_orientation="left_right" // gradient orientation.
  app:rainbowView_radius="12dp" // corner radius.
/>

The rainbowView_colors attributes gets color list from the color-array from your colors.xml.

<resources>
  <color name="colorPrimary">#C51162</color>
  ...
  <array name="colors">
    <item>@color/red_100</item>
    <item>@color/orange_100</item>
    <item>@color/yellow_100</item>
    <item>@color/green_100</item>
    ...
  </array>
</resources>

BinaryRainbowView

BinaryRainbowView is a gradient view for implementing a simple view with gradations.

<com.skydoves.rainbow.BinaryRainbowView
  android:layout_width="match_parent"
  android:layout_height="80dp"
  app:binaryRainbowView_startColor="@color/md_green_100" // starting color of the gradient.
  app:binaryRainbowView_centerColor="@color/white" // center color of the gradient.
  app:binaryRainbowView_endColor="@color/skyBlue" // end color of the gradient.
  app:binaryRainbowView_orientation="bottom_top" // gradient orientation.
  app:binaryRainbowView_radius="12dp" // corner radius
/>

Shuffle

RainbowView and BinaryRainbowView provides shuffling the palette colors using shuffleColors() method. The gradation colors placement will be changed randomly.

rainbow.shuffleColors()

Usage in Java

Here are some usages for Java developers.

new Rainbow(myView)
    .addContextColor(R.color.red_100)
    .addContextColor(R.color.orange_100)
    .addContextColor(R.color.yellow_100)
    .addContextColor(R.color.green_100)
    .withAlpha(255)
    .background(RainbowOrientation.RIGHT_LEFT, 8);

Find this library useful? ❀️

Support it by joining stargazers for this repository. ⭐️

License

Copyright 2019 skydoves (Jaewoong Eum)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the 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].