
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
ktk-color is used to transfer format of different kinds of color.
npm install ktk-color
<script>
import Color from 'ktk-color';
const color = Color.tovec4('red'); // [1, 0, 0, 1]
</script>
# Color.tovec4
Returns value in vec4 format.
The value will be clamped between 0 and 1 if exceeds limit.
Returns default value([0, 0, 0, 1]) if not in normal color format.
Color.tovec4('red') // [1, 0, 0, 1]
Color.tovec4('rgb(100,75,50)') // [0.39, 0.29, 0.19, 1]
Color.tovec4('rgba(100,75,50,0.5)') // [0.39, 0.29, 0.19, 0.5]
Color.tovec4('#666666') // [0.4, 0.4, 0.4, 1]
Color.tovec4([0, 0, 0, 1.5]) // [0, 0, 0, 1])
Color.tovec4([0, 0, 0, -0.5]) // [0, 0, 0, 0])
Color.tovec4([1, 100, 0, 0.5]) // [1, 1, 0, 0.5])
Color.tovec4('wrong') // [0, 0, 0, 1]
Color.tovec4(37374) // [0, 0, 0, 1]
# Color.tohex
Returns value in hex format.
Returns default value('#000000') if not in normal color format.
Color.tohex('red') // #ff0000
Color.tohex('rgb(100,100,100)') // #646464
Color.tohex('rgba(100,100,100,0.5)') // #646464
Color.tohex('#666666') // #666666
Color.tohex([1, 0, 0, 1]) // #ff0000
Color.tohex([1, 100, 0, 0.5]) // #ffff00
Color.tohex('wrong') // #000000
Color.tohex(37374) // #000000
# Color.torgb
Returns value in rgb format.
The value will be clamped between 0 and 1 if exceeds limit.
Returns default value('rgb(0, 0, 0)') if not in normal color format.
Color.torgb('red') // rgb(255,0,0)
Color.torgb('rgb(100,75,50)') // rgb(100,75,50)
Color.torgb('rgba(100,100,100,1)') // rgb(100,100,100)
Color.torgb('#646464') // rgb(100,100,100)
Color.torgb('#cde') // rgb(204,221,238)
Color.torgb([1, 100, 0, 0.5]) // rgb(255,255,0)
Color.torgb('wrong') // rgb(0,0,0)
Color.torgb(37374) // rgb(0,0,0)
# Color.torgba
Returns value in rgba format.
Returns default value('rgba(0, 0, 0, 1)') if not in normal color format.
Color.torgba('red') // rgba(255,0,0,1)
Color.torgba('rgb(100,75,50)') // rgba(100,75,50,1)
Color.torgba('rgba(100,100,100,1)') // rgba(100,100,100,1)
Color.torgba('#646464') // rgba(100,100,100,1)
Color.torgba('#cde') // rgba(204,221,238,1)
Color.torgba([1, 100, 0, 0.5]) // rgba(255,255,0,0.5)
Color.torgba('wrong') // rgba(0,0,0,1)
Color.torgba(37374) // rgba(0,0,0,1)
This project is licensed under
FAQs
color format conventer for personal use
We found that ktk-color 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.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.