Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including react-native-bitmap-color-picker with all npm packages installed. Try it out:

var reactNativeBitmapColorPicker = require("react-native-bitmap-color-picker")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

react-native-bitmap-color-picker v1.0.2

A color picker on a bitmap image palette

react-native-bitmap-color-picker

npm version npm downloads npm licence Platform

A color picker on a bitmap image palette.

PS: The colour wheel picture was published on Pixabay by Pete Linforth .

Install

npm i --save react-native-bitmap-color-picker

Usage

import React from 'react';
import { View } from 'react-native';
import { BitMapColorPicker as ColorPicker } from 'react-native-bitmap-color-picker';

export default class SliderColorPickerExample extends React.Component {
    constructor(props) {
        super(props);
        this.state = { oldColor: "#f77100" };
    }

    componentDidMount() {
        setTimeout(() => this.colorPicker && this.colorPicker.setOldColor('#fde200'), 1000);
    }

    changeColor = (colorRgb, resType) => resType === 'end' && this.setState({ oldColor: colorRgb })

    render() {
        return (
            <View style={{flex: 1, alignItems: 'center'}}>
                <ColorPicker
                    ref={view => {this.colorPicker = view;}}
                    oldColor={this.state.oldColor}
                    onColorChange={this.changeColor}
                    style={{width: 200, height: 200}}/>
            </View>
        );
    }
}

Props

PropTypeOptionalDefaultDescription
oldColorColor stringYesundefinedInitial positon of the picker indicator
onColorChangefunctionYesCallback continuously called while the user is dragging the picker indicator. The 1st argument is Color string. There is 2nd string argument 'end' when the picker indicator is released.
stylestyleYesThe style applied to the BitMapColorPicker container
base64BmpstringYesrequire('./colour-wheel-1740381_300.js').defaultThe bitmap palette base64 string, comes from some base64 convert tool against a bmp.

Methods

setOldColor(color)

Use this method to change positon of the picker indicator.

Sponsor

Alipay: flyskywhy@gmail.com

ETH: 0xd02fa2738dcbba988904b5a9ef123f7a957dbb3e

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free