mirror of
https://github.com/janishutz/color-thief.git
synced 2025-11-25 13:54:25 +00:00
172 lines
4.1 KiB
HTML
Executable File
172 lines
4.1 KiB
HTML
Executable File
<!doctype html>
|
|
<html class="no-js" lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
|
|
<link href='http://fonts.googleapis.com/css?family=Varela+Round|Terminal+Dosis:400,700,600' rel='stylesheet' type='text/css'>
|
|
|
|
<title>Image Palette</title>
|
|
<meta name="description" content="">
|
|
<meta name="author" content="">
|
|
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
|
|
<link rel="stylesheet" href="css/app.css">
|
|
|
|
<script src="js/libs/modernizr-2.0.6.min.js"></script>
|
|
</head>
|
|
<body>
|
|
|
|
<div id="container">
|
|
<header>
|
|
<h1>Image Palette</h1>
|
|
</header>
|
|
|
|
<div id="main" role="main">
|
|
|
|
<div class="imageSection">
|
|
<img src="img/icon1.png" />
|
|
<div class="colors">
|
|
|
|
<div class="function dominantColor">
|
|
<h3>getDominantColor()</h3>
|
|
</div>
|
|
|
|
<div class="function medianCutPalette">
|
|
<h3>createMedianCutPalette()</h3>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="imageSection">
|
|
<img src="img/icon2.gif" />
|
|
<div class="colors">
|
|
|
|
<div class="function dominantColor">
|
|
<h3>getDominantColor()</h3>
|
|
</div>
|
|
|
|
<div class="function medianCutPalette">
|
|
<h3>createMedianCutPalette()</h3>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="imageSection">
|
|
<img src="img/icon3.png" />
|
|
<div class="colors">
|
|
|
|
<div class="function dominantColor">
|
|
<h3>getDominantColor()</h3>
|
|
</div>
|
|
|
|
<div class="function medianCutPalette">
|
|
<h3>createMedianCutPalette()</h3>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="imageSection">
|
|
<img src="img/4.png" />
|
|
<div class="colors">
|
|
<div class="function dominantColor">
|
|
<h3>getDominantColor()</h3>
|
|
</div>
|
|
<div class="function medianCutPalette">
|
|
<h3>createMedianCutPalette()</h3>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="imageSection">
|
|
<img src="img/5.png" />
|
|
<div class="colors">
|
|
<div class="function dominantColor">
|
|
<h3>getDominantColor()</h3>
|
|
</div>
|
|
<div class="function medianCutPalette">
|
|
<h3>createMedianCutPalette()</h3>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="imageSection">
|
|
<img src="img/6.jpeg" />
|
|
<div class="colors">
|
|
<div class="function dominantColor">
|
|
<h3>getDominantColor()</h3>
|
|
</div>
|
|
<div class="function medianCutPalette">
|
|
<h3>createMedianCutPalette()</h3>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<footer>
|
|
|
|
</footer>
|
|
</div> <!--! end of #container -->
|
|
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
|
|
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.6.2.min.js"><\/script>')</script>
|
|
|
|
<script src="js/libs/quantize.js"></script>
|
|
<script src="js/libs/jquery.imagesloaded.js"></script>
|
|
<script src="js/libs/mustache.js"></script>
|
|
|
|
<script src="js/color-thief.js"></script>
|
|
|
|
<script>
|
|
$(document).ready(function(){
|
|
|
|
|
|
var view = {
|
|
title: "Joe",
|
|
calc: function() {
|
|
return 2 + 4;
|
|
}
|
|
}
|
|
|
|
var template = "{{title}} spends {{calc}}";
|
|
|
|
var html = Mustache.to_html(template, view);
|
|
|
|
$('body').prepend(html);
|
|
|
|
$('img').imagesLoaded(function(){
|
|
|
|
$('img').each(function(index){
|
|
|
|
var dominantColor = getDominantColor(this);
|
|
var medianPalette = createPalette(this, 10);
|
|
|
|
var imageSection = $(this).closest('.imageSection');
|
|
|
|
var switchEl;
|
|
|
|
swatchEl = $('<div>', {
|
|
'class': 'swatch'
|
|
}).css('background-color','rgba('+dominantColor.r+','+dominantColor.g+ ','+dominantColor.b+', 1)');
|
|
|
|
imageSection.find('.dominantColor').append(swatchEl);
|
|
|
|
var medianCutPalette = imageSection.find('.medianCutPalette');
|
|
|
|
$.each(medianPalette, function(index, value){
|
|
swatchEl = $('<div>', {
|
|
'class': 'swatch'
|
|
}).css('background-color','rgba('+value[0]+','+value[1]+ ','+value[2]+', 1)');
|
|
medianCutPalette.append(swatchEl);
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|