updates before renaming to color-thief

This commit is contained in:
Lokesh Dhakar
2011-11-03 15:36:42 -04:00
parent 69f3e21a83
commit 16894c23f4
10 changed files with 1038 additions and 242 deletions

View File

@@ -1,46 +1,46 @@
$(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').each(function(index){
$('img').imagesLoaded(function(){
$('img').each(function(index){
var averageRGB = getAverageRGB(this);
var dominantColor = getDominantColor(this);
var areaPalette = createAreaBasedPalette(this, 9);
var medianPalette = createMedianCutPalette(this, 10);
var dominantColor = getDominantColor(this);
var medianPalette = createPalette(this, 10);
var imageSection = $(this).closest('.imageSection');
var swatchEl = $('<div>', {
'class': 'swatch'
}).css('background-color','rgba('+averageRGB.r+','+averageRGB.g+ ','+averageRGB.b+', 1)');
var imageSection = $(this).closest('.imageSection');
imageSection.find('.averageRGB').append(swatchEl);
var switchEl;
swatchEl = $('<div>', {
'class': 'swatch'
}).css('background-color','rgba('+dominantColor.r+','+dominantColor.g+ ','+dominantColor.b+', 1)');
imageSection.find('.dominantColor').append(swatchEl);
var areaBasedPalette = imageSection.find('.areaBasedPalette');
$.each(areaPalette, function(index, value){
swatchEl = $('<div>', {
'class': 'swatch'
}).css('background-color','rgba('+value.r+','+value.g+ ','+value.b+', 1)');
areaBasedPalette.append(swatchEl);
});
var medianCutPalette = imageSection.find('.medianCutPalette');
}).css('background-color','rgba('+dominantColor.r+','+dominantColor.g+ ','+dominantColor.b+', 1)');
$.each(medianPalette, function(index, value){
swatchEl = $('<div>', {
'class': 'swatch'
}).css('background-color','rgba('+value[0]+','+value[1]+ ','+value[2]+', 1)');
medianCutPalette.append(swatchEl);
});
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);
});
});
});
});