-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2a0ae71
Showing
22 changed files
with
1,841 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# phpstorm project files | ||
.idea | ||
|
||
# netbeans project files | ||
nbproject | ||
|
||
# zend studio for eclipse project files | ||
.buildpath | ||
.project | ||
.settings | ||
|
||
# composer vendor dir | ||
vendor | ||
composer.lock | ||
|
||
# local phpunit config | ||
phpunit.xml | ||
|
||
# log files | ||
tests/logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Jyotish Draw | ||
|
||
Drawing component for Jyotish Library. | ||
|
||
## System Requirements | ||
|
||
Jyotish Draw component requires PHP 5.6 or later and [Jyotish Library](https://github.com/kunjara/jyotish). | ||
|
||
## License | ||
|
||
The files in this library are released under the GNU General Public License version 2 or later. | ||
|
||
## Demo | ||
|
||
To test Jyotish Draw component, a demo website is online: [jyotish.su](http://jyotish.su), or visit social dating service [abboom.com](https://abboom.com) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "kunjara/jyotish-draw", | ||
"description": "Drawing component for Jyotish Library", | ||
"keywords": [ | ||
"jyotish", "vedic astrology", "natal chart" | ||
], | ||
"minimum-stability": "dev", | ||
"type": "library", | ||
"license": "GPL-2.0+", | ||
"authors": [ | ||
{ | ||
"name": "Kunjara Lila das", | ||
"email": "[email protected]", | ||
"homepage": "http://web-art.su" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.6", | ||
"kunjara/jyotish": "1.0.*@dev" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "5.2.*" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Jyotish\\Draw\\": "src" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?php | ||
/** | ||
* @link http://github.com/kunjara/jyotish for the canonical source repository | ||
* @license GNU General Public License version 2 or later | ||
*/ | ||
|
||
namespace Jyotish\Draw; | ||
|
||
/** | ||
* Class for drawing. | ||
* | ||
* @author Kunjara Lila das <[email protected]> | ||
*/ | ||
class Draw | ||
{ | ||
/** | ||
* Image renderer | ||
*/ | ||
const RENDERER_IMAGE = 'image'; | ||
/** | ||
* Svg renderer | ||
*/ | ||
const RENDERER_SVG = 'svg'; | ||
|
||
/** | ||
* Renderer object. | ||
* | ||
* @var Image|Svg | ||
*/ | ||
protected $Renderer = null; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param int $width Width of drawing | ||
* @param int $height Height of drawing | ||
* @param string $renderer Renderer name (optional) | ||
* @throws Exception\UnexpectedValueException | ||
*/ | ||
public function __construct($width, $height, $renderer = self::RENDERER_IMAGE) { | ||
if (!in_array(strtolower($renderer), [self::RENDERER_IMAGE, self::RENDERER_SVG])) { | ||
throw new Exception\UnexpectedValueException( | ||
"Invalid renderer provided must be 'image' or 'svg'." | ||
); | ||
} | ||
|
||
$rendererClass = 'Jyotish\Draw\Renderer\\' . ucfirst($renderer); | ||
$this->Renderer = new $rendererClass($width, $height); | ||
} | ||
|
||
/** | ||
* Set options. | ||
* | ||
* @param array $options Options to set | ||
* @return Draw | ||
*/ | ||
public function setOptions($options) { | ||
$this->Renderer->setOptions($options); | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Draw text. | ||
* | ||
* @param string $text | ||
* @param int $x | ||
* @param int $y | ||
* @param null|array $options Options to set (optional) | ||
*/ | ||
public function drawText($text, $x, $y, array $options = null) { | ||
$this->Renderer->drawText($text, $x, $y, $options); | ||
} | ||
|
||
/** | ||
* Draw polygon. | ||
* | ||
* @param array $points An array containing the polygon's vertices. | ||
* @param null|array $options Options to set (optional) | ||
*/ | ||
public function drawPolygon(array $points, array $options = null) | ||
{ | ||
$this->Renderer->drawPolygon($points, $options); | ||
} | ||
|
||
/** | ||
* Draw chakra. | ||
* | ||
* @param \Jyotish\Base\Data $Data | ||
* @param int $x | ||
* @param int $y | ||
* @param null|array $options Options to set (optional) | ||
*/ | ||
public function drawChakra(\Jyotish\Base\Data $Data, $x, $y, array $options = null) { | ||
$this->setOptions($options); | ||
|
||
$ChakraRenderer = new \Jyotish\Draw\Plot\Chakra\Renderer($this->Renderer); | ||
$ChakraRenderer->drawChakra($Data, $x, $y, $options); | ||
} | ||
|
||
/** | ||
* Render the drawing with correct headers. | ||
* | ||
* @return mixed | ||
*/ | ||
public function render() { | ||
$this->Renderer->render(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* @link http://github.com/kunjara/jyotish for the canonical source repository | ||
* @license GNU General Public License version 2 or later | ||
*/ | ||
|
||
namespace Jyotish\Draw\Exception; | ||
|
||
/** | ||
* Jyotish\Draw Exceptions. | ||
*/ | ||
interface ExceptionInterface | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* @link http://github.com/kunjara/jyotish for the canonical source repository | ||
* @license GNU General Public License version 2 or later | ||
*/ | ||
|
||
namespace Jyotish\Draw\Exception; | ||
|
||
/** | ||
* Jyotish\Draw UnexpectedValueException. | ||
*/ | ||
class UnexpectedValueException extends \UnexpectedValueException implements ExceptionInterface | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* @link http://github.com/kunjara/jyotish for the canonical source repository | ||
* @license GNU General Public License version 2 or later | ||
*/ | ||
|
||
namespace Jyotish\Draw\Plot\Chakra\Exception; | ||
|
||
/** | ||
* Jyotish\Draw\Plot\Chakra Exceptions. | ||
*/ | ||
interface ExceptionInterface | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* @link http://github.com/kunjara/jyotish for the canonical source repository | ||
* @license GNU General Public License version 2 or later | ||
*/ | ||
|
||
namespace Jyotish\Draw\Plot\Chakra\Exception; | ||
|
||
/** | ||
* Jyotish\Draw\Plot\Chakra OutOfRangeException. | ||
*/ | ||
class OutOfRangeException extends \OutOfRangeException implements ExceptionInterface | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* @link http://github.com/kunjara/jyotish for the canonical source repository | ||
* @license GNU General Public License version 2 or later | ||
*/ | ||
|
||
namespace Jyotish\Draw\Plot\Chakra\Exception; | ||
|
||
/** | ||
* Jyotish\Draw\Plot\Chakra RuntimeException. | ||
*/ | ||
class RuntimeException extends \RuntimeException implements ExceptionInterface | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* @link http://github.com/kunjara/jyotish for the canonical source repository | ||
* @license GNU General Public License version 2 or later | ||
*/ | ||
|
||
namespace Jyotish\Draw\Plot\Chakra\Exception; | ||
|
||
/** | ||
* Jyotish\Draw\Plot\Chakra UnexpectedValueException. | ||
*/ | ||
class UnexpectedValueException extends \UnexpectedValueException implements ExceptionInterface | ||
{ | ||
|
||
} |
Oops, something went wrong.