Rudimentary face points

This commit is contained in:
Ruben 2016-09-15 11:53:23 +01:00
parent 6ebb6d7c83
commit 24703953db
2 changed files with 17 additions and 12 deletions

View file

@ -150,13 +150,20 @@ class Hit
return $this->points;
}
/**
* @param \EmotionHero\Models\Game $game
* @return \EmotionHero\Models\Hit
*/
public function setGame(Game $game) {
$this->game = $game;
$game->addHit($this);
return $this;
}
/**
* @param \EmotionHero\Models\Target $target
* @return \EmotionHero\Models\Hit
*/
public function setTarget(Target $target) {
$this->target = $target;
$target->addHit($this);
@ -1328,8 +1335,6 @@ class Points{
}
return $this;
$a = $this->getNormalisedPoints();
}
/**
@ -1350,7 +1355,7 @@ class Points{
public function getNormalisedPoints() {
$points = $this->getAsArray();
$xs = array_map(function(Point $a){return $a->getX();}, $points);
$ys = array_map(function(Point $a){return $a->getX();}, $points);
$ys = array_map(function(Point $a){return $a->getY();}, $points);
$minx = min($xs);
$maxx = max($xs);
@ -1364,13 +1369,13 @@ class Points{
$scale = max($sizex, $sizey); // divide by largest diff.
//used to center the face within the square:
$diffx = ($scale - $sizex)/2;
$diffy = ($scale - $sizey)/2;
$diffx = (($scale - $sizex)/(2 * $scale)) * 100;
$diffy = (($scale - $sizey)/(2 * $scale)) * 100;
$normalised_points = [];
foreach($points as $i => $point) {
$x = (($point->getX() - $minx) / $scale) + $diffx;
$y = (($point->getY() - $miny) / $scale) + $diffy;
$x = (($point->getX() - $minx) / $scale) * 100 + $diffx;
$y = (($point->getY() - $miny) / $scale) * 100 + $diffy;
$normalised_points[$i] = new Point($x, $y);
}

View file

@ -155,7 +155,7 @@ echo <<< EOSVG
<svg
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 100 100"
viewBox="-1 -1 102 102"
id="svg2"
version="1.1">
<g id="layer1">