GithubHelp home page GithubHelp logo

sharpvg's Introduction

SharpVG

A .NET Standard library for F# to generate vector graphics in SVG format.

Pull requests and suggestions are greatly appreciated.

Source code on GitHub

Travis CI Build Status Join the chat at https://gitter.im/SharpVG/LobbyNuGet Badge

Build history

Why SharpVG?

  • Allows you to emit SVG using simple F# commands so that you can create graphics and animations that are easy to distribute
  • Ability to render dynamically using Fable to create interactive web pages
  • All basic SVG elements are supported: line, circle, ellipse, rect, text, polygon, polyline, path, image, and groups
  • No understanding of SVG is required and its as easy as using seq, list, or array
  • No external dependencies other than SharpVG are required
  • .NET Standard cross platform support on Windows, Linux, and OSX
  • Limited support for SVG animations
  • Limited support for cartesian plotting
  • Reusable styles

Examples

let position = Point.ofInts (10, 10)
let area = Area.ofInts (50, 50)
let style = Style.create (Color.ofName Colors.Cyan) (Color.ofName Colors.Blue) (Length.ofInt 3) 1.0 1.0

Rect.create position area
  |> Element.createWithStyle style
  |> printf "%O"
<rect stroke="blue" stroke-width="3" fill="cyan" opacity="1" x="10" y="10" height="50" width="50"/>
let center = Point.ofInts (60, 60)
let radius = Length.ofInt 50
let style = Style.create (Color.ofName Colors.Violet) (Color.ofName Colors.Indigo) (Length.ofInt 3) 1.0 1.0

Circle.create center radius
  |> Element.createWithStyle style
  |> Svg.ofElement
  |> Svg.toHtml "Example"
  |> printf "%s"
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
</head>
<body>
<svg><circle stroke="indigo" stroke-width="3" fill="violet" opacity="1" r="50" cx="60" cy="60"/></svg>
</body>
</html>

Building SharpVG

Clone the repository:

git clone https://github.com/ChrisNikkel/SharpVG.git
cd SharpVG/SharpVG

Start the build:

dotnet build

Run the tests:

dotnet test Tests

Run the examples:

dotnet run -p Examples\Triangle\Triangle.fsproj
dotnet run -p Examples\Life\Life.fsproj
dotnet run -p Examples\Graph\Graph.fsproj

Run the Fable example (prerequisites):

cd Examples\Bounce\src
dotnet restore
dotnet fable yarn-run start

Explore interactively:

fsharpi -r:SharpVG/bin/Debug/netcoreapp2.0/SharpVG.dll
open SharpVG;;
Circle.create Point.origin (Length.ofInt 10) |> printf "%O";;
Circle.create Point.origin (Length.ofInt 10) |> Element.create |> Svg.ofElement |> Svg.toHtml "Example";;
#quit;;

Documentation

Read the documentation here.

Support

Please submit bugs and feature requests here.

Library License

The library is available under the MIT license. For more information see the license file.

Maintainer(s)

sharpvg's People

Contributors

chrisnikkel avatar gitter-badger avatar

Watchers

James Cloos avatar Johan von Tangen Sivertsen avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.