src/Image/Svg.php
function svg_overflow($x, $y)
	{
		$x2 = $x;
		$y2 = $y;
		if (isset($this->svg_attribs['overflow'])) {
			if ($this->svg_attribs['overflow'] == 'hidden') {
				// Not sure if this is supposed to strip off units, but since I dont use any I will omlt this step
				$svg_w = preg_replace("/([0-9\.]*)(.*)/i", "$1", $this->svg_attribs['width']);
				$svg_h = preg_replace("/([0-9\.]*)(.*)/i", "$1", $this->svg_attribs['height']);

				// $xmax = floor($this->svg_attribs['width']);
				$xmax = floor($svg_w);
				$xmin = 0;
				// $ymax = floor(($this->svg_attribs['height'] * -1));
				$ymax = floor(($svg_h * -1));
				$ymin = 0;

				if ($x > $xmax) {
					$x2 = $xmax; // right edge
				}
				if ($x < $xmin) {
					$x2 = $xmin; // left edge
				}
				if ($y < $ymax) {
					$y2 = $ymax; // bottom
				}
				if ($y > $ymin) {
					$y2 = $ymin; // top
				}
			}
		}


		return ['x' => $x2, 'y' => $y2];
	}
function svg_overflow($x, $y)
	{
		$x2 = $x;
		$y2 = $y;
		if (isset($this->svg_attribs['overflow'])) {
			if ($this->svg_attribs['overflow'] == 'hidden') {
				// Not sure if this is supposed to strip off units, but since I dont use any I will omlt this step
				$svg_w = preg_replace("/([0-9\.]*)(.*)/i", "$1", $this->svg_attribs['width']);
				$svg_h = preg_replace("/([0-9\.]*)(.*)/i", "$1", $this->svg_attribs['height']);

				// $xmax = floor($this->svg_attribs['width']);
				$xmax = floor($svg_w);
				$xmin = 0;
				// $ymax = floor(($this->svg_attribs['height'] * -1));
				$ymax = floor(($svg_h * -1));
				$ymin = 0;

				if ($x > $xmax) {
					$x2 = $xmax; // right edge
				}
				if ($x < $xmin) {
					$x2 = $xmin; // left edge
				}
				if ($y < $ymax) {
					$y2 = $ymax; // bottom
				}
				if ($y > $ymin) {
					$y2 = $ymin; // top
				}
			}
		}


		return ['x' => $x2, 'y' => $y2];
	}
function svg_overflow ( $ x , $ y ) { $ x2 = $ x ; $ y2 = $ y ; if ( isset ( $ this -> svg_attribs [ 'overflow' ] ) ) { if ( $ this -> svg_attribs [ 'overflow' ] == 'hidden' ) { // Not sure if this is supposed to strip off units, but since I dont use any I will omlt this step $ svg_w = preg_replace ( "/([0-9\.]*)(.*)/i" , "$1" , $ this -> svg_attribs [ 'width' ] ) ; $ svg_h = preg_replace ( "/([0-9\.]*)(.*)/i" , "$1" , $ this -> svg_attribs [ 'height' ] ) ; // $xmax = floor($this->svg_attribs['width']); $ xmax = floor ( $ svg_w ) ; $ xmin = 0 ; // $ymax = floor(($this->svg_attribs['height'] * -1)); $ ymax = floor ( ( $ svg_h * - 1 ) ) ; $ ymin = 0 ; if ( $ x > $ xmax ) { $ x2 = $ xmax ; // right edge } if ( $ x < $ xmin ) { $ x2 = $ xmin ; // left edge } if ( $ y < $ ymax ) { $ y2 = $ ymax ; // bottom } if ( $ y > $ ymin ) { $ y2 = $ ymin ; // top } } } return [ 'x' => $ x2 , 'y' => $ y2 ] ; }
check if points are within svg, if not, set to max
check if points are within svg if not set to max