本文整理汇总了PHP中TCPDF_STATIC::getSVGTransformMatrix方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF_STATIC::getSVGTransformMatrix方法的具体用法?PHP TCPDF_STATIC::getSVGTransformMatrix怎么用?PHP TCPDF_STATIC::getSVGTransformMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPDF_STATIC
的用法示例。
在下文中一共展示了TCPDF_STATIC::getSVGTransformMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startSVGElementHandler
/**
* Sets the opening SVG element handler function for the XML parser. (*** TO BE COMPLETED ***)
* @param $parser (resource) The first parameter, parser, is a reference to the XML parser calling the handler.
* @param $name (string) The second parameter, name, contains the name of the element for which this handler is called. If case-folding is in effect for this parser, the element name will be in uppercase letters.
* @param $attribs (array) The third parameter, attribs, contains an associative array with the element's attributes (if any). The keys of this array are the attribute names, the values are the attribute values. Attribute names are case-folded on the same criteria as element names. Attribute values are not case-folded. The original order of the attributes can be retrieved by walking through attribs the normal way, using each(). The first key in the array was the first attribute, and so on.
* @param $ctm (array) tranformation matrix for clipping mode (starting transformation matrix).
* @author Nicola Asuni
* @since 5.0.000 (2010-05-02)
* @protected
*/
protected function startSVGElementHandler($parser, $name, $attribs, $ctm = array())
{
// check if we are in clip mode
if ($this->svgclipmode) {
$this->svgclippaths[$this->svgclipid][] = array('name' => $name, 'attribs' => $attribs, 'tm' => $this->svgcliptm[$this->svgclipid]);
return;
}
if ($this->svgdefsmode and !in_array($name, array('clipPath', 'linearGradient', 'radialGradient', 'stop'))) {
if (!isset($attribs['id'])) {
$attribs['id'] = 'DF_' . (count($this->svgdefs) + 1);
}
$this->svgdefs[$attribs['id']] = array('name' => $name, 'attribs' => $attribs);
return;
}
$clipping = false;
if ($parser == 'clip-path') {
// set clipping mode
$clipping = true;
}
// get styling properties
$prev_svgstyle = $this->svgstyles[count($this->svgstyles) - 1];
// previous style
$svgstyle = $this->svgstyles[0];
// set default style
if ($clipping and !isset($attribs['fill']) and (!isset($attribs['style']) or !preg_match('/[;\\"\\s]{1}fill[\\s]*:[\\s]*([^;\\"]*)/si', $attribs['style'], $attrval))) {
// default fill attribute for clipping
$attribs['fill'] = 'none';
}
if (isset($attribs['style']) and !TCPDF_STATIC::empty_string($attribs['style'])) {
// fix style for regular expression
$attribs['style'] = ';' . $attribs['style'];
}
foreach ($prev_svgstyle as $key => $val) {
if (in_array($key, TCPDF_IMAGES::$svginheritprop)) {
// inherit previous value
$svgstyle[$key] = $val;
}
if (isset($attribs[$key]) and !TCPDF_STATIC::empty_string($attribs[$key])) {
// specific attribute settings
if ($attribs[$key] == 'inherit') {
$svgstyle[$key] = $val;
} else {
$svgstyle[$key] = $attribs[$key];
}
} elseif (isset($attribs['style']) and !TCPDF_STATIC::empty_string($attribs['style'])) {
// CSS style syntax
$attrval = array();
if (preg_match('/[;\\"\\s]{1}' . $key . '[\\s]*:[\\s]*([^;\\"]*)/si', $attribs['style'], $attrval) and isset($attrval[1])) {
if ($attrval[1] == 'inherit') {
$svgstyle[$key] = $val;
} else {
$svgstyle[$key] = $attrval[1];
}
}
}
}
// transformation matrix
if (!empty($ctm)) {
$tm = $ctm;
} else {
//$tm = $this->svgstyles[(count($this->svgstyles) - 1)]['transfmatrix'];
$tm = array(1, 0, 0, 1, 0, 0);
}
if (isset($attribs['transform']) and !empty($attribs['transform'])) {
$tm = TCPDF_STATIC::getTransformationMatrixProduct($tm, TCPDF_STATIC::getSVGTransformMatrix($attribs['transform']));
}
$svgstyle['transfmatrix'] = $tm;
$invisible = false;
if ($svgstyle['visibility'] == 'hidden' or $svgstyle['visibility'] == 'collapse' or $svgstyle['display'] == 'none') {
// the current graphics element is invisible (nothing is painted)
$invisible = true;
}
// process tag
switch ($name) {
case 'defs':
$this->svgdefsmode = true;
break;
// clipPath
// clipPath
case 'clipPath':
if ($invisible) {
break;
}
$this->svgclipmode = true;
if (!isset($attribs['id'])) {
$attribs['id'] = 'CP_' . (count($this->svgcliptm) + 1);
}
$this->svgclipid = $attribs['id'];
$this->svgclippaths[$this->svgclipid] = array();
$this->svgcliptm[$this->svgclipid] = $tm;
//.........这里部分代码省略.........
示例2: startSVGElementHandler
/**
* Sets the opening SVG element handler function for the XML parser. (*** TO BE COMPLETED ***)
* @param $parser (resource) The first parameter, parser, is a reference to the XML parser calling the handler.
* @param $name (string) The second parameter, name, contains the name of the element for which this handler is called. If case-folding is in effect for this parser, the element name will be in uppercase letters.
* @param $attribs (array) The third parameter, attribs, contains an associative array with the element's attributes (if any). The keys of this array are the attribute names, the values are the attribute values. Attribute names are case-folded on the same criteria as element names. Attribute values are not case-folded. The original order of the attributes can be retrieved by walking through attribs the normal way, using each(). The first key in the array was the first attribute, and so on.
* @param $ctm (array) tranformation matrix for clipping mode (starting transformation matrix).
* @author Nicola Asuni
* @since 5.0.000 (2010-05-02)
* @protected
*/
protected function startSVGElementHandler($parser, $name, $attribs, $ctm=array()) {
$name = $this->removeTagNamespace($name);
// check if we are in clip mode
if ($this->svgclipmode) {
$this->svgclippaths[$this->svgclipid][] = array('name' => $name, 'attribs' => $attribs, 'tm' => $this->svgcliptm[$this->svgclipid]);
return;
}
if ($this->svgdefsmode AND !in_array($name, array('clipPath', 'linearGradient', 'radialGradient', 'stop'))) {
if (isset($attribs['id'])) {
$attribs['child_elements'] = array();
$this->svgdefs[$attribs['id']] = array('name' => $name, 'attribs' => $attribs);
return;
}
if (end($this->svgdefs) !== FALSE) {
$last_svgdefs_id = key($this->svgdefs);
if (isset($this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'])) {
$attribs['id'] = 'DF_'.(count($this->svgdefs[$last_svgdefs_id]['attribs']['child_elements']) + 1);
$this->svgdefs[$last_svgdefs_id]['attribs']['child_elements'][$attribs['id']] = array('name' => $name, 'attribs' => $attribs);
return;
}
}
return;
}
$clipping = false;
if ($parser == 'clip-path') {
// set clipping mode
$clipping = true;
}
// get styling properties
$prev_svgstyle = $this->svgstyles[max(0,(count($this->svgstyles) - 1))]; // previous style
$svgstyle = $this->svgstyles[0]; // set default style
if ($clipping AND !isset($attribs['fill']) AND (!isset($attribs['style']) OR (!preg_match('/[;\"\s]{1}fill[\s]*:[\s]*([^;\"]*)/si', $attribs['style'], $attrval)))) {
// default fill attribute for clipping
$attribs['fill'] = 'none';
}
if (isset($attribs['style']) AND !TCPDF_STATIC::empty_string($attribs['style']) AND ($attribs['style'][0] != ';')) {
// fix style for regular expression
$attribs['style'] = ';'.$attribs['style'];
}
foreach ($prev_svgstyle as $key => $val) {
if (in_array($key, TCPDF_IMAGES::$svginheritprop)) {
// inherit previous value
$svgstyle[$key] = $val;
}
if (isset($attribs[$key]) AND !TCPDF_STATIC::empty_string($attribs[$key])) {
// specific attribute settings
if ($attribs[$key] == 'inherit') {
$svgstyle[$key] = $val;
} else {
$svgstyle[$key] = $attribs[$key];
}
} elseif (isset($attribs['style']) AND !TCPDF_STATIC::empty_string($attribs['style'])) {
// CSS style syntax
$attrval = array();
if (preg_match('/[;\"\s]{1}'.$key.'[\s]*:[\s]*([^;\"]*)/si', $attribs['style'], $attrval) AND isset($attrval[1])) {
if ($attrval[1] == 'inherit') {
$svgstyle[$key] = $val;
} else {
$svgstyle[$key] = $attrval[1];
}
}
}
}
// transformation matrix
if (!empty($ctm)) {
$tm = $ctm;
} else {
$tm = array(1,0,0,1,0,0);
}
if (isset($attribs['transform']) AND !empty($attribs['transform'])) {
$tm = TCPDF_STATIC::getTransformationMatrixProduct($tm, TCPDF_STATIC::getSVGTransformMatrix($attribs['transform']));
}
$svgstyle['transfmatrix'] = $tm;
$invisible = false;
if (($svgstyle['visibility'] == 'hidden') OR ($svgstyle['visibility'] == 'collapse') OR ($svgstyle['display'] == 'none')) {
// the current graphics element is invisible (nothing is painted)
$invisible = true;
}
// process tag
switch($name) {
case 'defs': {
$this->svgdefsmode = true;
break;
}
// clipPath
case 'clipPath': {
if ($invisible) {
break;
}
$this->svgclipmode = true;
//.........这里部分代码省略.........