Commit f5edc027 authored by Nicolas Maleve's avatar Nicolas Maleve

prototype

parent 6f8bf749
$( document ).ready(function() {
var faces=[];
var eyes=[];
var eyes_names=[];
var faces_names=[];
$.getJSON( "jindex.json", function( data ) {
$.each( data, function( key, val ) {
//if(key<20){
var div='<div style="position:absolute;top:10px;left:50%;" id="id_'+key+'"><!---<img src="'+val.name.replace("/home/nicolas/Pictures/Guttormsgaard/testing","testing")+'" />--></div>';
$('body').append(div);
// console.log( key + " name " + val.name + ". " );
// console.log( key + " faces " + val.faces + ". " );
// console.log( key + " eyes " + val.eyes + ". " );
for(var i=0;i<val.faces.length;i++){
faces.push(val.faces[i]);
faces_names.push(val.faces_names[i]);
var subdiv='<div style="position:absolute;left:'+val.faces[i][0]+'px;top:'+val.faces[i][1]+'px;width:'+val.faces[i][2]+'px;height:'+val.faces[i][3]+'px;border:2px solid green;"><img src="testing/crops/'+val.faces_names[i]+'" /></div>';
var tid='#id_'+key;
$(tid).append(subdiv);
for(var j=0;j<val.eyes.length;j++){
eyes.push(val.eyes[j]);
eyes_names.push(val.eyes_names[j]);
var ssubdiv='<div style="position:absolute;left:'+val.eyes[j][0]+'px;top:'+val.eyes[j][1]+'px;width:'+val.eyes[j][2]+'px;height:'+val.eyes[j][3]+'px;border:2px solid magenta;"><img src="testing/crops/'+val.eyes_names[j]+'" /></div>';
$(tid).append(ssubdiv);
}
}
//}else{}
});
});
console.log(eyes);
$.getJSON( "test-spain.json", function( data ) {
$.each( data, function( key, val ) {
console.log(key+" "+val);
if(key=='path'){
var im='<div id="image" style="position:relative;"><img src="'+val.replace("../picts","testing")+'" /></div>';
$('#input').append(im);
}else if(key=='faces'){
for(var i=0;i<val.length;i++){
for(var k=0;k<1;k++){
var facer=Math.floor((Math.random() * (faces.length-1)) + 1);
console.log("Facer "+facer);
if(faces[facer].length>0){
//console.log("facer array");
//console.log(faces[facer]);
var ssubdiv='<div style="position:absolute;left:'+val[i][0]+'px;top:'+val[i][1]+'px;width:'+faces[facer][2]+'px;height:'+faces[facer][3]+'px;"><img style="max-width:120px;max-height:120px;" src="testing/crops/'+faces_names[facer]+'" /></div>';
//$("#image").append(ssubdiv);
}
}
}
}else if(key=='eyes'){
//console.log(val);
for(var i=0;i<val.length;i++){
for(var k=0;k<1;k++){
var eyer=Math.floor((Math.random() * (eyes.length-1)) + 1);
console.log("Eyer "+eyer);
if(eyes[eyer].length>0){
//console.log("eyer array");
//console.log(eyes[eyer]);
var ssubdiv='<div style="position:absolute;left:'+val[i][0]+'px;top:'+val[i][1]+'px;width:'+eyes[eyer][2]+'px;height:'+eyes[eyer][3]+'px;z-index:3000;"><img src="testing/crops/'+eyes_names[eyer]+'" /></div>';
$("#image").append(ssubdiv);
}
}
}
}
});
});
function shuffle(o){
for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
}
});
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">
<title>test positions</title>
<script src="jquery-2.2.0.min.js"></script>
<script src="poc.js"></script>
</head>
<body>
<div style="position:absolute;left:0px;top:10px;width:50%;height:100%;background:white;" id="input"><div class="inputimage">Input image</div></div>
</body> </html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment