{"id":11640,"date":"2022-05-21T21:12:41","date_gmt":"2022-05-21T21:12:41","guid":{"rendered":"https:\/\/www.htmlgoodies.com\/?p=11640"},"modified":"2022-05-21T21:12:41","modified_gmt":"2022-05-21T21:12:41","slug":"color-manipulation-javascript","status":"publish","type":"post","link":"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/","title":{"rendered":"Color Manipulation with JavaScript"},"content":{"rendered":"

\"CSS-in-JS<\/p>\n

One of many draws of CSS libraries like Sass and Less are their wide assortment of color manipulation functions such as lighten<\/strong>, darken<\/strong>, saturate<\/strong>, etc. With the growing popularity of CSS-in-JS, the need for JavaScript (JS) equivalents has followed suit. Right on cue, a number of JS libraries for color conversion and manipulation have cropped up to make the jobs of web developers easier. In fact, right now it is hard to settle on which one to use. One library that comes recommended by the popular JSS<\/a> CSS-in-JS library is simply called “color<\/a>“. It is quite feature rich, having more to offer than say color2k and a smaller size than chroma.js. This web development tutorial will provide an overview of some of color’s<\/strong> many features and put them to work in an Angular Single Page Application (SPA).<\/p>\n

Before getting started, you may want to check out our Introduction to CSS-in-JS tutorial<\/a>.<\/p>\n

How to Setup and Install the JSS color Library<\/h2>\n

The recommended way to install color<\/strong> is to use the Node Package Manager (NPM). The command is simply:<\/p>\n

$ npm install color\r\n<\/pre>\n

Or even npm i color<\/code> if you are really into minimizing typing.<\/p>\n

Then you can refer to it in your node.js files using require:<\/p>\n

const Color = require('color');\r\n<\/pre>\n

In Angular, you should use import<\/strong>:<\/p>\n

import Color from 'color';\r\n<\/pre>\n

The exposed Color<\/strong> object provides a few different constructors to choose from, most of which accept some permutation of Red Green Blue (RGB) values. It will also accept a limited number of strings, such as the oft-used HEX format:<\/p>\n

const color = Color('#FFFFFF');\r\nconst color = Color('rgb(255, 255, 255)');\r\nconst color = Color({r: 255, g: 255, b: 255});\r\nconst color = Color.rgb(255, 255, 255);\r\nconst color = Color.rgb([255, 255, 255]);\r\n<\/pre>\n

Under the covers, String<\/strong> constructors are handled by the color-string<\/a> library.<\/p>\n

You can learn more about dynamic styling options by reading our Dynamic Styling with JSS<\/a> tutorial.<\/p>\n

Exploring the JS Color API<\/h2>\n

Color’s<\/strong> API was heavily inspired by color-js<\/a>, whose manipulation functions closely resemble those of CSS tools like Sass, LESS, and Stylus. But, before we get to those, let’s look at how to convert colors to other formats.<\/p>\n

CSS supports a multitude of color types, from preset names like “aliceblue<\/strong>“, and “teal<\/strong>” to HEX (“#ee652e<\/strong>“), RGB (rgb(138, 238, 130))<\/strong>, and RGBA (rgba(0,255,0,0.75))<\/strong>.<\/p>\n

Looking for the rgb<\/strong> number value? Call the hex()<\/strong> method:<\/p>\n

color.hex() \/\/ #ffffff\r\n<\/pre>\n

Convert a color to an rgb<\/strong> object:<\/p>\n

color.object(); \/\/ {r: 255, g: 255, b: 255}\r\n<\/pre>\n

Here’s how to set a hash of the color value and reflect the color’s current model:<\/p>\n

color.rgb().array() \/\/ [255, 255, 255]\r\n<\/pre>\n

To get the individual rgb<\/strong> values, use these:<\/p>\n

color.red()   \/\/255\r\ncolor.green() \/\/255\r\ncolor.blue()  \/\/255\r\n<\/pre>\n

Read<\/strong>: Using an Angular Service to Read Sass Variables<\/a><\/p>\n

Color Manipulation Functions and CSS Colors<\/h3>\n

Sass comes with a lot of great functions that can easily be applied to CSS colors. These functions take some of the sting out of choosing and manipulating colors. These include darken<\/strong> and lighten<\/strong>, saturate<\/strong> and desaturate<\/strong>, rgba<\/strong>, and more. So, too, with the color<\/strong> library. Here’s a sampling:<\/p>\n

\/\/lighten by 50%\r\ncolor.lighten(0.5)     \/\/ hsl(100, 50%, 50%) -> hsl(100, 50%, 75%)\r\n\/\/darken by 50%\r\ncolor.darken(0.5)      \/\/ hsl(100, 50%, 50%) -> hsl(100, 50%, 25%)\r\ncolor.saturate(0.5)    \/\/ hsl(100, 50%, 50%) -> hsl(100, 75%, 50%)\r\ncolor.desaturate(0.5)  \/\/ hsl(100, 50%, 50%) -> hsl(100, 25%, 50%)\r\nrgba(10, 10, 10, 0.8)\r\n<\/pre>\n

Other useful manipulation functions include:<\/p>\n

color.grayscale()      \/\/ #5CBF54 -> #969696\r\ncolor.whiten(0.5)      \/\/ hwb(100, 50%, 50%) -> hwb(100, 75%, 50%)\r\ncolor.blacken(0.5)     \/\/ hwb(100, 50%, 50%) -> hwb(100, 50%, 75%)\r\n\r\ncolor.fade(0.5)        \/\/ rgba(10, 10, 10, 0.8) -> rgba(10, 10, 10, 0.4)\r\ncolor.opaquer(0.5)     \/\/ rgba(10, 10, 10, 0.8) -> rgba(10, 10, 10, 1.0)\r\n\r\ncolor.rotate(180)      \/\/ hsl(60, 20%, 20%) -> hsl(240, 20%, 20%)\r\ncolor.rotate(-90)      \/\/ hsl(60, 20%, 20%) -> hsl(330, 20%, 20%)\r\n\r\ncolor.mix(Color(\"yellow\"))        \/\/ cyan -> rgb(128, 255, 128)\r\ncolor.mix(Color(\"yellow\"), 0.3)   \/\/ cyan -> rgb(77, 255, 179)\r\n<\/pre>\n

All of the above functions may be chained together:<\/p>\n

color.green(100).grayscale().lighten(0.6)\r\n<\/pre>\n

Other functions provide information about a color:<\/p>\n

color.isLight()         \/\/ true\r\ncolor.isDark()          \/\/ false\r\n<\/pre>\n

Using color.js to Set Theme Colors<\/h2>\n

In the last couple of articles on CSS-in-JS we have been adapting the Using an Angular Service to Read Sass Variables Demo<\/a> to employ JSS<\/a> to set an Angular component’s colors via @Input<\/strong> parameters. Although JSS and color.js make a perfect pairing, each library can be used independently of the other. To emphasize that point, we will apply color.js<\/strong> to the Color Service that defines the theme colors for the application.<\/p>\n

In the app.component.scss<\/strong> file, Sass functions are employed to set the light<\/strong> and dark<\/strong> versions of the base colors:<\/p>\n

$backgroundColor: rgb(82, 172, 240);\r\n$lightBackgroundCcolor: lighten($backgroundColor, 16%);\r\n$hoverColor: blue;\r\n$darkHoverColor: darken($hoverColor, 20%);\r\n$focusBorderColor: darkgray;\r\n$darkFocusBorderColor: darken($focusBorderColor, 40%);\r\n<\/pre>\n

Imagine a situation where our application was built using vanilla CSS rather than Sass. Without access to the Sass functions, we would require another means of affecting the base colors. That would be an ideal use of the color library.<\/p>\n

We would still have access to the three base colors via CSS variables:<\/p>\n

.color-demo-app {\r\n  --background-color: rgb(82, 172, 240);\r\n  --hover-color: blue;\r\n  --focus-border-color: lightgray;\r\n}\r\n<\/pre>\n

Now, in loadColors()<\/strong>, we can add two additional calls to the new setMapColor()<\/strong> function for each CSS property’s light<\/strong> and dark<\/strong> variation:<\/p>\n

import Color from 'color';\r\n\r\nconst CSS_PREFIX = \"--\";\r\nconst CSS_SUFFIX = \"color\";\r\nconst CSS_DELIMITER = \"-\";\r\n\r\nexport enum PropertyNames {\r\n  background  = 'background',\r\n  hover       = 'hover',\r\n  focusborder = 'focus-border'\r\n}\r\n\r\npublic loadColors() {\r\n  \/\/ Read the custom property of body section with given name:\r\n  const appElement = \r\n    document.getElementsByClassName('color-demo-app');\r\n  if (appElement && appElement.length > 0) {\r\n    const appStyles = window.getComputedStyle(appElement[0]);\r\n    Object.values(PropertyNames).forEach(propertyName => {\r\n      const cssVariableName = CSS_PREFIX\r\n        + `${propertyName}${CSS_DELIMITER}`\r\n        + CSS_SUFFIX;\r\n      const cssVariableValue = \r\n        appStyles.getPropertyValue(cssVariableName)\r\n                  .replace(' ', '');\r\n      if (cssVariableValue) {\r\n        this.setMapColor(propertyName, cssVariableValue);\r\n      }\r\n      \/\/ load light color \r\n      this.setMapColor(\r\n        propertyName, \r\n        Color(cssVariableValue).lighten(0.2).hex(),\r\n        ColorOptions.light\r\n      );\r\n      \/\/ load dark color \r\n      this.setMapColor(\r\n        propertyName, \r\n        Color(cssVariableValue).darken(0.2).hex(),\r\n        ColorOptions.dark\r\n      );\r\n    });\r\n\r\n    this.setThemeDefaults();\r\n  }\r\n}\r\n<\/pre>\n

Extracting the code to set the _colorMap <\/strong>entry to a helper function only makes sense since we have to do it three times for each CSS property:<\/p>\n

private setMapColor(\r\n  propertyName: PropertyNames, \r\n  value: string,\r\n  colorOption = ColorOptions.standard \r\n) {\r\n  const colorMapKey = <ColorProperty>{\r\n    name: propertyName,\r\n    option: colorOption\r\n  };\r\n  this._colorMap.set(\r\n    JSON.stringify(colorMapKey),\r\n    value\r\n  );\r\n}\r\n<\/pre>\n

You can see how all of the above code works together in the stackblitz demo<\/a>.<\/p>\n

Conclusion<\/h2>\n

There are a few reasons to love color libraries like color.js<\/strong>. Firstly, using JavaScript to manipulate colors provides additional scoping and dynamic execution to accomplish things that would be quite difficult using CSS, even with help from extension libraries like Sass and Less. Another attractive feature is their ease of use, at least where color.js is concerned.<\/p>\n

Read more CSS and web development tutorials by visiting our CSS programming section<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"

One of many draws of CSS libraries like Sass and Less are their wide assortment of color manipulation functions such as lighten, darken, saturate, etc. With the growing popularity of CSS-in-JS, the need for JavaScript (JS) equivalents has followed suit. Right on cue, a number of JS libraries for color conversion and manipulation have cropped […]<\/p>\n","protected":false},"author":90,"featured_media":11641,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[30588,30620],"tags":[4810,3385],"b2b_audience":[37],"b2b_industry":[65],"b2b_product":[71,76,131,68,118,81,82,133,83,84,107,86,30818,93,94,99,114,115,116,85,522,117,80,98,128,135],"acf":[],"yoast_head":"\nColor Manipulation with JavaScript | HTML Goodies<\/title>\n<meta name=\"description\" content=\"An introduction to color manipulation in JavaScript with the JSS colors library. Learn web development and CSS with code examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Color Manipulation with JavaScript | HTML Goodies\" \/>\n<meta property=\"og:description\" content=\"An introduction to color manipulation in JavaScript with the JSS colors library. Learn web development and CSS with code examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"HTML Goodies\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-21T21:12:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2022\/05\/css-in-js-jss-tutorials.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@htmlgoodies\" \/>\n<meta name=\"twitter:site\" content=\"@htmlgoodies\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rob Gravelle\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.htmlgoodies.com\/#organization\",\"name\":\"HTML Goodies\",\"url\":\"https:\/\/www.htmlgoodies.com\/\",\"sameAs\":[\"https:\/\/twitter.com\/htmlgoodies\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.htmlgoodies.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/03\/HTMLg_weblogo_MobileLogo.png\",\"contentUrl\":\"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/03\/HTMLg_weblogo_MobileLogo.png\",\"width\":584,\"height\":136,\"caption\":\"HTML Goodies\"},\"image\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.htmlgoodies.com\/#website\",\"url\":\"https:\/\/www.htmlgoodies.com\/\",\"name\":\"HTML Goodies\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.htmlgoodies.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#primaryimage\",\"url\":\"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2022\/05\/css-in-js-jss-tutorials.png\",\"contentUrl\":\"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2022\/05\/css-in-js-jss-tutorials.png\",\"width\":1200,\"height\":630,\"caption\":\"CSS-in-JS Tutorials\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#webpage\",\"url\":\"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/\",\"name\":\"Color Manipulation with JavaScript | HTML Goodies\",\"isPartOf\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#primaryimage\"},\"datePublished\":\"2022-05-21T21:12:41+00:00\",\"dateModified\":\"2022-05-21T21:12:41+00:00\",\"description\":\"An introduction to color manipulation in JavaScript with the JSS colors library. Learn web development and CSS with code examples.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.htmlgoodies.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Color Manipulation with JavaScript\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/#\/schema\/person\/d340101131281902e682ad0190b7ac75\"},\"headline\":\"Color Manipulation with JavaScript\",\"datePublished\":\"2022-05-21T21:12:41+00:00\",\"dateModified\":\"2022-05-21T21:12:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#webpage\"},\"wordCount\":760,\"publisher\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2022\/05\/css-in-js-jss-tutorials.png\",\"keywords\":[\"CSS\",\"JavaScript\"],\"articleSection\":[\"CSS\",\"Javascript\"],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.htmlgoodies.com\/#\/schema\/person\/d340101131281902e682ad0190b7ac75\",\"name\":\"Rob Gravelle\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.htmlgoodies.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/05\/rob-gravelle-150x150.jpg\",\"contentUrl\":\"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/05\/rob-gravelle-150x150.jpg\",\"caption\":\"Rob Gravelle\"},\"description\":\"Rob Gravelle resides in Ottawa, Canada, and has been an IT guru for over 20 years. In that time, Rob has built systems for intelligence-related organizations such as Canada Border Services and various commercial businesses. In his spare time, Rob has become an accomplished music artist with several CDs and digital releases to his credit.\",\"url\":\"https:\/\/www.htmlgoodies.com\/author\/rob-gravelle\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Color Manipulation with JavaScript | HTML Goodies","description":"An introduction to color manipulation in JavaScript with the JSS colors library. Learn web development and CSS with code examples.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Color Manipulation with JavaScript | HTML Goodies","og_description":"An introduction to color manipulation in JavaScript with the JSS colors library. Learn web development and CSS with code examples.","og_url":"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/","og_site_name":"HTML Goodies","article_published_time":"2022-05-21T21:12:41+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2022\/05\/css-in-js-jss-tutorials.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_creator":"@htmlgoodies","twitter_site":"@htmlgoodies","twitter_misc":{"Written by":"Rob Gravelle","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/www.htmlgoodies.com\/#organization","name":"HTML Goodies","url":"https:\/\/www.htmlgoodies.com\/","sameAs":["https:\/\/twitter.com\/htmlgoodies"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.htmlgoodies.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/03\/HTMLg_weblogo_MobileLogo.png","contentUrl":"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/03\/HTMLg_weblogo_MobileLogo.png","width":584,"height":136,"caption":"HTML Goodies"},"image":{"@id":"https:\/\/www.htmlgoodies.com\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/www.htmlgoodies.com\/#website","url":"https:\/\/www.htmlgoodies.com\/","name":"HTML Goodies","description":"","publisher":{"@id":"https:\/\/www.htmlgoodies.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.htmlgoodies.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#primaryimage","url":"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2022\/05\/css-in-js-jss-tutorials.png","contentUrl":"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2022\/05\/css-in-js-jss-tutorials.png","width":1200,"height":630,"caption":"CSS-in-JS Tutorials"},{"@type":"WebPage","@id":"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#webpage","url":"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/","name":"Color Manipulation with JavaScript | HTML Goodies","isPartOf":{"@id":"https:\/\/www.htmlgoodies.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#primaryimage"},"datePublished":"2022-05-21T21:12:41+00:00","dateModified":"2022-05-21T21:12:41+00:00","description":"An introduction to color manipulation in JavaScript with the JSS colors library. Learn web development and CSS with code examples.","breadcrumb":{"@id":"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.htmlgoodies.com\/"},{"@type":"ListItem","position":2,"name":"Color Manipulation with JavaScript"}]},{"@type":"Article","@id":"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#article","isPartOf":{"@id":"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#webpage"},"author":{"@id":"https:\/\/www.htmlgoodies.com\/#\/schema\/person\/d340101131281902e682ad0190b7ac75"},"headline":"Color Manipulation with JavaScript","datePublished":"2022-05-21T21:12:41+00:00","dateModified":"2022-05-21T21:12:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#webpage"},"wordCount":760,"publisher":{"@id":"https:\/\/www.htmlgoodies.com\/#organization"},"image":{"@id":"https:\/\/www.htmlgoodies.com\/css\/color-manipulation-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2022\/05\/css-in-js-jss-tutorials.png","keywords":["CSS","JavaScript"],"articleSection":["CSS","Javascript"],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.htmlgoodies.com\/#\/schema\/person\/d340101131281902e682ad0190b7ac75","name":"Rob Gravelle","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.htmlgoodies.com\/#\/schema\/person\/image\/","url":"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/05\/rob-gravelle-150x150.jpg","contentUrl":"https:\/\/www.htmlgoodies.com\/wp-content\/uploads\/2021\/05\/rob-gravelle-150x150.jpg","caption":"Rob Gravelle"},"description":"Rob Gravelle resides in Ottawa, Canada, and has been an IT guru for over 20 years. In that time, Rob has built systems for intelligence-related organizations such as Canada Border Services and various commercial businesses. In his spare time, Rob has become an accomplished music artist with several CDs and digital releases to his credit.","url":"https:\/\/www.htmlgoodies.com\/author\/rob-gravelle\/"}]}},"_links":{"self":[{"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/posts\/11640"}],"collection":[{"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/users\/90"}],"replies":[{"embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/comments?post=11640"}],"version-history":[{"count":0,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/posts\/11640\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/media\/11641"}],"wp:attachment":[{"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/media?parent=11640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/categories?post=11640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/tags?post=11640"},{"taxonomy":"b2b_audience","embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/b2b_audience?post=11640"},{"taxonomy":"b2b_industry","embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/b2b_industry?post=11640"},{"taxonomy":"b2b_product","embeddable":true,"href":"https:\/\/www.htmlgoodies.com\/wp-json\/wp\/v2\/b2b_product?post=11640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}