Download .zip |
Info | Example | View files (201) | Download .zip | Reputation | Support forum (1) | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2018-09-25 (2 hours ago) | 80% | Total: 154 | All time: 8,553 This week: 483 |
Version | License | PHP version | Categories | |||
svgmagick 1.0.3 | Custom (specified... | 5 | PHP 5, Graphics, Traits |
Description | Author | ||||||||||||||
This package can compose vectorial graphics in SVG format. |
|
The full SVG implementation on PHP. Currently, the library contains the full SVG specification. SVGMagick also contains a number of useful methods for working with filter, the gradient (e.g. UniformGradient with direction and position) and the transformation of the SVG basic shapes (e.g. polygon, rect, polyline) in the path. SVGMagick does not yet have a stable API, so everything can change at any time.
Hope to read feedbacks and suggestions from community about SVGMagick to make it better.
The suggested installation method is via composer:
$ composer require nstdio/svg: "dev-master"
or add
"nstdio/svg": "dev-master"
to the require
section of your composer.json
file.
Every SVG tag has corresponding class in SVGMagick. What is needed for the creation of SVGMagick object? You have to pass as the first parameter of the constructor is the parent object. So you don't need to explicitly call append
on parent object.
use nstdio\svg\container\Defs;
use nstdio\svg\container\SVG;
use nstdio\svg\gradient\LinearGradient;
// ...
$svg = new SVG();
$defs = new Defs($svg); // <defs> will be appended in <svg>.
$gradient = new LinearGradient($defs) // <linearGradient> will be appended in <defs>
All classes are subject to this rule except for SVG
.
use nstdio\svg\container\SVG;
use nstdio\svg\shape\Rect;
// ...
$svg = new SVG(); // by default width = 640, height = 480.
$rect = new Rect($svg, 120, 300, 3, 3); // creating Rect object and appending <rect> element to <svg>
// You have two way to set <rect> element attributes.
// Use magic methods. Any attribute can be setted using magic setter.
// Note that for setting dash-separated attribute you must use camelCase.
// For setting stroke-linecap you must set strokeLinecap propery of corresponding object.
$rect->rx = 5;
$rect->ry = 5;
$rect->stroke = 'darkgreen';
$rect->fill = 'limegreen';
$rect->strokeWidth = 1.5; // In this particular case strokeWidth will be converted into stroke-width.
// Or use apply method.
$rect->apply(['stroke' => 'darkgreen', 'fill' => 'limegreen', 'stroke-width' => 1.5]);
$rect->setBorderRadius(5); // setting rx and ry at once.
(new Circle($svg, 75, 200, 70))->apply([
'fill' => '#001f3f',
'fillOpacity' => 0.6,
'stroke' => '#FF851B',
'strokeWidth' => 5,
]);
echo $svg; // or $svg->draw() to get svg structure;
Result
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="640" height="480" version="1.1" viewBox="0 0 640 480">
<rect height="120" width="300" x="3" y="3" rx="5" ry="5" stroke="darkgreen" fill="limegreen" stroke-width="1.5"></rect>
<circle cx="75" cy="200" r="70" fill="#001f3f" fill-opacity="0.6" stroke="#FF851B" stroke-width="5"></circle>
</svg>
Files |
File | Role | Description | ||
---|---|---|---|---|
example (18 files) | ||||
src (1 directory) | ||||
tests (1 file, 2 directories) | ||||
.travis.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpunit.xml.dist | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files | / | example |
File | Role | Description |
---|---|---|
blend.php | Example | Example script |
colorMatrix.php | Example | Example script |
componentTransfer.php | Example | Example script |
cubicBezierBox.php | Example | Example script |
diffuseLightingCustom.php | Example | Example script |
filterGaussian.php | Example | Example script |
gradient.php | Example | Example script |
import.php | Aux. | Auxiliary script |
light.php | Example | Example script |
motion.php | Example | Example script |
pathBox.php | Example | Example script |
pattern.php | Example | Example script |
quadraticBezierBox.php | Example | Example script |
set.php | Example | Example script |
shadow.php | Example | Example script |
shapeLighting.php | Example | Example script |
shapes.php | Example | Example script |
transform.php | Example | Example script |
Files | / | src | / | svg |
File | Role | Description | ||
---|---|---|---|---|
animation (6 files) | ||||
attributes (18 files) | ||||
container (11 files) | ||||
desc (4 files) | ||||
filter (24 files) | ||||
font (10 files) | ||||
gradient (6 files) | ||||
import (2 files) | ||||
light (4 files) | ||||
output (8 files) | ||||
shape (11 files) | ||||
text (10 files) | ||||
traits (4 files) | ||||
util (4 files, 1 directory) | ||||
xml (4 files) | ||||
Animatable.php | Class | Class source | ||
Base.php | Class | Class source | ||
ElementFactoryInterface.php | Class | Class source | ||
ElementInterface.php | Class | Class source | ||
ElementStorage.php | Class | Class source | ||
Filterable.php | Class | Class source | ||
GradientInterface.php | Class | Class source | ||
SVGElement.php | Class | Class source | ||
XMLDocumentInterface.php | Class | Class source |
Files | / | src | / | svg | / | animation |
File | Role | Description |
---|---|---|
Animate.php | Class | Class source |
AnimateMotion.php | Class | Class source |
AnimateTransform.php | Class | Class source |
BaseAnimation.php | Class | Class source |
MPath.php | Class | Class source |
Set.php | Class | Class source |
Files | / | src | / | svg | / | attributes |
File | Role | Description |
---|---|---|
Animation.php | Class | Class source |
AnimationAddition.php | Class | Class source |
AnimationEvent.php | Class | Class source |
AnimationTarget.php | Class | Class source |
AnimationTiming.php | Class | Class source |
AnimationValue.php | Class | Class source |
ConditionalProcessing.php | Class | Class source |
Core.php | Class | Class source |
DocumentEvent.php | Class | Class source |
ExternalResourcesRequired.php | Class | Class source |
FilterPrimitive.php | Class | Class source |
FullyAnimatable.php | Class | Class source |
GraphicalEvent.php | Class | Class source |
Presentation.php | Class | Class source |
Styleable.php | Class | Class source |
TransferFunction.php | Class | Class source |
Transformable.php | Class | Class source |
XLink.php | Class | Class source |
Files | / | src | / | svg | / | container |
File | Role | Description |
---|---|---|
A.php | Class | Class source |
Container.php | Class | Class source |
ContainerInterface.php | Class | Class source |
Defs.php | Class | Class source |
G.php | Class | Class source |
Marker.php | Class | Class source |
Mask.php | Class | Class source |
Pattern.php | Class | Class source |
SVG.php | Class | Class source |
Swtch.php | Class | Class source |
Symbol.php | Class | Class source |
Files | / | src | / | svg | / | desc |
File | Role | Description |
---|---|---|
Desc.php | Class | Class source |
Descriptive.php | Class | Class source |
Metadata.php | Class | Class source |
Title.php | Class | Class source |
Files | / | src | / | svg | / | filter |
File | Role | Description |
---|---|---|
BaseFilter.php | Class | Class source |
Blend.php | Class | Class source |
ColorMatrix.php | Class | Class source |
ComponentTransfer.php | Class | Class source |
Composite.php | Class | Class source |
ConvolveMatrix.php | Class | Class source |
DiffuseLighting.php | Class | Class source |
DisplacementMap.php | Class | Class source |
Filter.php | Class | Class source |
Flood.php | Class | Class source |
Func.php | Class | Class source |
FuncA.php | Class | Class source |
FuncB.php | Class | Class source |
FuncG.php | Class | Class source |
FuncR.php | Class | Class source |
GaussianBlur.php | Class | Class source |
Image.php | Class | Class source |
Merge.php | Class | Class source |
MergeNode.php | Class | Class source |
Morphology.php | Class | Class source |
Offset.php | Class | Class source |
SpecularLighting.php | Class | Class source |
Tile.php | Class | Class source |
Turbulence.php | Class | Class source |
Files | / | src | / | svg | / | font |
File | Role | Description |
---|---|---|
BaseFont.php | Class | Class source |
Font.php | Class | Class source |
FontFace.php | Class | Class source |
FontFaceFormat.php | Class | Class source |
FontFaceName.php | Class | Class source |
FontFaceSrc.php | Class | Class source |
FontFaceUri.php | Class | Class source |
HKern.php | Class | Class source |
MissingGlyph.php | Class | Class source |
VKern.php | Class | Class source |
Files | / | src | / | svg | / | gradient |
File | Role | Description |
---|---|---|
Direction.php | Class | Class source |
Gradient.php | Class | Class source |
LinearGradient.php | Class | Class source |
RadialGradient.php | Class | Class source |
Stop.php | Class | Class source |
UniformGradient.php | Class | Class source |
Files | / | src | / | svg | / | import |
File | Role | Description |
---|---|---|
Importer.php | Class | Class source |
ImportInterface.php | Class | Class source |
Files | / | src | / | svg | / | light |
File | Role | Description |
---|---|---|
BaseLight.php | Class | Class source |
DistantLight.php | Class | Class source |
PointLight.php | Class | Class source |
SpotLight.php | Class | Class source |
Files | / | src | / | svg | / | output |
File | Role | Description |
---|---|---|
FileOutput.php | Class | Class source |
FileOutputInterface.php | Class | Class source |
ImageOutput.php | Class | Class source |
ImageOutputInterface.php | Class | Class source |
IOFormat.php | Class | Class source |
Output.php | Class | Class source |
OutputInterface.php | Class | Class source |
SVGOutputInterface.php | Class | Class source |
Files | / | src | / | svg | / | shape |
File | Role | Description |
---|---|---|
Circle.php | Class | Class source |
Ellipse.php | Class | Class source |
Line.php | Class | Class source |
Path.php | Class | Class source |
PathBounds.php | Class | Class source |
Polygon.php | Class | Class source |
Polyline.php | Class | Class source |
Rect.php | Class | Class source |
RoundedShape.php | Class | Class source |
Shape.php | Class | Class source |
ShapeInterface.php | Class | Class source |
Files | / | src | / | svg | / | text |
File | Role | Description |
---|---|---|
AltGlyph.php | Class | Class source |
AltGlyphDef.php | Class | Class source |
AltGlyphItem.php | Class | Class source |
BaseText.php | Class | Class source |
Glyph.php | Class | Class source |
GlyphRef.php | Class | Class source |
Text.php | Class | Class source |
TextPath.php | Class | Class source |
TRef.php | Class | Class source |
TSpan.php | Class | Class source |
Files | / | src | / | svg | / | traits |
File | Role | Description |
---|---|---|
ChildTrait.php | Class | Class source |
ElementTrait.php | Class | Class source |
StyleTrait.php | Class | Class source |
TransformTrait.php | Class | Class source |
Files | / | src | / | svg | / | util |
File | Role | Description | ||
---|---|---|---|---|
transform (6 files) | ||||
Bezier.php | Class | Class source | ||
Identifier.php | Class | Class source | ||
Inflector.php | Class | Class source | ||
KeyValueWriter.php | Class | Class source |
Files | / | src | / | svg | / | util | / | transform |
File | Role | Description |
---|---|---|
Packer.php | Class | Class source |
PackerInterface.php | Class | Class source |
Transform.php | Class | Class source |
TransformInterface.php | Class | Class source |
TransformMatcher.php | Class | Class source |
TransformMatcherInterface.php | Class | Class source |
Files | / | src | / | svg | / | xml |
File | Role | Description |
---|---|---|
DOMElementWrapper.php | Class | Class source |
DOMNode.php | Class | Class source |
DOMWrapper.php | Class | Class source |
NotImplementedException.php | Class | Class source |
Files | / | tests |
File | Role | Description | ||
---|---|---|---|---|
svg (7 files, 9 directories) | ||||
util (3 files, 1 directory) | ||||
bootstrap.php | Aux. | Auxiliary script |
Files | / | tests | / | svg |
File | Role | Description | ||
---|---|---|---|---|
animation (3 files) | ||||
container (1 file) | ||||
desc (1 file) | ||||
filter (3 files) | ||||
gradient (3 files) | ||||
import (1 file) | ||||
light (1 file) | ||||
shape (9 files) | ||||
text (1 file) | ||||
ElementStorageTest.php | Class | Class source | ||
SVGChildTest.php | Class | Class source | ||
SVGContextTestCase.php | Class | Class source | ||
SVGElementCopyTest.php | Class | Class source | ||
SVGFileOutputTest.php | Class | Class source | ||
SVGOutputHeadersTest.php | Class | Class source | ||
SVGTest.php | Class | Class source |
Files | / | tests | / | svg | / | animation |
File | Role | Description |
---|---|---|
AnimateTransformTest.php | Class | Class source |
MPathTest.php | Class | Class source |
SetTest.php | Class | Class source |
Files | / | tests | / | svg | / | filter |
File | Role | Description |
---|---|---|
ColorMatrixTest.php | Class | Class source |
ComponentTransferTest.php | Class | Class source |
FilterTest.php | Class | Class source |
Files | / | tests | / | svg | / | gradient |
File | Role | Description |
---|---|---|
DirectionTest.php | Class | Class source |
GradientTest.php | Class | Class source |
UniformGradientTest.php | Class | Class source |
Files | / | tests | / | svg | / | shape |
File | Role | Description |
---|---|---|
EllipseTest.php | Class | Class source |
LineTest.php | Class | Class source |
PathBoundsTest.php | Class | Class source |
PathTest.php | Class | Class source |
PolygonTest.php | Class | Class source |
PolylineTest.php | Class | Class source |
RectTest.php | Class | Class source |
ShapeFilterTest.php | Class | Class source |
ShapeUniformGradientTest.php | Class | Class source |
Files | / | tests | / | util |
File | Role | Description | ||
---|---|---|---|---|
transform (2 files) | ||||
IdentifierTest.php | Class | Class source | ||
InflectorTest.php | Class | Class source | ||
KeyValueWriterTest.php | Class | Class source |
Files | / | tests | / | util | / | transform |
File | Role | Description |
---|---|---|
TransformCompactTest.php | Class | Class source |
TransformTest.php | Class | Class source |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
User Ratings | User Comments (2) | |||||||||||||||||||||||||||||||||||||
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.