cvs: pear /Image_Puzzle Puzzle.php /Image_Puzzle/Puzzle Edge.php Piece.php /Image_Puzzle/Puzzle/Edge Arc.php Default.php HalfCircle.php Line.php
Sinus.php

From: Date: Sun, 05 Mar 2006 16:22:29 +0000
Subject: cvs: pear /Image_Puzzle Puzzle.php /Image_Puzzle/Puzzle Edge.php Piece.php /Image_Puzzle/Puzzle/Edge Arc.php Default.php HalfCircle.php Line.php
Sinus.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-38918@lists.php.net to get a copy of this message
fela Sun Mar 5 16:22:29 2006 UTC Modified files: /pear/Image_Puzzle Puzzle.php /pear/Image_Puzzle/Puzzle Edge.php Piece.php /pear/Image_Puzzle/Puzzle/Edge Arc.php Default.php HalfCircle.php Line.php Sinus.php Log: - replaced double to single quoted strings - added necessary spaces after comas and near +/-/* chars

http://cvs.php.net/viewcvs.cgi/pear/Image_Puzzle/Puzzle.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Image_Puzzle/Puzzle.php diff -u pear/Image_Puzzle/Puzzle.php:1.1 pear/Image_Puzzle/Puzzle.php:1.2 --- pear/Image_Puzzle/Puzzle.php:1.1 Sun Mar 5 10:09:54 2006 +++ pear/Image_Puzzle/Puzzle.php Sun Mar 5 16:22:29 2006 @@ -1,6 +1,6 @@ <?php /** - * PHP Puzzle Maker. + * PEAR::Image_Puzzle * * PHP version 5 * @@ -121,7 +121,7 @@ * @return Image_Puzzle a new puzzle object */ public function __construct($options = array()) { - foreach ($options as $key=>$value){ + foreach ($options as $key => $value){ if (in_array($key, array_keys($this->_options))) { $this->_options[$key] = $value; } @@ -136,7 +136,7 @@ */ public function createFromFile($filename) { if (!is_readable($filename)) { - throw new PEAR_Exception("Can't read from $filename."); + throw new PEAR_Exception('Cannot read from ' . $filename); } $size = getimagesize($filename); $this->_sourceWidth = $size[0]; @@ -154,10 +154,10 @@ */ public function getPiece($row, $col) { if ($row < 1 || $row > $this->_options['rows']) { - throw new PEAR_Exception("Illegal row number"); + throw new PEAR_Exception('Illegal row number'); } if ($col < 1 || $col > $this->_options['cols']) { - throw new PEAR_Exception("Illegal col number"); + throw new PEAR_Exception('Illegal col number'); } return $this->_pieces[$row - 1][$col - 1]; } @@ -217,24 +217,24 @@ $edge = Image_Puzzle_Edge::factory('line', $pieceWidth, $pieceHeight); for ($col = 0; $col < $this->_options['cols']; $col++){ $this->_pieces[0][$col]->setTopEdge($edge); - $this->_pieces[$this->_options['rows']-1][$col]->setBottomEdge($edge); + $this->_pieces[$this->_options['rows'] - 1][$col]->setBottomEdge($edge); } $edge = Image_Puzzle_Edge::factory('line', $pieceHeight, $pieceWidth); for ($row = 0; $row < $this->_options['rows']; $row++){ $this->_pieces[$row][0]->setLeftEdge($edge); - $this->_pieces[$row][$this->_options['cols']-1]->setRightEdge($edge); + $this->_pieces[$row][$this->_options['cols'] - 1]->setRightEdge($edge); } - for ($col = 0; $col < $this->_options['cols']-1; $col++){ + for ($col = 0; $col < $this->_options['cols'] - 1; $col++){ for ($row = 0; $row < $this->_options['rows']; $row++){ $edge = Image_Puzzle_Edge::factory($this->_options['edge'], $pieceHeight, $pieceWidth); - $this->_pieces[$row][$col+1]->setLeftEdge($edge); + $this->_pieces[$row][$col + 1]->setLeftEdge($edge); $this->_pieces[$row][$col]->setRightEdge($edge); } } for ($col = 0; $col < $this->_options['cols']; $col++){ - for ($row = 0; $row < $this->_options['rows']-1; $row++){ + for ($row = 0; $row < $this->_options['rows'] - 1; $row++){ $edge = Image_Puzzle_Edge::factory($this->_options['edge'], $pieceWidth, $pieceHeight); - $this->_pieces[$row+1][$col]->setTopEdge($edge); + $this->_pieces[$row + 1][$col]->setTopEdge($edge); $this->_pieces[$row][$col]->setBottomEdge($edge); } } http://cvs.php.net/viewcvs.cgi/pear/Image_Puzzle/Puzzle/Edge.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Image_Puzzle/Puzzle/Edge.php diff -u pear/Image_Puzzle/Puzzle/Edge.php:1.1 pear/Image_Puzzle/Puzzle/Edge.php:1.2 --- pear/Image_Puzzle/Puzzle/Edge.php:1.1 Sun Mar 5 10:09:54 2006 +++ pear/Image_Puzzle/Puzzle/Edge.php Sun Mar 5 16:22:29 2006 @@ -1,6 +1,6 @@ <?php /** - * PHP Puzzle Maker. + * PEAR::Image_Puzzle * * PHP version 5 * @@ -91,21 +91,20 @@ */ static public function factory($edgeName, $longitude, $transversal) { $edgeName = ucfirst($edgeName); - $edgeFile = "Image/Puzzle/Edge/$edgeName.php"; - $edgeClass = "Image_Puzzle_Edge_$edgeName"; + $edgeFile = 'Image/Puzzle/Edge/' . $edgeName . '.php'; + $edgeClass = 'Image_Puzzle_Edge_' . $edgeName; if (!file_exists($edgeFile)) { - throw new PEAR_Exception("Unknown puzzle edge $edgeName"); + throw new PEAR_Exception('Unknown puzzle edge ' . $edgeName); } require_once $edgeFile; if (!class_exists($edgeClass)) { - throw new PEAR_Exception("Edge $edgeName not found in $edgeFile"); + throw new PEAR_Exception('Edge ' . $edgeName . ' not found in ' . $edgeFile); } $edge = new $edgeClass($longitude, $transversal); if (!$edge instanceof Image_Puzzle_Edge) { - throw new PEAR_Exception("Edge $edgeName does not implements edge interface"); + throw new PEAR_Exception('Edge ' . $edgeName . ' does not implements edge interface'); } return $edge; } } - ?> \ No newline at end of file http://cvs.php.net/viewcvs.cgi/pear/Image_Puzzle/Puzzle/Piece.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Image_Puzzle/Puzzle/Piece.php diff -u pear/Image_Puzzle/Puzzle/Piece.php:1.1 pear/Image_Puzzle/Puzzle/Piece.php:1.2 --- pear/Image_Puzzle/Puzzle/Piece.php:1.1 Sun Mar 5 10:09:54 2006 +++ pear/Image_Puzzle/Puzzle/Piece.php Sun Mar 5 16:22:29 2006 @@ -1,6 +1,6 @@ <?php /** - * PHP Puzzle Maker. + * PEAR::Image_Puzzle * * PHP version 5 * http://cvs.php.net/viewcvs.cgi/pear/Image_Puzzle/Puzzle/Edge/Arc.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Image_Puzzle/Puzzle/Edge/Arc.php diff -u pear/Image_Puzzle/Puzzle/Edge/Arc.php:1.1 pear/Image_Puzzle/Puzzle/Edge/Arc.php:1.2 --- pear/Image_Puzzle/Puzzle/Edge/Arc.php:1.1 Sun Mar 5 10:09:54 2006 +++ pear/Image_Puzzle/Puzzle/Edge/Arc.php Sun Mar 5 16:22:29 2006 @@ -1,6 +1,6 @@ <?php /** - * PHP Puzzle Maker. + * PEAR::Image_Puzzle * * PHP version 5 * @@ -38,9 +38,9 @@ public function __construct($longitude, $transversal) { parent::__construct($longitude, $transversal); - $this->_factor = rand(85,95) /100; - $this->_radius = $longitude / 2 / sqrt(1-$this->_factor * $this->_factor); - $this->_side = rand()&1; + $this->_factor = rand(85, 95) / 100; + $this->_radius = $longitude / 2 / sqrt(1 - $this->_factor * $this->_factor); + $this->_side = rand() & 1; } public function getLeftTopMargin() { @@ -55,10 +55,10 @@ $x = $x - $this->longitude / 2; if ($this->_side) { $y = $y - $this->_factor * $this->_radius; - return $x*$x + $y*$y < $this->_radius * $this->_radius; + return $x * $x + $y * $y < $this->_radius * $this->_radius; } else { $y = $y + $this->_factor * $this->_radius; - return $x*$x + $y*$y > $this->_radius * $this->_radius; + return $x * $x + $y * $y > $this->_radius * $this->_radius; } } } http://cvs.php.net/viewcvs.cgi/pear/Image_Puzzle/Puzzle/Edge/Default.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Image_Puzzle/Puzzle/Edge/Default.php diff -u pear/Image_Puzzle/Puzzle/Edge/Default.php:1.1 pear/Image_Puzzle/Puzzle/Edge/Default.php:1.2 --- pear/Image_Puzzle/Puzzle/Edge/Default.php:1.1 Sun Mar 5 10:09:54 2006 +++ pear/Image_Puzzle/Puzzle/Edge/Default.php Sun Mar 5 16:22:29 2006 @@ -1,6 +1,6 @@ <?php /** - * PHP Puzzle Maker. + * PEAR::Image_Puzzle * * PHP version 5 * @@ -38,10 +38,10 @@ public function __construct($longitude, $transversal) { parent::__construct($longitude, $transversal); - $factor = rand(10,12) / 100; + $factor = rand(10, 12) / 100; $this->_longRadius = max($longitude, $transversal) * $factor; $this->_transRadius = min($longitude, $transversal) * $factor; - $this->_side = rand()&1; + $this->_side = rand() & 1; } public function getLeftTopMargin() { @@ -64,7 +64,7 @@ } private function _isInsideCircle($x, $y){ - return $x*$x / $this->_longRadius / $this->_longRadius + $y * $y + return $x * $x / $this->_longRadius / $this->_longRadius + $y * $y / $this->_transRadius / $this->_transRadius < 1; } http://cvs.php.net/viewcvs.cgi/pear/Image_Puzzle/Puzzle/Edge/HalfCircle.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Image_Puzzle/Puzzle/Edge/HalfCircle.php diff -u pear/Image_Puzzle/Puzzle/Edge/HalfCircle.php:1.1 pear/Image_Puzzle/Puzzle/Edge/HalfCircle.php:1.2 --- pear/Image_Puzzle/Puzzle/Edge/HalfCircle.php:1.1 Sun Mar 5 10:09:54 2006 +++ pear/Image_Puzzle/Puzzle/Edge/HalfCircle.php Sun Mar 5 16:22:29 2006 @@ -1,6 +1,6 @@ <?php /** - * PHP Puzzle Maker. + * PEAR::Image_Puzzle * * PHP version 5 * @@ -36,8 +36,8 @@ public function __construct($longitude, $transversal) { parent::__construct($longitude, $transversal); - $this->_radius = min($longitude, $transversal) / rand(40,60) * 10; - $this->_side = rand()&1; + $this->_radius = min($longitude, $transversal) / rand(40, 60) * 10; + $this->_side = rand() & 1; } public function getLeftTopMargin() { @@ -51,9 +51,9 @@ public function isTransparent($x, $y) { $x = $x - $this->longitude / 2; if ($this->_side) { - return $x*$x + $y*$y < $this->_radius * $this->_radius; + return $x * $x + $y * $y < $this->_radius * $this->_radius; } - return $x*$x + $y*$y > $this->_radius * $this->_radius; + return $x * $x + $y * $y > $this->_radius * $this->_radius; } } http://cvs.php.net/viewcvs.cgi/pear/Image_Puzzle/Puzzle/Edge/Line.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Image_Puzzle/Puzzle/Edge/Line.php diff -u pear/Image_Puzzle/Puzzle/Edge/Line.php:1.1 pear/Image_Puzzle/Puzzle/Edge/Line.php:1.2 --- pear/Image_Puzzle/Puzzle/Edge/Line.php:1.1 Sun Mar 5 10:09:54 2006 +++ pear/Image_Puzzle/Puzzle/Edge/Line.php Sun Mar 5 16:22:29 2006 @@ -1,6 +1,6 @@ <?php /** - * PHP Puzzle Maker. + * PEAR::Image_Puzzle * * PHP version 5 * http://cvs.php.net/viewcvs.cgi/pear/Image_Puzzle/Puzzle/Edge/Sinus.php?r1=1.1&r2=1.2&diff_format=u Index: pear/Image_Puzzle/Puzzle/Edge/Sinus.php diff -u pear/Image_Puzzle/Puzzle/Edge/Sinus.php:1.1 pear/Image_Puzzle/Puzzle/Edge/Sinus.php:1.2 --- pear/Image_Puzzle/Puzzle/Edge/Sinus.php:1.1 Sun Mar 5 10:09:54 2006 +++ pear/Image_Puzzle/Puzzle/Edge/Sinus.php Sun Mar 5 16:22:29 2006 @@ -1,6 +1,6 @@ <?php /** - * PHP Puzzle Maker. + * PEAR::Image_Puzzle * * PHP version 5 * @@ -38,8 +38,8 @@ public function __construct($longitude, $transversal) { parent::__construct($longitude, $transversal); - $this->_periods = rand(3,6); - $this->_margin = $transversal * 0.08 * rand(8,12) / 10; + $this->_periods = rand(3, 6); + $this->_margin = $transversal * 0.08 * rand(8, 12) / 10; } public function getLeftTopMargin() {
« previous php.pear.cvs (#38918) next »