Skip to content

Instantly share code, notes, and snippets.

@oriadam
oriadam / colorValues.js
Last active February 9, 2024 16:01
javascript convert any color to array of rgba values
// return array of [r,g,b,a] from any valid color. if failed returns undefined
function colorValues(color)
{
if (!color)
return;
if (color.toLowerCase() === 'transparent')
return [0, 0, 0, 0];
if (color[0] === '#')
{
if (color.length < 7)
@oriadam
oriadam / closest-test-for-jsperf.html
Last active December 5, 2017 13:59
jsPerf closest
<!DOCTYPE html>
<html>
<head>
<style>
name {
display: inline-block;
width: 200px;
}