abstract_renderer.cls.php
来自「国外很不错的一个开源OA系统Group-Office」· PHP 代码 · 共 709 行 · 第 1/2 页
PHP
709 行
} } protected function _border_dashed($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { list($top, $right, $bottom, $left) = $widths; switch ($side) { case "top": $delta = $top / 2; case "bottom": $delta = isset($delta) ? $delta : -$bottom / 2; $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side)); break; case "left": $delta = $left / 2; case "right": $delta = isset($delta) ? $delta : - $right / 2; $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side)); break; default: return; } } protected function _border_solid($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { list($top, $right, $bottom, $left) = $widths; // All this polygon business is for beveled corners... switch ($side) { case "top": if ( $corner_style == "bevel" ) { $points = array($x, $y, $x + $length, $y, $x + $length - $right, $y + $top, $x + $left, $y + $top); $this->_canvas->polygon($points, $color, null, null, true); } else $this->_canvas->filled_rectangle($x, $y, $length, $top, $color); break; case "bottom": if ( $corner_style == "bevel" ) { $points = array($x, $y, $x + $length, $y, $x + $length - $right, $y - $bottom, $x + $left, $y - $bottom); $this->_canvas->polygon($points, $color, null, null, true); } else $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color); break; case "left": if ( $corner_style == "bevel" ) { $points = array($x, $y, $x, $y + $length, $x + $left, $y + $length - $bottom, $x + $left, $y + $top); $this->_canvas->polygon($points, $color, null, null, true); } else $this->_canvas->filled_rectangle($x, $y, $left, $length, $color); break; case "right": if ( $corner_style == "bevel" ) { $points = array($x, $y, $x, $y + $length, $x - $right, $y + $length - $bottom, $x - $right, $y + $top); $this->_canvas->polygon($points, $color, null, null, true); } else $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color); break; default: return; } } protected function _border_double($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { list($top, $right, $bottom, $left) = $widths; $line_width = $$side / 4; // We draw the outermost edge first. Points are ordered: outer left, // outer right, inner right, inner left, or outer top, outer bottom, // inner bottom, inner top. switch ($side) { case "top": if ( $corner_style == "bevel" ) { $left_line_width = $left / 4; $right_line_width = $right / 4; $points = array($x, $y, $x + $length, $y, $x + $length - $right_line_width, $y + $line_width, $x + $left_line_width, $y + $line_width,); $this->_canvas->polygon($points, $color, null, null, true); $points = array($x + $left - $left_line_width, $y + $top - $line_width, $x + $length - $right + $right_line_width, $y + $top - $line_width, $x + $length - $right, $y + $top, $x + $left, $y + $top); $this->_canvas->polygon($points, $color, null, null, true); } else { $this->_canvas->filled_rectangle($x, $y, $length, $line_width, $color); $this->_canvas->filled_rectangle($x, $y + $top - $line_width, $length, $line_width, $color); } break; case "bottom": if ( $corner_style == "bevel" ) { $left_line_width = $left / 4; $right_line_width = $right / 4; $points = array($x, $y, $x + $length, $y, $x + $length - $right_line_width, $y - $line_width, $x + $left_line_width, $y - $line_width); $this->_canvas->polygon($points, $color, null, null, true); $points = array($x + $left - $left_line_width, $y - $bottom + $line_width, $x + $length - $right + $right_line_width, $y - $bottom + $line_width, $x + $length - $right, $y - $bottom, $x + $left, $y - $bottom); $this->_canvas->polygon($points, $color, null, null, true); } else { $this->_canvas->filled_rectangle($x, $y - $line_width, $length, $line_width, $color); $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $line_width, $color); } break; case "left": if ( $corner_style == "bevel" ) { $top_line_width = $top / 4; $bottom_line_width = $bottom / 4; $points = array($x, $y, $x, $y + $length, $x + $line_width, $y + $length - $bottom_line_width, $x + $line_width, $y + $top_line_width); $this->_canvas->polygon($points, $color, null, null, true); $points = array($x + $left - $line_width, $y + $top - $top_line_width, $x + $left - $line_width, $y + $length - $bottom + $bottom_line_width, $x + $left, $y + $length - $bottom, $x + $left, $y + $top); $this->_canvas->polygon($points, $color, null, null, true); } else { $this->_canvas->filled_rectangle($x, $y, $line_width, $length, $color); $this->_canvas->filled_rectangle($x + $left - $line_width, $y, $line_width, $length, $color); } break; case "right": if ( $corner_style == "bevel" ) { $top_line_width = $top / 4; $bottom_line_width = $bottom / 4; $points = array($x, $y, $x, $y + $length, $x - $line_width, $y + $length - $bottom_line_width, $x - $line_width, $y + $top_line_width); $this->_canvas->polygon($points, $color, null, null, true); $points = array($x - $right + $line_width, $y + $top - $top_line_width, $x - $right + $line_width, $y + $length - $bottom + $bottom_line_width, $x - $right, $y + $length - $bottom, $x - $right, $y + $top); $this->_canvas->polygon($points, $color, null, null, true); } else { $this->_canvas->filled_rectangle($x - $line_width, $y, $line_width, $length, $color); $this->_canvas->filled_rectangle($x - $right, $y, $line_width, $length, $color); } break; default: return; } } protected function _border_groove($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { list($top, $right, $bottom, $left) = $widths; $half_widths = array($top / 2, $right / 2, $bottom / 2, $left / 2); $this->_border_inset($x, $y, $length, $color, $half_widths, $side); switch ($side) { case "top": $x += $left / 2; $y += $top / 2; $length -= $left / 2 + $right / 2; break; case "bottom": $x += $left / 2; $y -= $bottom / 2; $length -= $left / 2 + $right / 2; break; case "left": $x += $left / 2; $y += $top / 2; $length -= $top / 2 + $bottom / 2; break; case "right": $x -= $right / 2; $y += $top / 2; $length -= $top / 2 + $bottom / 2; break; default: return; } $this->_border_outset($x, $y, $length, $color, $half_widths, $side); } protected function _border_ridge($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { list($top, $right, $bottom, $left) = $widths; $half_widths = array($top / 2, $right / 2, $bottom / 2, $left / 2); $this->_border_outset($x, $y, $length, $color, $half_widths, $side); switch ($side) { case "top": $x += $left / 2; $y += $top / 2; $length -= $left / 2 + $right / 2; break; case "bottom": $x += $left / 2; $y -= $bottom / 2; $length -= $left / 2 + $right / 2; break; case "left": $x += $left / 2; $y += $top / 2; $length -= $top / 2 + $bottom / 2; break; case "right": $x -= $right / 2; $y += $top / 2; $length -= $top / 2 + $bottom / 2; break; default: return; } $this->_border_inset($x, $y, $length, $color, $half_widths, $side); } protected function _tint($c) { if ( !is_numeric($c) ) return $c; return min(1, $c + 0.66); } protected function _shade($c) { if ( !is_numeric($c) ) return $c; return max(0, $c - 0.66); } protected function _border_inset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { list($top, $right, $bottom, $left) = $widths; switch ($side) { case "top": case "left": $shade = array_map(array($this, "_shade"), $color); $this->_border_solid($x, $y, $length, $shade, $widths, $side); break; case "bottom": case "right": $tint = array_map(array($this, "_tint"), $color); $this->_border_solid($x, $y, $length, $tint, $widths, $side); break; default: return; } } protected function _border_outset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { list($top, $right, $bottom, $left) = $widths; switch ($side) { case "top": case "left": $tint = array_map(array($this, "_tint"), $color); $this->_border_solid($x, $y, $length, $tint, $widths, $side); break; case "bottom": case "right": $shade = array_map(array($this, "_shade"), $color); $this->_border_solid($x, $y, $length, $shade, $widths, $side); break; default: return; } } //........................................................................ }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?