api.emotionhero.com/www/faces2.php

147 lines
2.7 KiB
PHP
Raw Normal View History

2016-09-19 01:50:50 +02:00
<?php
require __DIR__ . '/../bootstrap.php';
error_reporting(E_ALL);
ini_set('display_errors', true);
$em = \EmotionHero\Application::getInstance()->getEm();
/* @var $hitRepo EmotionHero\Models\HitRepository */
$hitRepo = $em->getRepository(\EmotionHero\Models\Hit::class);
/* @var $currentHit \EmotionHero\Models\Hit */
$currentHit = $hitRepo->findOneBy(['hasImage'=>true], ['id'=>'DESC']);
$printEmoBlocks = function($emotion, $feature, $steps = 6) use($em) {
$hits = $em->getRepository(EmotionHero\Models\Hit::class)->findBy(['hasImage'=>true],["emotions.$emotion" => 'ASC']);
foreach($hits as $hit) {
/* @var $hit EmotionHero\Models\Hit */
$img = $hit->getFeatureImgAsString($feature);
$score = $hit->getEmotions()->getEmotionScore($emotion);
$percentage = sprintf("%.7f %%",$score);
echo <<< EOSNIPPET
<div class="block">
<img src="data:image/x-icon;base64,$img" title="{$hit->getId()}">
<span class="perc">$percentage</span>
</div>
EOSNIPPET;
}
};
?>
<html>
<head>
<title>Emotion Hero</title>
</head>
<style type="text/css">
body{
background:black;
font-family:"Unifont";
font-weight:bold;
color: red;
}
.block{
/*width:14%;*/
background: yellow;
margin-bottom: 8%;
}
img{
width:100%;
filter:sepia(100%);
/*mix-blend-mode: multiply;
mix-blend-mode: exclusion;*/
}
.nose .block{
width:70px;
}
.perc{
display:block;
width:100%;
text-align:center;
background: blue;
color: white;
font-size:67%;
}
.emo-block{
width:14%;
float:left;
margin-right:0.28%;
text-align:center;
}
.emo-block-emos{
position:relative;
}
.emo{
text-align:center;
float:left;
}
.brows{
width:100%;
}
.nose{
width:240px;
}
.current{
/*width:200px;*/
margin:0 auto;
text-align:center;
}
.current img{
width:200px;
}
dd, dt{
float:left;width:80px;
text-align:left;
}
img.curImg{
position:absolute;
left:0;
/*mix-blend-mode:difference;*/
}
svg{
width:300px;
float:left;
}
.emo-name{
position:fixed;
background:#ffff00;
z-index:9999;
}
h3 span{
padding:0.2%;
color:black;
background:yellow;
}
</style>
<body>
<?php
echo "<div class='brows emo'><h3><span>eye brows</span></h3>";
foreach(EmotionHero\Models\Emotions::$EMOTIONS as $emotion) {
echo "<div class='emo-block'><div class='emo-name'>$emotion</div><div class='emo-block-emos'>";
$printEmoBlocks($emotion, 'brows');
echo "<img class='curImg' src=\"data:image/x-icon;base64,{$currentHit->getFeatureImgAsString("brows")}\" title=\"{$currentHit->getId()}\" style=\"top:{$currentHit->getEmotions()->getEmotionScore($emotion)}%\">";
echo "</div></div>";
}
echo"</div>";
?>
</body>
</html>