Giter VIP home page Giter VIP logo

bright's Introduction

Android Arsenal JitPack IO


Bright

Description

Bright provides an easy way to determine if a background color is light or dark in order to choose an appropriate text color (black on light colors and white on dark colors) or to convert an image to grayscale. To do so, it calculates the luminance of a color from its rgb value or the luminance of an area (bitmap) from its average color.

The library is configurable through two variants:

  • RELATIVE: relative luminance following the Luma recommendation BT. 709
  • PERCEIVED: perceived luminance following the Luma recommendation CCIR 601

and a performance boost option:

  • PERFORMANCE: trade accuracy for performance

Integration

Auto

Two-steps integration using JitPack

Manual

  • Download the latest version
  • Move it in the library folder of your project: libs/bright-1.0.aar
  • Add the following dependency to your build.gradle
    repositories {
        flatDir {
            dirs 'libs'
        }
    }
    
    dependencies {
        compile 'com.devddagnet.bright.lib:bright:1.0@aar'
    }

Usage

Basic

Get the luminance of a color or an area

    int luminance = Bright.getInstance().brightness(color/rgb/bitmap);

Check if it is brighter than dark

    Bright.getInstance().isBright(luminance);

Or directly check from a color or an area

    Bright.getInstance().isBright(rgb/bitmap)

Options

Luminance variants: RELATIVE, PERCEIVED

Performance boost: PERFORMANCE

Get brightness from the relative luminance

    int luminance = Bright.setup(Config.RELATIVE).brightness(color/rgb/bitmap)

Get brightness from the perceived luminance

    int luminance = Bright.setup(Config.PERCEIVED).brightness(color/rgb/bitmap)

Trade accuracy for performance

    Bright.setup(Config.RELATIVE | Config.PERFORMANCE)

    Bright.setup(Config.PERCEIVED | Config.PERFORMANCE)

Sample

APK | Sources

MultiColorFragment - A set of colored blocks with a white or black text, relatively to the brightness of the text background color.

PictureFragment - A series of pictures with text in all corners and in the center, white or black relatively to the brightness of the background area

Bright(X) - X is the luminous intensity

Video

Sample Video

Glossary

Luminance: a photometric measure of the luminous intensity per unit area of light travelling in a given direction.

License

Copyright 2016 Damien Dagnet

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.

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.