Skip to content

Instantly share code, notes, and snippets.

@hushin
Last active December 18, 2015 02:49
Show Gist options
  • Save hushin/5714266 to your computer and use it in GitHub Desktop.
Save hushin/5714266 to your computer and use it in GitHub Desktop.
Adobe Kuler からいい感じの色の組み合わせを抜いてくるスクリプト

これは何

Adobe Kuler からいい感じの色の組み合わせを抜いてくるスクリプト です。 Kuler API というのがあったらしいけど今見たら提供されてなかったので書いた。 自己責任で使ってください。

getHexBackgroundColor

http://stackoverflow.com/questions/3048838/jquery-css-color-value-returns-rgb をそのままコピーしてます。

使い方

色を抜いてくるKulerのページを開く。 ex) https://kuler.adobe.com/explore/most-favorite/?time=month

下のkuler_parse.js を chromeのデベロッパーツール -> Console に貼付けて実行する。

result.js のようにConsoleに抽出される。

$.fn.getHexBackgroundColor = function() {
var rgb = $(this).css('background-color');
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
function hex(x) {return ("0" + parseInt(x).toString(16)).slice(-2);}
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}
$(".collection-assets-item .frame").each(function () {
var colors = $(this).children().map(function () {
return "'" + $(this).getHexBackgroundColor() + "'";
}).get().toString();
console.log("[" + colors + "],");
})
['#3fb8af','#7fc7af','#dad8a7','#ff9e9d','#ff3d7f'],
['#a3d9b0','#93bf9e','#f2f0d5','#8c8474','#40362e'],
['#c3ae8d','#f25260','#2d5f73','#6badc9','#8fced6'],
['#212640','#5d718c','#4b95a6','#60bfbf','#eff2d8'],
['#013440','#035159','#94f2e9','#fcf5b9','#f2d2b6'],
['#aeb05d','#dcd191','#d3a46e','#e39871','#bf6263'],
['#0f2648','#17345b','#224d73','#d9c589','#bfa980'],
['#74002b','#201811','#5e3b1b','#8c683b','#d9c291'],
['#f23041','#f25764','#f2c2cb','#c8d98b','#f2f2f2'],
['#738a02','#ffa30d','#f25516','#c90502','#660b55'],
['#0f808c','#6c8c26','#f2a71b','#f26a1b','#d91818'],
['#eaf4ff','#6a7e93','#b7cbe0','#937f5b','#e0d1b7'],
['#bf834e','#718263','#4e6970','#6e3c2c','#d9d09a'],
['#292930','#4a4140','#168a83','#cca18e','#820132'],
['#04c4d9','#05f2f2','#fcf100','#f2cb05','#fe8c05'],
['#010a26','#04d9d9','#f2cf66','#f2994b','#f24b0f'],
['#fff6c9','#f0c068','#d97643','#9c4d3d','#8f152c'],
['#7a9942','#e3e3e3','#8c2e2e','#3a3a3a','#2c729e'],
['#084141','#005958','#009090','#08bcbd','#08dfe1'],
['#8fbabf','#f2ead0','#d9c39a','#a68c6d','#593a2f'],
['#1d0325','#290331','#320240','#a63b32','#d9411e'],
['#322e25','#504c40','#a6382e','#d94a3d','#dfc8bb'],
['#ff4800','#f27442','#ffa27d','#10b397','#7dffe9'],
['#e61d4d','#32bfb5','#e6ded3','#e6a600','#0f0038'],
['#6f7064','#97a97f','#b9c18a','#f7edd9','#899596'],
['#539da6','#93cfda','#8c8379','#d9af8b','#a65851'],
['#de5605','#f7a035','#b1deb5','#efecca','#65aba6'],
['#08a689','#82bf56','#c7d93d','#e9f2a0','#f2f2f2'],
['#254559','#f2d5bb','#d9a491','#d97979','#bf657d'],
['#d92332','#8c232c','#732735','#f2d995','#1d2126'],
['#000000','#154d4d','#c8c832','#808080','#ffffff'],
['#3d7178','#dddddd','#191919','#323232','#5a5a5a'],
['#1f2226','#727372','#bf2c2c','#8c2727','#732432'],
['#e3997c','#334157','#8fad90','#b7cf9a','#e6d5a7'],
['#e8cab3','#b58681','#87657c','#60557a','#ff7fc8'],
['#f7bd7b','#ae161e','#6a1410','#3f0d09','#171e23'],
// 没
$(".collection-assets-item .frame").map(function () {
return [$(this).children().map(function () {
return $(this).getHexBackgroundColor();
}).get()];
}).get()
$.fn.getHexBackgroundColor = function() {
var rgb = $(this).css('background-color');
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
function hex(x) {return ("0" + parseInt(x).toString(16)).slice(-2);}
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}
$(".collection-assets-item .frame").map(function () {
return "[" + $(this).children().map(function () {
return "'" + $(this).getHexBackgroundColor() + "'";
}).get().join(", ") + "]";
}).get().join(", ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment