Coder Social home page Coder Social logo

changjiashuai / multi-colorpicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from skydoves/multi-colorpicker

0.0 2.0 0.0 10.19 MB

Android multi colorpicker for getting colors from any images by tapping on the desired color.

License: Apache License 2.0

Kotlin 100.00%

multi-colorpicker's Introduction

Multi-ColorPicker

API License
You can get colors from your gallery pictures or custom images just using touch with multi-selectors.

gif0

Examples

gif1 example2-2

Including in your project

build.gradle

repositories {
    mavenCentral() // or jcenter() works as well
}

dependencies {
    implementation "com.github.skydoves:multicolorpicker:1.0.8"
}

or Maven

<dependency>
  <groupId>com.github.skydoves</groupId>
  <artifactId>multicolorpicker</artifactId>
  <version>1.0.8</version>
</dependency>

How to use

You can use like using just ImageView and you can get colors from any images.

Add XML Namespace

First add below XML Namespace inside your XML layout file.

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

ColorPickerView in layout

<com.skydoves.multicolorpicker.MultiColorPickerView
        android:id="@+id/multiColorPickerView"
        android:layout_width="300dp"
        android:layout_height="300dp"
        app:palette="@drawable/palette"/>

Attribute in xml

app:palette="@drawable/palette" // set palette image

get Colors from Listener

multiColorPickerView.addSelector(selectorDrawable, new ColorListener() {
            @Override
            public void onColorSelected(ColorEnvelope envelope) {
                int color = envelope.getColor();
                int[] rgb = envelope.getRgb();
                String htmlCode = envelope.getHtmlCode();

                // TODO
            }
        });

MultiColorPickerView Methods

Methods Return Description
addSelector(Drawable drawable, ColorListener listener) Selector adds a Selector and returning it
setPaletteDrawable(Drawable drawable) void changes palette's drawable
getMixedColor(Float ratio(0~1)) void returns mixed color from selectors seleted color
setSelectedAlpha(Float ratio(0~1) void sets active selector's alpha
getSelectorsSize() int returns selectors size
setFlagView(FlagView flagView) void sets a FlagView on colorpicker
setFlagMode(FlagMode flagmode) void sets FlagMode(Always, Last, None)
setFlagFlipable(boolean flipable) void sets flag's flip-able when flag go over top boundary

Selector Methods

Methods Return Description
getX() int returns selector's X axis
getY() int returns selector's Y axis
getColor() int returns the selector's selected color
getColorHtml() String returns the selector's selected color html code
getColorRGB() int[3] returns the selector's selected color rgb array
onMove(int x, int y) void moves the selector's point
onMoveCenter() void moves the selector's point to center
onSelect() void selects point at selector's position (used with onMove())
onSelect(int x, int y) void moves and selects point

License

Copyright 2017 skydoves

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.

multi-colorpicker's People

Contributors

skydoves avatar

Watchers

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