{"id":13700350,"url":"https://github.com/webcore-it/colorful-background-css-generator","last_synced_at":"2025-10-09T06:47:59.375Z","repository":{"id":20041418,"uuid":"23309641","full_name":"webcore-it/colorful-background-css-generator","owner":"webcore-it","description":"A colorful css gradient background generator","archived":false,"fork":false,"pushed_at":"2018-06-03T11:54:00.000Z","size":336,"stargazers_count":321,"open_issues_count":3,"forks_count":46,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-06-28T18:47:41.668Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.webcore-it.com/colorful-background/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webcore-it.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-25T10:07:30.000Z","updated_at":"2025-03-13T12:12:10.000Z","dependencies_parsed_at":"2022-08-27T04:01:31.063Z","dependency_job_id":null,"html_url":"https://github.com/webcore-it/colorful-background-css-generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/webcore-it/colorful-background-css-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webcore-it%2Fcolorful-background-css-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webcore-it%2Fcolorful-background-css-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webcore-it%2Fcolorful-background-css-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webcore-it%2Fcolorful-background-css-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webcore-it","download_url":"https://codeload.github.com/webcore-it/colorful-background-css-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webcore-it%2Fcolorful-background-css-generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266679370,"owners_count":23967610,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T20:00:54.607Z","updated_at":"2025-10-09T06:47:54.341Z","avatar_url":"https://github.com/webcore-it.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"A colorful css gradient background generator\n============================================\n\nA pure javascript generator to create colorful css backgrounds.\n\nCheck [this website](http://www.webcore-it.com/colorful-background) to see the generator in action and play with the colors settings.\n\n\nIdea \n----\nThe idea is to have multiple layers of linear css gradients at different angles. The gradients go from color to transparent to let the lower layers shine through and generate the wanted effect. There is no limit in the number of layers.\n\n\n![Visualization of the idea of multiple layers](https://raw.githubusercontent.com/webcore-it/colorful-background-css-generator/master/doc/colorful-background-idea.png \"Visualization of the idea of multiple layers\")\n\nUsage\n-----\nThere are two ways to use this generator:\n\n1. Include the generator in the website\n2. Use it just as a code generator\n\nThere are examples in the `examples` folder.\n\n###1. Include the generator in the website\nAdd the generator (it's in the `dist` folder) to your html file and let it set the background to the element directly.\n\n**include_generator_example.html**\n```html\n\u003c!doctype html\u003e\n\u003chtml lang=\"en\"\u003e\n    \u003chead\u003e\n        \u003cstyle type=\"text/css\"\u003e#colorful {  height: 30em; width: 30em; padding: 1em; }\u003c/style\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003cdiv id=\"colorful\"\u003eThis element will have the colorful background.\u003c/div\u003e\n        \u003cscript src=\"https://raw.githubusercontent.com/webcore-it/colorful-background-css-generator/master/dist/colorful-background-css-generator.min.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n        \u003cscript type=\"text/javascript\"\u003e\n            // The Generator\n            var generator = new ColorfulBackgroundGenerator();\n\n            // This adds 5 layers to the generator\n            // The parameters are: degree[0-360],\n            //                     h[0-360], \n            //                     s[0-1], \n            //                     l[0-1],\n            //                     posColor[0-100], \n            //                     posTransparency[0-100]\n            // The lowest layer (at the bottom) in the css is the first added layer.\n            generator.addLayer(new ColorfulBackgroundLayer({degree: 325, h: 5, s: 0.95, l: 0.55,posColor: 100})); // bottom layer\n            generator.addLayer(new ColorfulBackgroundLayer({degree: 225, h: 75, s: 0.9, l: 0.7, posColor: 30, posTransparency: 80}));\n            generator.addLayer(new ColorfulBackgroundLayer({degree: 155, h: 150, s: 0.95, l: 0.7, posColor: 10, posTransparency: 80}));\n            generator.addLayer(new ColorfulBackgroundLayer({degree: 55, h: 230, s: 0.95, l: 0.65, posColor: 0, posTransparency: 70}));\n            generator.addLayer(new ColorfulBackgroundLayer({degree: 20, h: 300, s: 0.9, l: 0.65, posColor: 0, posTransparency: 55})); // top layer\n\n            // Assign generated style to the element identified by it's id\n            generator.assignStyleToElementId(\"colorful\");\n        \u003c/script\u003e\n    \u003c/body\u003e\n\u003c/html\u003e \n```\n\n###2. Use it just as code generator\nAnother way is to use the generator to generate the css for the background and add this generated css to your style.css. \n\n**generate_css_example.html**\n```html\n\u003c!doctype html\u003e\n\u003chtml lang=\"en\"\u003e\n    \u003chead\u003eGenerate the css class\u003c/head\u003e\n    \u003cbody\u003e\n        \u003cpre id=\"code\"\u003e\u003c/pre\u003e\n        \u003cscript src=\"https://raw.githubusercontent.com/webcore-it/colorful-background-css-generator/master/dist/colorful-background-css-generator.min.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n        \u003cscript type=\"text/javascript\"\u003e\n            // The Generator\n            var generator = new ColorfulBackgroundGenerator();\n\n            // This adds 3 layers to the generator\n            // The parameters are: degree[0-360],\n            //                     h[0-360], \n            //                     s[0-1], \n            //                     l[0-1],\n            //                     posColor[0-100], \n            //                     posTransparency[0-100]\n            // The lowest layer (at the bottom) in the css is the first added layer.\n            generator.addLayer(new ColorfulBackgroundLayer({degree: 50, h: 35, s: 0.95, l: 45, posColor: 100})); // bottom layer\n            generator.addLayer(new ColorfulBackgroundLayer({degree: 140, h: 220, s: 0.9, l: 0.7, posColor: 30, posTransparency: 80}));\n            generator.addLayer(new ColorfulBackgroundLayer({degree: 210, h: 340, s: 0.9, l: 0.65, posColor: 10, posTransparency: 55})); // top layer\n\n            // Print the css style.\n            var element = document.getElementById(\"code\");\n            element.innerHTML = generator.getCSSAsText();\n        \u003c/script\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\n\nHints\n-----\n* Choose a high saturation between `80` and `100` \n* Choose a lightness between `40` and `60`\n* The lowest (first added) layer should have the `posTransparency` at `100` and `posColor` \u003e `50` to make the lowest layer more colorful then the other layers\n\nSupported Browsers\n------------------\nThe only magic are css gradients. So it works with\n* Firefox 16+\n* Safari 5.1+\n* Chrome 10+\n* Internet Explorer 10+\n* Opera 12.1+\n* iOS 5.1+\n* Android 4+\n* Blackberry 10+\n* IE Mobile 10+\n\nSee http://caniuse.com/#feat=css-gradients for more details on css gradients.\n\nLessons Learned\n--------------\n###Transparency in Firefox\nThis is fixed in Firefox 36+ but an issue in earlier versions.\n\nFirefox renders transparency in gradients different than webkit. The trick is to not use `transparent` or `rgba(0,0,0,0)` but the first color with alpha transparency = 0. \n```css\n/* This fades to gray first before fading to transparent. */\ndiv.gray {\n    background: linear-gradient(0deg,  hsla(0,100%,50%,1) 0%, transparent 100%);\n}\n/* This fades from color to transparent. */\ndiv.color {\n    background: linear-gradient(0deg,  hsla(0,100%,50%,1) 0%, hsla(0,100%,50%,0) 100%);\n}\n```\nOpen [this fiddle](http://jsfiddle.net/WebCore_IT/v1gnw2wc/) with Firefox version 16 till 35 to see the difference.\n\n\n###Degrees counting in webkit\n* Prefixed `-webkit-linear-gradient` is counting degrees **counterclockwise**.\u003cbr\u003e\n0° is at the **left side**.\n* The standard `linear-gradient` is counting degrees **clockwise**.\u003cbr\u003e\n0° is at the **bottom side**.\n\nTo convert the degrees of the standard linear-gradient to the -webkit-prefix degrees: (360 - standard-degrees) + 90\n\nOpen [this fiddle](http://jsfiddle.net/WebCore_IT/666datts/) in Chrome 26+ (or Safari 6.1+) to see the difference.\n\n\nLicense\n-----\nThe MIT License (MIT)\n\nCopyright (c) 2014 webcore-it\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebcore-it%2Fcolorful-background-css-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebcore-it%2Fcolorful-background-css-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebcore-it%2Fcolorful-background-css-generator/lists"}