Descripción: Inicialización para el apunte "Paleta de colores desde imagen".
A continuación mostramos los apuntes asociados a este extra:
// Descripción para sindicación:
/*
[rss]Inicialización para el apunte "Paleta de colores desde imagen".[/rss]
*/
if (window.onload != undefined) {
guardar_coloresImagen = window.onload;
window.onload = function() {
guardar_coloresImagen();
iniciosVarios();
}
}
else
window.onload = iniciosVarios;
function iniciosVarios() {
oncambiar();
onclickar();
}
function tag(id) {return document.getElementById(id);}
function oncambiar() {
eventuar(tag("captura"), "change", submitar);
}
function submitar() {
this.form.submit()
}
function onclickar() {
for (i = 0; i < 256; i++)
eventuar(tag("color_" + i), "click", seleccionar);
}
function seleccionar() {
tag("seleccionado").value = "#" + this.title
tag("seleccionado").style.backgroundColor = "#" + this.title
}
// eventuar
function eventuar(elemento, evento, f) {
if (document.addEventListener) elemento.addEventListener(evento, f, true);
else if (document.attachEvent) elemento.attachEvent("on" + evento, f);
else elemento["on" + evento] = f;
}
function visible(estado) {
return (estado) ? "visible":"hidden";
};
function mostrarPaleta(cual) {
for (i = 0, max = cual.length; i < 256; i++) {
tag("color_" + i).style.visibility = visible(i < max);
if (i < cual.length) {
tag("color_" + i).style.backgroundColor = "#" + cual[i];
tag("color_" + i).title = cual[i];
}
}
// alert(cual);
}
Este código ha sido leído en 98 ocasiones.
Esta extra aún no tiene comentarios.
Valoración de esta página: (extra.script.coloresImagen)
Listados: imágenes, categorías, etiquetas, extras | Anuarios: 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 | Otros enlaces: buscador