Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
kunjara committed Mar 7, 2016
0 parents commit 2a0ae71
Show file tree
Hide file tree
Showing 22 changed files with 1,841 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .gitignore
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
15 changes: 15 additions & 0 deletions README.md
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)
29 changes: 29 additions & 0 deletions composer.json
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"
}
}
}
109 changes: 109 additions & 0 deletions src/Draw.php
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();
}
}
15 changes: 15 additions & 0 deletions src/Exception/ExceptionInterface.php
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
{

}
15 changes: 15 additions & 0 deletions src/Exception/UnexpectedValueException.php
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
{

}
15 changes: 15 additions & 0 deletions src/Plot/Chakra/Exception/ExceptionInterface.php
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
{

}
15 changes: 15 additions & 0 deletions src/Plot/Chakra/Exception/OutOfRangeException.php
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
{

}
15 changes: 15 additions & 0 deletions src/Plot/Chakra/Exception/RuntimeException.php
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
{

}
15 changes: 15 additions & 0 deletions src/Plot/Chakra/Exception/UnexpectedValueException.php
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
{

}
Loading

0 comments on commit 2a0ae71

Please sign in to comment.