Skip to content

Commit c12ef9f

Browse files
committed
draft SVG: fix svg sub style calls
1 parent 35944c0 commit c12ef9f

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/SVG.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,23 +1910,26 @@ protected function parseSVGStyleGradient(
19101910
$gradient = $newgradient;
19111911
}
19121912

1913+
$out = '';
1914+
$out .= $this->graph->getStartTransform();
1915+
19131916
if (!empty($clip_fnc)) {
1914-
$bbox = [];
1917+
$fnout = null;
19151918
if (method_exists($this, $clip_fnc)) {
1916-
$bbox = $this->$clip_fnc(...$clip_par);
1919+
$fnout = $this->$clip_fnc(...$clip_par);
19171920
} elseif (method_exists($this->graph, $clip_fnc)) {
1918-
$bbox = $this->graph->$clip_fnc(...$clip_par);
1921+
$fnout = $this->graph->$clip_fnc(...$clip_par);
19191922
}
1920-
if (
1921-
(!isset($gradient['type'])
1922-
|| ($gradient['type'] != 3))
1923-
&& is_array($bbox)
1924-
&& (count($bbox) == 4)
1923+
if (is_string($fnout)) {
1924+
$out .= $fnout;
1925+
} elseif (
1926+
is_array($fnout) && (count($fnout) == 4)
1927+
&& (!isset($gradient['type']) || ($gradient['type'] != 3))
19251928
) {
1926-
$grx = is_numeric($bbox[0]) ? (float)$bbox[0] : 0.0;
1927-
$gry = is_numeric($bbox[1]) ? (float)$bbox[1] : 0.0;
1928-
$grw = is_numeric($bbox[2]) ? (float)$bbox[2] : 0.0;
1929-
$grh = is_numeric($bbox[3]) ? (float)$bbox[3] : 0.0;
1929+
$grx = is_numeric($fnout[0]) ? (float)$fnout[0] : 0.0;
1930+
$gry = is_numeric($fnout[1]) ? (float)$fnout[1] : 0.0;
1931+
$grw = is_numeric($fnout[2]) ? (float)$fnout[2] : 0.0;
1932+
$grh = is_numeric($fnout[3]) ? (float)$fnout[3] : 0.0;
19301933
}
19311934
}
19321935

@@ -2022,8 +2025,6 @@ protected function parseSVGStyleGradient(
20222025
$gry -= $grh;
20232026
}
20242027

2025-
$out = '';
2026-
20272028
$out .= sprintf(
20282029
'%F 0 0 %F %F %F cm' . "\n",
20292030
$this->toPoints($grw),
@@ -2042,6 +2043,8 @@ protected function parseSVGStyleGradient(
20422043
);
20432044
}
20442045

2046+
$out .= $this->graph->getStopTransform();
2047+
20452048
return $out;
20462049
}
20472050

0 commit comments

Comments
 (0)