Color Cross Fade


Source link: https://github.com/noties/ColorCrossFade

Color Cross Fade

Simple color cross fade utility for Android. Supported types: RGB, ARGB, HSV, HSV (with alpha).

Introduction

The main concept of CCFAnimator is to be able to evaluate a color value that lies between two supplied colors given the fraction (.0F - 1.F). This gives ability to smoothly transition from one state to other, for example during ViewPager page changes ( positionOffset value of OnPageChangeListener), during scroll changes of numerous scrolling widgets (RecyclerView, ListView, ScrollView, etc) and much more places where there is a state change & this change could be represented as a float in range .0F - 1.F.

Also, CCFAnimator could be used as a ValueAnimator, to just trigger color animations. CCFAnimator.asValueAnimator(OnNewColorListener) returns a ValueAnimator that could be further customized (animation duration, interpolation, etc).

There is an ability to animate between more than two (2) colors. Use build-in methods in CCFAnimator that takes an array (rgb, argb, hsv).

Usage

RGB

Animates between supplied colors, but ignores alpha channel

CCFAnimator.rgb(int fromColor, int toColor);
 CCFAnimator.rgb(int[] colors);

ARGB

Animates between supplied colors changing a-r-g-b channels of colors

CCFAnimator.argb(int fromColor, int toColor);
 CCFAnimator.argb(int[] colors);
  CCFAnimator.alpha(int color, int toAlpha);
 // animates alpha value of one color

HSV

Animates between supplied colors changing h-s-v channels of colors

// no alpha CCFAnimator.hsv(int fromColor, int toColor);
 CCFAnimator.hsv(int[] colors);
  // with alpha channel CCFAnimator.hsv(int fromColor, int toColor, int fromAlpha, int toAlpha);

Concat

Instances of CCFAnimator of any type could be merged into one CCFAnimator. This could be helpfull when different types of color animations are used for one cross-fade animation (RGB, ARGB, HSV)

CCFAnimator.concat(
  CCFAnimator.rgb(...),
  CCFAnimator.argb(...),
  CCFAnimator.hsv(...) );

ValueAnimator

final CCFAnimator ccf = CCFAnimator.rgb(...);
 final ValueAnimator animator = ccf.asValueAnimator(new OnNewColorListener() {

  @Override
  public void onNewColor(int color) {

// ready to use color

mSomeView.setBackgroundColor(color);

  
}
 
}
);
 animator.setDuration(1000L);
 animator.setInterpolator(new AccelerateInterpolator());
 animator.start();

License

  Copyright 2015 Dimitry Ivanov ([email protected])
 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. 

Resources

A simple QRCode generation api for java built on top ZXING.

The utilities provided here allow for automatic unsubscription from sequences based on Activity or Fragment lifecycle events. This capability is useful in Android, where incomplete subscriptions can cause memory leaks.

With Carpaccio, your views became smarter, instead of calling functions on views, now your views can call functions! You no longer need to extend a view to set a custom behavior.

This Android project samples some Material Design-ish transitions for list items and floating action buttons. It uses the the shared element concept introduced in Android 5.0.

This library implements a color picker and a color preference for use in Android applications.

Batch uninstall Android apps using this very convenient script. Just supply a package name (or part of it) and the script will take care of the uninstallation.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes