This commit is contained in:
abe- 2017-06-19 01:22:28 +02:00
parent 48a9d46474
commit ff3da7ff2d

View file

@ -2,8 +2,6 @@ var cuencas, cmap;
var ids,nombres,colores,x,y; var ids,nombres,colores,x,y;
var capas,capaspg,imgs; var capas,capaspg,imgs;
var dim, dimr; var dim, dimr;
var pg;
var zoom;
function preload() { function preload() {
ids = new Array("norte","duero","ebro","pirineo","jucar","tajo","guadiana","guadalquivir","sur","segura","baleares"); ids = new Array("norte","duero","ebro","pirineo","jucar","tajo","guadiana","guadalquivir","sur","segura","baleares");
@ -24,13 +22,6 @@ function preload() {
} }
function setup() { function setup() {
pg = createGraphics(800, 519);
var as = 519. / 800.;
zoom = .95;
var framesWidth = document.getElementById("#p5").offsetWidth;
var framesHeight = document.getElementById("#p5").offsetHeight;
createCanvas(800, 519); createCanvas(800, 519);
nombres = new Array("Norte","Duero","Ebro","Pirineo","Jucar","Tajo","Guadiana","Guadalquivir","Sur", "Segura", "Baleares y Canarias"); nombres = new Array("Norte","Duero","Ebro","Pirineo","Jucar","Tajo","Guadiana","Guadalquivir","Sur", "Segura", "Baleares y Canarias");
colores = new Array("#f00","#0f0","#00f","#ff0","#0ff","#a00","#0a0","#00a","#aa0","#0aa", "#aaa"); colores = new Array("#f00","#0f0","#00f","#ff0","#0ff","#a00","#0a0","#00a","#aa0","#0aa", "#aaa");
@ -41,20 +32,12 @@ function setup() {
function draw() { function draw() {
// Resize: background("#cad2d3");
var w = min(800,width*.85);
var h = w*519./800.;
zoom = w*800.;
var mx = map(mouseX-width/2+w/2,0,w,0,800);
var my = map(mouseY-height/2+h/2,0,h,0,519);
pg.background("#cad2d3");
// capas // capas
for (var n = 0; n < ids.length; n++) { for (var n = 0; n < ids.length; n++) {
if (dimr[n] != -1) pg.image(capas[n],0,0); if (dimr[n] != -1) image(capas[n],0,0);
else { else {
pg.image(imgs[n], 0, 0); image(imgs[n], 0, 0);
} }
} }
@ -62,52 +45,49 @@ function draw() {
var mc = cmap.get(mx,my); var mc = cmap.get(mx,my);
for (var n = 0; n < colores.length; n++) { for (var n = 0; n < colores.length; n++) {
if (compara(mc,color(colores[n]))) { if (compara(mc,color(colores[n]))) {
pg.tint(255,100); tint(255,100);
pg.image(capaspg[n],0, 0); image(capaspg[n],0, 0);
pg.noTint(); noTint();
} }
} }
// nombres // nombres
pg.textSize(14); textSize(14);
for (var n = 0; n < nombres.length; n++) { for (var n = 0; n < nombres.length; n++) {
//var nbr = String.prototype.toUpperCase(nombres[n]); //var nbr = String.prototype.toUpperCase(nombres[n]);
if (dimr[n] != -1 || !compara(mc,color(colores[n]))) fill(0); if (dimr[n] != -1 || !compara(mc,color(colores[n]))) fill(0);
else fill(0); else fill(0);
pg.noStroke(); noStroke();
pg.textStyle(BOLD); textStyle(BOLD);
pg.text(nombres[n], x[n], y[n]-10); text(nombres[n], x[n], y[n]-10);
pg.textStyle(NORMAL); textStyle(NORMAL);
if (compara(mc,color(colores[n]))) { if (compara(mc,color(colores[n]))) {
pg.text("Plan inicial: " + dim[n]+" Has", x[n], y[n]+5); text("Plan inicial: " + dim[n]+" Has", x[n], y[n]+5);
} }
else { else {
pg.noStroke(); noStroke();
if (dimr[n] != -1) pg.text("Parcela media: " + dimr[n]+" Has", x[n], y[n]+5); if (dimr[n] != -1) text("Parcela media: " + dimr[n]+" Has", x[n], y[n]+5);
else pg.text("(Sin datos)", x[n], y[n]+5); else text("(Sin datos)", x[n], y[n]+5);
} }
} }
// Titulo // Titulo
pg.fill(255,200); fill(255,200);
pg.stroke(155); stroke(155);
pg.rect(605, 365, 170, 130); rect(605, 365, 170, 130);
pg.fill(0); fill(0);
pg.textStyle(BOLD); textStyle(BOLD);
pg.textSize(12); textSize(12);
pg.text("TAMAÑO MEDIO DE EXPLOTACIÓN ENTREGADA A COLONO", 620, 380, 150, 80); text("TAMAÑO MEDIO DE EXPLOTACIÓN ENTREGADA A COLONO", 620, 380, 150, 80);
pg.textStyle(NORMAL); textStyle(NORMAL);
pg.textSize(11); textSize(11);
pg.noStroke(); noStroke();
pg.fill(155,0,0); fill(155,0,0);
pg.text("Interacción con el ratón:",620, 430, 150, 20); text("Interacción con el ratón:",620, 430, 150, 20);
pg.fill(0); fill(0);
pg.text("Datos reales (verde) frente a datos según Plan de Colonización (blanco)", 620, 445, 150, 80); text("Datos reales (verde) frente a datos según Plan de Colonización (blanco)", 620, 445, 150, 80);
background("#cad2d3");
imageMode(CENTER);
image(pg,width/2, height/2,w,h);
} }