Rudimentary face points
This commit is contained in:
parent
6ebb6d7c83
commit
24703953db
2 changed files with 17 additions and 12 deletions
|
@ -150,13 +150,20 @@ class Hit
|
||||||
return $this->points;
|
return $this->points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \EmotionHero\Models\Game $game
|
||||||
|
* @return \EmotionHero\Models\Hit
|
||||||
|
*/
|
||||||
public function setGame(Game $game) {
|
public function setGame(Game $game) {
|
||||||
$this->game = $game;
|
$this->game = $game;
|
||||||
$game->addHit($this);
|
$game->addHit($this);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \EmotionHero\Models\Target $target
|
||||||
|
* @return \EmotionHero\Models\Hit
|
||||||
|
*/
|
||||||
public function setTarget(Target $target) {
|
public function setTarget(Target $target) {
|
||||||
$this->target = $target;
|
$this->target = $target;
|
||||||
$target->addHit($this);
|
$target->addHit($this);
|
||||||
|
@ -1328,8 +1335,6 @@ class Points{
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
$a = $this->getNormalisedPoints();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1350,8 +1355,8 @@ class Points{
|
||||||
public function getNormalisedPoints() {
|
public function getNormalisedPoints() {
|
||||||
$points = $this->getAsArray();
|
$points = $this->getAsArray();
|
||||||
$xs = array_map(function(Point $a){return $a->getX();}, $points);
|
$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);
|
$minx = min($xs);
|
||||||
$maxx = max($xs);
|
$maxx = max($xs);
|
||||||
|
|
||||||
|
@ -1362,15 +1367,15 @@ class Points{
|
||||||
$sizey = $maxy-$miny;
|
$sizey = $maxy-$miny;
|
||||||
|
|
||||||
$scale = max($sizex, $sizey); // divide by largest diff.
|
$scale = max($sizex, $sizey); // divide by largest diff.
|
||||||
|
|
||||||
//used to center the face within the square:
|
//used to center the face within the square:
|
||||||
$diffx = ($scale - $sizex)/2;
|
$diffx = (($scale - $sizex)/(2 * $scale)) * 100;
|
||||||
$diffy = ($scale - $sizey)/2;
|
$diffy = (($scale - $sizey)/(2 * $scale)) * 100;
|
||||||
|
|
||||||
$normalised_points = [];
|
$normalised_points = [];
|
||||||
foreach($points as $i => $point) {
|
foreach($points as $i => $point) {
|
||||||
$x = (($point->getX() - $minx) / $scale) + $diffx;
|
$x = (($point->getX() - $minx) / $scale) * 100 + $diffx;
|
||||||
$y = (($point->getY() - $miny) / $scale) + $diffy;
|
$y = (($point->getY() - $miny) / $scale) * 100 + $diffy;
|
||||||
|
|
||||||
$normalised_points[$i] = new Point($x, $y);
|
$normalised_points[$i] = new Point($x, $y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ echo <<< EOSVG
|
||||||
<svg
|
<svg
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
xmlns="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"
|
id="svg2"
|
||||||
version="1.1">
|
version="1.1">
|
||||||
<g id="layer1">
|
<g id="layer1">
|
||||||
|
|
Loading…
Reference in a new issue