Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@adrianjost/two-channel-picker
Advanced tools
A simple two channel Color Picker
I needed an intuitive color picker to control my warm-white-cold-white (WWCW) LED Strips with the SmartLight Project.
The picker value is therefore indepent from the displayed color. The given value is a number between 0 and 1 for each of the two channels. The brightness can be determined by dragging the slider along the Y-axis. Dragging along the X-axis changes the relationship between the two channels.
<script src="https://cdn.jsdelivr.net/npm/@adrianjost/two-channel-picker@0.3.1/dist/wc/two-channel-picker.min.js"></script>
<div style="width: 300px; height: 300px;">
<two-channel-picker
value="[0,1]"
id="picker"
options='{"colorLeft": "#f00", "colorRight": "#00f" }'
></two-channel-picker>
</div>
<script>
document.getElementById("picker").addEventListener("input", (event) => {
console.log(event.detail[0]);
});
</script>
please note, that you may need to adjust the version number in the url.
Install the package:
npm i @adrianjost/two-channel-picker
or
yarn add @adrianjost/two-channel-picker
In your App:
<template>
<TwoChannelPicker
v-model="channels"
:options="{
colorLeft: '#fd9',
colorRight: '#9df',
marker: {
radius: 16,
borderWidth: 2,
},
}"
/>
</template>
<script>
import TwoChannelPicker from "@adrianjost/two-channel-picker";
export default {
components: {
TwoChannelPicker,
},
data() {
return {
channels: [0, 1],
};
},
};
</script>
The package also includes some helper methods. You can access them by importing the according js files. Please use the JSDoc comments to learn how to use them.
import {
getChannelsForHueAndBrightness,
getHueAndBrightnessForChannels,
getCenterColor,
getColorForHueAndBrightness,
getColorForChannels,
} from "@adrianjost/two-channel-picker/dist/helpers/channelColor.js";
import {
hex2rgb,
rgb2hex,
} from "@adrianjost/two-channel-picker/dist/helpers/colorConversion.js";
You can customize the picker with the following props/attributes.
When using the lib as a web component you must provide all attributes
JSON.stringify()
-ed.
attribute | type | default value | description |
---|---|---|---|
value / v-model | Array, String | [1,0] | the current channel values, if provided as a String, this must be JSON.parse() -able |
options | Object | {} | all your config goes in here |
Available Attributes in the options
prop:
attribute | type | default value | description |
---|---|---|---|
readOnly | Boolean | false | should the user be able to move the marker? |
colorLeft | String | #fd9 | the color in the top left corner. Must be in the HEX Format with 3 or 6 digits. |
colorRight | String | #fd9 | the color in the top right corner. Must be in the HEX Format with 3 or 6 digits. |
marker.borderWidth | Number | 2 | The border width of the active marker in px. |
marker.radius | Number | 16 | The border radius including the borderWidth in px. |
You need more options? Please open an issue and I will do my best to implement it. Pull Requests are also welcome!
0.3.4
Additions
FAQs
> A simple two channel Color Picker
The npm package @adrianjost/two-channel-picker receives a total of 1 weekly downloads. As such, @adrianjost/two-channel-picker popularity was classified as not popular.
We found that @adrianjost/two-channel-picker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.