All Projects β†’ IconJar β†’ Ijsvg

IconJar / Ijsvg

Licence: mit
MacOS SVG rendering and exporting library

Labels

Projects that are alternatives of or similar to Ijsvg

Svg To Ts
Build performant SVG icon libraries by converting raw SVG files to TypeScript that is optimized for modern tree shaking mechanisms.
Stars: ✭ 131 (-5.76%)
Mutual labels:  svg
Typesettable
πŸ“ A typesetting library for SVG and Canvas
Stars: ✭ 134 (-3.6%)
Mutual labels:  svg
Svg
Useful SVGs
Stars: ✭ 137 (-1.44%)
Mutual labels:  svg
Openjscad.org
JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
Stars: ✭ 1,851 (+1231.65%)
Mutual labels:  svg
React Designer
It's not art
Stars: ✭ 1,762 (+1167.63%)
Mutual labels:  svg
Svg Sprite Loader
Webpack loader for creating SVG sprites.
Stars: ✭ 1,822 (+1210.79%)
Mutual labels:  svg
Svgo
Go Language Library for SVG generation
Stars: ✭ 1,779 (+1179.86%)
Mutual labels:  svg
Circle Flags
A collection of 300+ minimal circular SVG country flags
Stars: ✭ 139 (+0%)
Mutual labels:  svg
React Qr Svg
React component for rendering SVG QR codes
Stars: ✭ 134 (-3.6%)
Mutual labels:  svg
Svgren
πŸ“· SVG rendering library in C++
Stars: ✭ 136 (-2.16%)
Mutual labels:  svg
Convert Svg
Node.js packages for converting SVG into other formats using headless Chromium
Stars: ✭ 133 (-4.32%)
Mutual labels:  svg
Inkscape Isometric Projection
Inkscape extension for converting objects to an isometric projection
Stars: ✭ 133 (-4.32%)
Mutual labels:  svg
React Content Loader
βšͺ SVG-Powered component to easily create skeleton loadings.
Stars: ✭ 11,830 (+8410.79%)
Mutual labels:  svg
Rmdi
React Material Design Icons – built with Pixo, Styled Components, and Styled System
Stars: ✭ 132 (-5.04%)
Mutual labels:  svg
Styled Icons
πŸ’… Popular icon packs like Font Awesome, Material Design, and Octicons, available as React Styled Components
Stars: ✭ 1,878 (+1251.08%)
Mutual labels:  svg
Swiftsvg
A simple, performant, and lightweight SVG parser
Stars: ✭ 1,719 (+1136.69%)
Mutual labels:  svg
Dvisvgm
A fast DVI, EPS, and PDF to SVG converter
Stars: ✭ 134 (-3.6%)
Mutual labels:  svg
Svglib
Read SVG files and convert them to other formats.
Stars: ✭ 139 (+0%)
Mutual labels:  svg
Glyphs
A dynamic design system for managing large icon sets in Figma and using them on the web
Stars: ✭ 140 (+0.72%)
Mutual labels:  svg
Flowchart Vue
flowchartηš„vueη‰ˆζœ¬
Stars: ✭ 136 (-2.16%)
Mutual labels:  svg

IJSVG

IJSVG is a Mac OSX 10.7+ COCOA library for rendering SVG's within your COCOA applications, its extremely fast and native.

Orignaly written for IconJar (in development)

It also supports the NSPasteboards writing protocol, an IJSVG object can be put onto the pasteboard and application like Sketch and Photoshop can paste them into the document as vector objects (generated PDF's on the fly).

Quick Start

Add all the IJSVG library files into your project, import the IJSVG.h into the files you wish to use the SVG's. The easiest way to

Step 1 - initialize the SVG object

IJSVG * svg = [[IJSVG alloc] initWithFilePathURL:someURLHere];
// or with and without extension to find it within the bundle
IJSVG * svg = [IJSVG svgNamed:@"my_svg"]; 

Step 2 - grab the NSImage from it

NSImage * svgImage = [svg imageWithSize:NSMakeSize(100.f,100.f)];

#Other ways of drawing

IJSVG does allow you to directly draw the SVG into any focused drawing context for example within the drawRect of an NSView...

- (void)drawRect
{
  [svg drawInRect:self.bounds];
}

Helpers

IJSVG provides a very simple way of helping out the backing scale factor of the drawing context when the SVG is drawn. Due to CALayers defaulting to 1.0 when custom drawing methods are implemented, they do not know about your backing scale factor. Luckily you can simply do this:

__block IJSVG * svg ....
svg.renderingBackingScaleHelper = ^{
    return [svg computeBackingScale:someView.window.backingScaleFactor];
};

Exporting

Yes, thats right... CALayers -> SVG (whos idea was this?!)

IJSVG provides a way of exporting the rendered layer tree back to an SVG file. This isnt 100% perfect but it does a good job of generating what IJSVG renders (have yet to find an issue).

Its a simple as doing this:

IJSVG * svg ...
IJSVGExporter * exporter = [[IJSVGExporter alloc] initWithSVG:svg options:IJSVGExporterOptionAll];
NSString * svgString = [exporter SVGString];

Which will give you back the SVG code to put into a file, there are various options you can give it for more XML manipulation such s collpasing groups and converting transform's from matrix's back to their human readable counter parts.

The fun part is you can actually create an SVG object from a IJSVGLayer and work with them without needing to load a file, for example:

// create group layer and a shape layer (subclass of CAShapeLayer)
IJSVGGroupLayer * baseSVGGroup = ....
IJSVGShapeLayer * shapeLayer = ....
[baseSVGGroup addSublayer:shapeLayer];

// create the SVG - note the viewbox!
IJSVG * svg = [[IJSVG alloc] initWithSVGLayer:baseSVGGroup viewBox:NSMakeRect(0.f, 0.f, 50.f, 50.f)];
.... do what you want

and now you would have a usuable SVG to render where ever you would like and more importantly you can now export that back to an SVG file.

All layers must be of generic type IJSVGLayer or IJSVGShapeLayer, it will throw an exception if you do not use these. Also if you go out the scope of what those layers can do, it wont render nor will it export (get malformed results).

What it supports

  • Elements: def, use, g, path, clipPath, circle, elipse, rect, polyline, polygon and line (supports groups heirachy and inheritance, clip-paths etc)
  • Commands: A, M, L, H, V, C, S, T, Q and Z and full support for multiple parameters of each type
  • Transformations: matrix, rotate, translate, scale and skew transformations
  • Stroking: stroking, stroke color, stroke opacity, dashed, dashed offset and phase, stroke line cap style
  • Filling: fill color, fill mode (winding rules), fill opacity, linear gradients, radial gradients and patterns
  • Color: supports all predefined colors from the SVG spec and hex values
  • Caching: has basic caching implemenation
  • CSS: Basic embedded style sheets are support with very basic selectors
  • Switches and foreign objects, there is a delegate you can implement to handle foreign objects, once you say you can handle it, its up to you to handle the SVG as IJSVG will stop parsing the document once you have told it you will handle it

Credit

IJSVG is loosely based on UIBezierPath-SVG by ap4y

SVG icons in example found around the net, some from Sketch App Resources all open source and free to use

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].