2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

svg.js: Implement the pathSegList interface (Forum #49085)

git-svn-id: https://svn.fhem.de/fhem/trunk@10792 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2016-02-10 20:20:49 +00:00
parent 6b9b7a43ae
commit f7441ab85b
2 changed files with 18 additions and 2 deletions

View File

@ -1907,7 +1907,7 @@ SVG_render($$$$$$$$$$)
my @tvals = split("[ ,]", $ret);
if (@tvals > 2) {
if ($tvals[0] ne "M") { # just points, no M/L
$ret = sprintf("M %d %d $lt $ret", $tvals[1],$tvals[2]);
$ret = sprintf("M %d,%d $lt $ret", $tvals[1],$tvals[2]);
}
}
@ -2054,7 +2054,7 @@ SVG_getControlPoints($)
my $header = "";
foreach my $i (0..int(@vals)-1) {
$header .= $vals[$i] . " ";
$header .= $vals[$i] . ($i == 1 ? "," : " ");
if ($vals[$i] eq "C" || $vals[$i] eq "Q") {
my $lt = $vals[$i];
$i++;

View File

@ -198,6 +198,22 @@ sv_menu(evt, embed)
$("#content").append(par.div);
var pl = selNode[arrName];
if(!pl) { // chrome 48+ removed the pathSegList interface
function
myPathSegList(node)
{
this.arr = $(node).attr("d").split(/ */);
this.arr.splice(0,1); // remove M
this.arr.splice(1,1); // remove L/Q/etc
this.numberOfItems = this.arr.length;
this.getItem = function(pos)
{
var xy = this.arr[pos].split(",");
return { x:parseFloat(xy[0]), y:parseFloat(xy[1]) };
}
}
selNode[arrName] = pl = new myPathSegList(selNode);
}
if(pl.numberOfItems > 2)
mousemove({pageX:pl.getItem(pl.numberOfItems-2).x});
}