Home
Softono
a

ajstarks

Professional software vendor delivering innovative solutions on the Softono platform. Specialized in both open-source and proprietary software development.

Total Products
2

Software by ajstarks

decksh
Open Source

decksh

# decksh: a little language for presentations, visualizations, and information displays `decksh` is a domain-specific language (DSL) for generating [`deck`](https://github.com/ajstarks/deck) markup. ![object reference](images/placemat.png) `decksh` elements ## Install ``` go get github.com/ajstarks/decksh # install the package go install github.com/ajstarks/decksh/cmd/decksh@latest # install the decksh command ``` The current version is 2026-06-10-1.1.0 ## References and Examples - [`decksh` overview](https://speakerdeck.com/ajstarks/decksh-a-little-language-for-decks) - [`decksh` object reference](https://speakerdeck.com/ajstarks/decksh-object-reference) - [Installing and Running decksh/pdfdeck](https://speakerdeck.com/ajstarks/pdfdeck) - [Repository of decksh projects and visualizations](https://github.com/ajstarks/deckviz "Repository of decksh projects and visualizations") ## Package use The `Process` function reads decksh commands from an `io.Reader` and writes deck markup to an `io.Writer`, returning an error. For example: ``` package main import ( "fmt" "os" "strings" "github.com/ajstarks/decksh" ) func main() { input := ` deck slide ctext "hello, world" 50 50 10 eslide edeck ` err := decksh.Process(os.Stdout, strings.NewReader(input)) if err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) } } ``` Produces: ``` <deck> <slide> <text align="c" xp="50" yp="50" sp="10" >hello, world</text> </slide> </deck> ```` ## Running the command line client This repository also contains `cmd/decksh`, a client decksh command: `decksh` reads from the specified input, and writes deck markup to the specified output destination: ``` $ decksh # input from stdin, output to stdout $ decksh -o foo.xml # input from stdin, output to foo.xml $ decksh foo.sh # input from foo.sh output to stdout $ decksh -o foo.xml foo.sh # input from foo.sh output to foo.xml $ decksh -version # show decksh version $ decksh -dump ... # show decksh variables ``` Typically, `decksh` acts as the head of a rendering pipeline, where another `deck` client renders the markup. This example uses `pdfdeck` ``` $ decksh text.dsh | pdfdeck -stdout -pagesize 1200,900 - > text.pdf ``` ## Example input decksh hello, world: ``` // hello world deck slide "black" "white" ctext "hello world" 50 25 15 circle 0 0 120 "blue" eslide edeck ``` produces: ![hello-world](images/hw-00004.png) This deck script: ``` // Example deck midx=50 midy=50 iw=640 ih=480 imfile="follow.jpg" imlink="https://budnitzbicycles.com" imscale=58 dtop=87 opts="-fulldeck=f -textsize 1 -xlabel=2 -barwidth 1.5" deck slide "white" "black" ctext "Deck elements" midx dtop 5 cimage "follow.jpg" "Dreams" 72 midy iw ih imscale imlink textblock "Budnitz #1, Plainfield, NJ, May 10, 2015" 55 35 10 1 "serif" "white" // List blist 10 75 3 li "text, image, list" li "rect, ellipse, polygon" li "line, arc, curve" elist // Graphics gy=10 c1="red" c2="blue" c3="green" rect 15 gy 8 6 c1 ellipse 27.5 gy 8 6 c2 polygon "37 37 45" "7 13 10" c3 line 50 gy 60 gy 0.25 c1 arc 70 gy 10 8 0 180 0.25 c2 curve 80 gy 95 25 90 gy 0.25 c3 // Chart chleft=10 chright=45 chtop=42 chtbottom=28 dchart -left chleft -right chright -top chtop -bottom chbottom opts AAPL.d eslide edeck ``` Produces: ![exampledeck](images/exampledeck.png) Text, font, color, caption and link arguments follow Go conventions (surrounded by double quotes). ## Coordinate System `decksh` (like the deck markup it produces) uses a traditional Cartesian coordinate system: The origin (0,0) is at the lower left, x increases to the right, and y increases upwards. The coordinate system is expliticly based on the percentages, with x and y ranging from 0-100. For example (50, 50) is the middle of the canvas, (100,100) is the upper right, (100,0) is the lower right, and (0,100) is the upper left. ![percent-canvas](images/pct-canvas.png) ## Rulers Make rulers with an interval (default 5), with optional color ```ruler [increment] [color]``` ![ruler](images/ruler.png) ## Colors Colors formats are: - [RGB](https://en.wikipedia.org/wiki/RGB_color_model "RGB"): "rgb(n,n,n)", where n ranges from 0-255, for example "`"rgb(128,0,128)"` . - hex: "#rrggbb", for example `"#aa00aa"`, - [HSV](https://en.wikipedia.org/wiki/HSL_and_HSV "HSV"): hsv(hue,saturation,value), hue ranges from 0-360, saturation and value range from 0-100, for example `"hsv(360,30,30)"` (pdfdeck and pngdeck support this syntax) - [SVG color names](https://www.w3.org/TR/SVG11/types.html#ColorKeywords "SVG color names"). Color gradients (used for slide backgrounds and rectangle and square fills) are specified as color1/color2/percent, for example, `"blue/white/90"` ## Coordinates, dimensions, scales, opacity and fonts Coordinates, dimensions, scales and opacities are floating point numbers ranging from from 0-100 (representing percentages of the canvas width and percent opacity). Some arguments are optional, and if omitted defaults are applied (black for text, gray for graphics, 100% opacity). Canvas size and image dimensions are in pixels. Fonts may be: - "sans" - "serif" - "mono" - symbol" ![cfo](images/cfo-table.png) ## Begin or end a deck. ``` deck edeck ``` ## Begin, end a slide with optional background and text colors. ``` slide [bgcolor] [fgcolor] eslide ``` Note that doc/edoc and page/epage are may also be used as synomyms for deck/edeck and slide/eslide. ## Specify the size of the canvas. ``` canvas w h ``` ## Simple assignments `id=<number>` defines a constant, which may be then subtitited. For example: ``` x=10 y=20 text "hello, world" x y 5 ``` The special identifier, `deckshVersion` contains the string denoting the version of decksh. ## Assignment operations `id+=<number>` increment the value of `id` by `<number>` ``` x+=5 ``` `id-=<number>` decrement the value of `id` by `<number>` ``` x-=10 ``` `id*=<number>` multiply the value of `id` by `<number>` ``` x*=50 ``` `id*=<number>` divide the value of `id` by `<number>` ``` x/=100 ``` ## Binary operations Addition `id=<id> + number or <id>` ``` tx=10 spacing=1.2 sx=tx-10 vx=tx+spacing ``` Subtraction `id=<id> - number or <id>` ``` a=x-10 ``` Muliplication `id=<id> * number or <id>` ``` a=x*10 ``` Division `id=<id> / number or <id>` ``` a=x/10 ``` Modulo `id=<id> % number or <id>` a=x%10 ## Coordinate assignments Assign (x,y) coordinates to the specified identifier. The x coordinate is `id_x` and the y coordinate is `id_y`. The expression with the parentheses may be a constant, variable or binary expression. This code: ``` a=40 b=40 c=20 p0=(50,50) p1=(a,b) p2=(a+c,b) p3=(a+c,b+c) p4=(a,b+c) circle p0_x p0_x 3 line p1_x p1_y p2_x p2_y 0.2 "blue" line p2_x p2_y p3_x p3_y 0.2 "red" line p3_x p3_y p4_x p4_y 0.2 "green" line p4_x p4_y p1_x p1_y 0.2 "orange" ``` makes this: ![coordinates](images/pcoords.png) ## Polar Coordinates ``` x=polarx cx cy r theta y=polary cx cy r theta ``` Return the polar coordinate given the center at `(cx, cy)`, radius `r`, and angle `theta` (in degrees) ![polar](images/polar.png) ## Polar Coordinates (composite) ``` p=polar cx cy r theta ``` Return the polar coordinates `(p_x)` and `(p_y)` given the center at `(cx, cy)`, radius `r`, and angle `theta` (in degrees) ## Dump The keyword `dump` causes a sorted list of variables and their values to be printed on standard error. For example, given: ``` deck slide x=50 y=50 s=5 message="Hello, decksh" ctext message x y s eslide dump edeck ``` Produces: ``` deckshVersion = "2024-12-15-1.0.0" message = "Hello, decksh" s = 5 x = 50 y = 50 ``` You can also specify that specific variables are shown, `dump x y` shows: ``` x = 50 y = 50 ``` ## Area ``` a=area d c=area a+b ``` return the circular area, `a` for the diameter `d`. ## Formatted Text Assign a string variable with formatted text (using package fmt floating point format strings). Up to five variables may be used. ``` w1=10 w2=20+100 s0=format "Widget 1: %.2f" w1 s1=format "Widget 2: %.3f" w2 st=format "Total Widgets: %v" s1+w2 ``` Large numbers may also be formatted with commas using the `%,` format string. For example: ``` s=format "%," 123456789 // s contains 123,456,789 ``` ## Random Number ``` x=random min max ``` ![random](images/random.png) assign a random number in the specified range ## Math Functions decksh supports these math functions: - cosine - sine - square root - tangent ### Cosine return the coine of the number of expression (`id` or binary operation) ``` a=4 b=10 x=cosine 4 x=cosine a+b x=cosine b ``` ### Sine return the sine of the number of expression (`id` or binary operation) ``` a=4 b=10 x=sine 4 x=sine a+b x=sine b ``` ### Square Root return the square root of the number of expression (`id` or binary operation) ``` a=4 b=10 x=sqrt 4 x=sqrt a+b x=sqrt b ``` ### Tangent return the square root of the number of expression (`id` or binary operation) ``` a=4 b=10 x=tangent 4 x=tangent a+b x=tangent b ``` ## Range Value Mapping ``` x=vmap v vmin vmax min max ``` ![vmap](images/vmap.png) For value `v`, map the range `vmin-vmax` to `min-max`. ## Substring ``` x=substr string begin end ``` assigns a substring given beginning and ending indicies. `-` may be used as a shorthand for the beginning and end. ``` s="hello, world" a=substr s - - // a="hello, world" b=substr s - 4 // b="hello" c=substr s 7 - // c="world" d=substr s 3 8 // d="lo, wo" e=substr "This is a test" 5 8 // e="is a" ``` ## Loops Loop over `statements`, with `x` starting at `begin`, ending at `end` with an optional `increment` (if omitted the increment is 1). Substitution of `x` occurs in statements. ``` for x=begin end [increment] statements efor ``` Loop over `statements`, with `x` ranging over the strings within `[]`. Substitution of `x` will occur in statements. ``` for x=["abc" "def" "ghi"] statements efor ``` Loop over `statements` with `x` ranging over the numbers within `()`. Substitution of `x` will occur in statements. ``` for x=(11 56 89 90 230) statements efor ``` Loop over `statements`, with `x` ranging over the contents `"file"`. Substitution of `x` will occur in statements. ``` for x="file" statements efor ``` ## Conditionals Specify the conditional execution of decksh statements with `if condition`, `else` and `eif`. The else block is optional. The values for ```v1``` and ```v2``` may be either numbers of strings. (For strings only ```==``` and ```!=``` apply). The conditions are: ``` if v1 condition v2 where condition is: == or eq equals if x == y != or ne not equals if x != y < or lt less than if x > y > or gt greater than if x < y >= or ge greater than or equal if x >= y <= or ge less than or equal if x <= y >< or bt between if x >< y z ``` For example: ``` x=10 y=20 if x > y text "x is greater than y" x y 5 else text "x is not greater than y" x y 5 eif ``` The else block may be omitted: ``` if x < 10 text "x is less than 10" x y 5 eif ``` For strings: ``` c1="red" c2="blue" if c1 != c2 text "red is not blue" 50 50 2 eif ``` ## Include decksh markup from a file ``` include "file" ``` places the contents of `"file"` inline. ## Functions Functions have a defined `name` and arguments, and are specifed with statements between the `def` and `edef` keywords ``` def name arg1 arg2 ... argn statements edef ``` ## Importing function defintions Functions may be imported once, and then called by name. For example, given a file `redcircle.dsh`: ``` def redcircle X Y circle X Y 10 "red" edef ``` which is referenced: ``` import "redcircle.dsh" x=50 y=50 x2=x-20 y2=y+20 redcircle x y redcircle x2 y2 ``` makes: ![import](images/import.png) Functions may also be called with the `func` keyword: ``` func "file" arg1 ... argn ``` For example, given a file "ftest.dsh" ``` def ftest funx funy funs funt funs*=2 ctext funt funx funy funs edef ``` calling the function: ``` func "ftest.dsh" 50 30 2.5 "hello" ``` produces: ``` funx=50 funy=30 funs=5.0 funt="hello" ctext "hello" 50 30 5.0 ``` ## Data: Make a file ``` data "foo.d" uno 100 dos 200 tres 300 edata ``` makes a structured data file (name[tab]value) named `foo.d` with the lines between `data` and `edata`. If the optional argument "plain" is added, the file is copied directly (with whitespace trimmed from the beginning). ``` data "foo.txt" "plain" Now is the time for all good men to come to the aid of the party. edata ```` ## Grid: Place objects on a grid ``` grid "file.dsh" x y xskip yskip limit ``` ![grid](images/grid.png) The first file argument (`"file.dsh"` above) specifies a file with decksh commands; each item in the file must include the arguments "x" and "y". Normal variable substitution occurs for other arguments. For example if the contents of `file.dsh` has six items: ``` circle x y 5 circle x y 10 circle x y 15 square x y 5 square x y 10 square x y 15 ``` The line: ``` grid "file.dsh" 10 80 20 30 50 ``` creates two rows: three circles and then three squares `x, y` specify the beginning location of the items, `xskip` is the horizontal spacing between items. `yinternal` is the vertical spacing between items and `limit` the the horizontal limit. When the `limit` is reached, a new row is created. ## Text Left, centered, end, or block-aligned text or file contents (`x` and `y` are the text's reference point), with optional font ("sans", "serif", "mono", or "symbol"), color and opacity. ### left-aligned text ``` text "text" x y size [font] [color] [opacity] [link] btext "text" x y size [font] [color] [opacity] [link] ``` ![text](images/text.png) ### centered text ``` ctext "text" x y size [font] [color] [opacity] [link] ``` ![ctext](images/ctext.png) ### right-aligned text ``` etext "text" x y size [font] [color] [opacity] [link] ``` ![etext](images/etext.png) ### a text block (from either a string or the contents of a file) ``` textblock "text" x y width size [font] [color] [opacity] [link] textblockfile "filename" x y width size [font] [color] [opacity] [link] ``` ![textblock](images/textblock.png) ### paragraphs ``` para x y width size [font] [color] [opacity] [link] .... epara ```` ![para](images/para.png) Text rotated along the specified angle (in degrees) ``` rtext "text" x y angle size [font] [color] [opacity] [link] ``` ### rotated text ![rtext](images/rtext.png) ### text on an arc Text on an arc centered at `(x,y)`, with specified radius, between begin and ending angles (in degrees). if the beginning angle is less than the ending angle the text is rendered counter-clockwise. if the beginning angle is greater than the ending angle, the text is rendered clockwise. ``` arctext "text" x y radius begin-angle end-angle size [font] [color] [opacity] [link] ``` ![arctext](images/arctext.png) ### text from file contents (plain and code formatted) Place the contents of "filename" at (x,y). Place the contents of "filename" in gray box, using a monospaced font. ``` textfile "filename" x y size [font] [color] [opacity] [linespacing] ``` ![textfile](images/textfile.png) ``` textcode "filename" x y width size [color] ``` ![textcocde](images/textcode.png) ## Images Plain and captioned, with optional scales, links and caption size. `(x, y)` is the center of the image, and `width` and `height` are the image dimensions in pixels. ``` image "file" x y width height [scale] [link] cimage "file" "caption" x y width height [scale] [link] [size] ``` ![image](images/image.png) ## Lists (plain, bulleted, numbered, centered). Optional arguments specify the color, opacity, line spacing, link and rotation (degrees) ``` list x y size [font] [color] [opacity] [linespacing] [link] [rotation] ``` ![list](images/list.png) ``` blist x y size [font] [color] [opacity] [linespacing] [link] [rotation] ``` ![blist](images/blist.png) ``` nlist x y size [font] [color] [opacity] [linespacing] [link] [rotation] ``` ![nlist](images/nlist.png) ``` clist x y size [font] [color] [opacity] [linespacing] [link] [rotation] ``` ![clist](images/clist.png) ### list items, and ending the list ``` li "text" elist ``` ## Graphics Rectangles, ellipses, squares, circles: specify the center location `(x, y)` and dimensions `(w,h)` with optional color and opacity. The default color and opacity is gray, 100%. In the case of the `acircle` keyword, the `a` argument is the area, not the diameter. ``` rect x y w h [color] [opacity] ellipse x y w h [color] [opacity] ``` ![rect](images/rect.png) ![ellipse](images/ellipse.png) ``` square x y w [color] [opacity] circle x y w [color] [opacity] ``` ![square](images/square.png) ![circle](images/circle.png) ``` acircle x y a [color] [opacity] ``` ![acircle](images/area.png) Rounded rectangles are similar, with the added radius for the corners: (solid colors only) ``` rrect x y w h r [color] ``` ![rrect](images/rrect.png) For polygons, specify the x and y coordinates as a series of numbers, with optional color and opacity. ``` polygon "xcoords" "ycoords" [color] [opacity] ``` ![polygon](images/polygon.png) Note that the coordinates may be either discrete: ``` polygon "10 20 30" "50 60 50" ``` or use substitution: ``` x1=10 x2=20 x3=30 y1=50 y2=y1+10 y3=y1 polygon "x1 x2 x3" "y1 y2 y3" ``` A combination of constants and substitution is also allowed. ``` polygon "20 x2 30" "50 y2 50" ``` Polyline is similar to polygon, except line segments are used instead of a filled polygon, and you may specify a line width. ``` polyline "xcoords" "ycoords" [lw] [color] [opacity] ``` ![polyline](images/polyline.png) For lines, specify the coordinates for the beginning `(x1,y1)` and end points `(x2, y2)`. For horizontal and vertical lines specify the initial point and the length. Line thickness, color and opacity are optional, with defaults (0.2, gray, 100%). Dotted lines are similar, you must specify the number of dots. ``` line x1 y1 x2 y2 [size] [color] [opacity] ``` ![line](images/line.png) ``` dline x1 y1 x2 y2 [size] [gap] [color] [opacity] ``` ![dline](images/dline.png) ``` hline x y length [size] [color] [opacity] ``` ![hline](images/hline.png) ``` vline x y length [size] [color] [opacity] ``` ![vline](images/vline.png) A "pill" shape has is a horizontal line with rounded ends. ``` pill x w length size [color] ``` ![pill](images/pill.png) Curve is a quadratic Bezier curve: specify the beginning location `(bx, by)`, the control point `(cx, cy)`, and ending location `(ex, ey)`. For arcs, specify the location of the center point `(x,y)`, the width and height, and the beginning and ending angles (in degrees). Line thickness, color and opacity are optional, with defaults (0.2, gray, 100%). ``` curve bx by cx cy ex ey [size] [color] [opacity] ``` ![curve](images/curve.png) ``` arc x y w h a1 a2 [size] [color] [opacity] ``` ![arc](images/arc.png) To make n-sided stars, use the "star" keyword: `(x,y)` is the center of the star, `np` is the number of points, and `inner` and `outer` are the sizes of the inner and outer points, respectively. ``` star x y np inner outer [color] [opacity] ``` ![star](images/star.png) ## Arrows Arrows with optional linewidth, width, height, color, and opacity. Default linewidth is 0.2, default arrow width and height is 3, default color and opacity is gray, 100%. The curve variants use the same syntax for specifying curves. ``` arrow x1 y1 x2 y2 [linewidth] [arrowidth] [arrowheight] [color] [opacity] ``` ![arrow](images/arrow.png) ``` lcarrow bx by cx cy ex ey [linewidth] [arrowidth] [arrowheight] [color] [opacity] ``` ![lcarrow](images/lcarrow.png) ``` rcarrow bx by cx cy ex ey [linewidth] [arrowidth] [arrowheight] [color] [opacity] ``` ![rcarrow](images/rcarrow.png) ``` ucarrow bx by cx cy ex ey [linewidth] [arrowidth] [arrowheight] [color] [opacity] ``` ![ucarrow](images/ucarrow.png) ``` dcarrow bx by cx cy ex ey [linewidth] [arrowidth] [arrowheight] [color] [opacity] ``` ![dcarrow](images/dcarrow.png) ## Braces Left, right, up and down-facing braces. (x, y) is the location of the point of the brace, (aw, ah) are width and height of the braces's end curves; `linewidth`, `color` and `opacity` are optional (defaults are 0.2, gray, 100%) ``` lbrace x y height aw ah [linewidth] [color] [opacity] ``` ![rbrace](images/rbrace.png) ``` rbrace x y height aw ah [linewidth] [color] [opacity] ``` ![lbrace](images/rbrace.png) ``` ubrace x y width aw ah [linewidth] [color] [opacity] ``` ![ubrace](images/ubrace.png) ``` dbrace x y width aw ah [linewidth] [color] [opacity] ``` ![dbrace](images/dbrace.png) ## Brackets Left, right, up and down-facing brackets. (x, y) is the location of the center of the bracket. For left and right-facing brackets, `width` is the size of the top and bottom portions, and `height` is the span of the bracket. For upward and downward-facing brackets, `width` is the span of of bracket, and `height` is the size of the left and right portions. `linewidth`, `color` and `opacity` are optional (defaults are 0.2, gray, 100%) ``` lbracket x y width height [linewidth] [color] [opacity] ``` ![lbracket](images/lbracket.png) ``` rbracket x y width height [linewidth] [color] [opacity] ``` ![rbracket](images/rbracket.png) ``` ubracket x y width height [linewidth] [color] [opacity] ``` ![dbracket](images/dbracket.png) ``` dbracket x y width height [linewidth] [color] [opacity] ``` ![ubracket](images/ubracket.png) ## Charts Run the [dchart](https://github.com/ajstarks/dchart/blob/master/README.md "dchart") command with the specified arguments. ``` dchart [args] ``` For example, ```dchart -bar=t -left=35 -right=65 -top=90 -bottom=65 -yaxis=t``` ![dchart](images/dchart.png) Alternatively, some chart types may be drawn using their own dedicated keywords, optionally specifying chart, label, and value colors: ## Barchart ```barchart "file" [color] [lcolor] [vcolor]``` ![barchart](images/barchart.png) ## Scatter chart ```scatterchart "file" [color] [lcolor] [vcolor]``` ![scatter](images/scatterchart.png) ## Line Chart ```linechart "file" [color] [lcolor] [vcolor]``` ![line](images/linechart.png) ## Area chart ```areachart "file" [color] [lcolor] [vcolor]``` ![area](images/areachart.png) ## Dotchart ```dotchart "file" [color] [lcolor] [vcolor]``` ![dotchart](images/dotchart.png) ## Horizontal bar chart ```hbarchart "file" [color] [lcolor] [vcolor]``` ![hbarchart](images/hbarchart.png) ## "Word" barchart ```wbarchart "file" [color] [lcolor] [vcolor]``` ![wbarchart](images/wbarchart.png) ## Slope chart ```slopechart "file" [color] [lcolor] [vcolor]``` ![slopechart](images/slopechart.png) ## Proportional map ```pmap "file" [size]``` ![pmap](images/pmapchart.png) ## Pie chart ```pie "file" [size]``` ![pie](images/piechart.png) ## Donut chart: ```donut "file" [size] [width]``` ![donutchart](images/donutchart.png) ## Proportional grid ```pgrid "file"``` ![pgridchart](images/pgridchart.png) ## Waffle chart ```waffle "file"``` ![legochart](images/legochart.png) ## Fan chart ```fanchart "file" [size]``` ![fan](images/fanchart.png) ## Bwotie chart ```fanchart "file" [size]``` ![bowtie](images/bowtie.png) When using chart keywords, special variables may be used to control chart attributes: ``` Description variable Default Value Chart top chartTop 80 Chart bottom chartBottom 30 Chart left chartLeft 10 Chart right chartRight 90 Chart text size chartTextSize 1.5 Chart line width chartLineWidth 0.2 Chart bar width chartBarWidth 0 (autoscale) Chart line spacing chartLineSpacing 2.4 Chart Volume opacity chartVolOp 50 X-axis label interval chartXLabel 1 (1: all, 0: none, every nth labelchartYRange Y-axis range chartYRange "" (min,max,interval) CSV Columns chartCSVCols "" Data Format chartDataFmt "%.1f" Show % value chartPercent 0 (0: off, 1: on) Show values chartVal 1 (0: off, 1: on) Show y-axis grid chartGrid 0 (0: off, 1: on) Show title chartTitle 1 (0: off, 1: on) Read CSV chartReadCSV 0 (0: off, 1: on) Show last X-axis label chartXLast 0 (0: off, 1: on) ``` The chart boundaries may be set via ```chartbbox```. ```chartbbox left [right] [top] [bottom]``` For example: ``` chartLeft=50 chartRight=90 chartTop=30 chartBottom=10 chartXLabel=2 linechart "AAPL.d" "red" ``` makes: ![linechart](images/exlinechart.png) ## Legend Show a colored legend ``` legend "text" x y size [font] [color] ``` ![legend](images/legend.png) # Geographic Features ![geo](images/geo.png) Using data from either: * [Shapefiles](https://desktop.arcgis.com/en/arcmap/latest/manage-data/shapefiles/what-is-a-shapefile.htm) * [KML files](https://pro.arcgis.com/en/pro-app/latest/help/data/kml/what-is-kml-.htm) * [geoJSON files](https://datatracker.ietf.org/doc/html/rfc7946) * sets of lat/long pairs geographic features may be rendered. Supported are: * geographic regions, borders and paths * plain and labeled locations * images at geographic locations Appropriate geoJSON, KML and Shapefiles may be obtained from the [opendatasoft site](https://public.opendatasoft.com/explore/dataset/world-administrative-boundaries/export/) The map above is rendered by this code: ``` deck wcolor="lightblue" lcolor="sienna" gcolor="white" geoLatMin=20 geoLatMax=45 geoLongMax=48 geoLongMin=5 slide wcolor gcolor text "The Ancient World" 10 10 5 georegion "world.kml" lcolor geoborder "world.kml" 0.05 wcolor geolabel "countries.d" 3 "serif" gcolor geoloc "cities.d" "c" 1 "sans" gcolor eslide edeck ``` (Note: to ensure proper layout, set the -layers option to "poly:ellipse:text:line" in your deck rendering tool.) The geographic bounding box of the map is defined by latitude (geoLatMin, geoLatMax) and longitude (geoLongMin, geoLongMax) in decimal degrees. Latitudes range from -90° to 90° and longitudes range from -180° to 180°. The Equator is at 0° latitude; latitudes to the north of the Equator are positive, and latitudes south of the Equator are negative. The Prime Meridian is 0° longitude; longitudes to the east of this point are positive, longitudes to the west are negative. Once the ```geoLatMin, geoLatMax, geoLongMin, geoLongMax``` variables are set, geographic functions will use them implicitly. If these special variables are not set, the default values (-90,90,-180,180) are used. ![latlong](images/latlong-scale.png) Further, the canvas boundaries for geographic functions are: ```geoXmin, geoXmax``` for the width and ```geoYmin, geoYmax``` for the height. If these special variables are not set the default values (0,100) are used. For example to show the African continent (bound by 37.347N to 34.8333S and 17.52W to 51.267E) on a specified portion of the canvas (40,70) and (30,70): ``` geoLatMax=37.346983 geoLatMin=0-34.833222 geoLongMax=51.266667 geoLongMin=0-17.520278 geoXmin=40 geoYmax=70 geoYmin=30 geoXmax=70 ``` ![canvas-scale](images/canvas-scale2.png) ## Geographic and Canvas bounding boxes Set the lat/long boundaries for subsequent geographic operations (```geobbox``` is an alternative keyword) ``` geobound latmin [latmax] [longmin] [longmax] ``` bounding boxes may also be specified using geo: URLs: ``` geobound "geo:-34.833222,-17.520278" "geo:37.346983,51.266667" ``` ``` af1="geo:-34.833222,-17.520278" af2="geo:37.346983,51.266667" geobound af1 af2 ``` Set the canvas bounds for geographic operations ``` geocanvas xmin [xmax] [ymin] [ymax] ``` Access the canvas coordinates that correspond to a geographic location with the ```geocoord``` assignment: ``` v=geocoord "geo:40.621255,-74.439466" ``` or ``` v=geocoord 40.621255 -74.439466 ``` The (x,y) coordinates are accessed: ``` circle v_x v_y 1 "red" ``` ## Regions ![regions](images/georegion.png) Reads data from the specified KML, geoJSON or Shapefile and renders the regions. A file with the suffix ".kml" is assumed to be in KML format. Files with suffix ".json" or "geojson" are processed as geoJSON, and a file with the ".shp" suffix is assumed to be a Shapefile. ```color``` and ```op``` specify the color and opacity. ``` georegion "file" [color] [op] ``` ## Borders ![border](images/geoborder.png) Reads data from the specified file and renders the borders. ```lw``` is the line width, ```color``` and ```op``` specify the color and opacity. ``` geoborder "file" [lw] [color] [op] ``` ## Labels ![labels](images/geolabel.png) Reading from the specified file, or a geo coordinate string, place text at a latitude and longitude. The fields in the file are tab-separated latitude, longitide, and label. Labels with embedded "\n" means the text will be stacked. (for example "Atlantic\nOcean"). A file of coordinates looks like this: ``` 26.3351 17.2283 Libya 26.8206 30.8025 Egypt 39.0742 21.8243 Greece 38.9637 35.2433 Turkey 41.8719 12.5674 Italy 32.4279 53.6880 Iran 33.2232 43.6793 Iraq 34.0000 09.0000 Tunisia ``` Coordinate strings may be either a string with tab separated values: ``` "+26.3351 17.2283 Libya" ``` or [geo URI](https://en.wikipedia.org/wiki/Geo_URI_scheme) like this: ``` geo:26.3351,17.2283 ``` ``` geolabel "file.d" [size] [font] [color] [op] geolabel "+41.8719 12.5674 Italy" [size] [font] [color] [op] geolabel "geo:41.8719,12.5674 Italy" [size] [font] [color] [op] ``` ## Locations ![locs](images/geoloc.png) Reading data from the specified file or coordinate string, place text and a dot. The text may be center-above ("c"), center-underneath ("u"), begin ("b"), or end ("e") aligned in relation to the dot. ``` geoloc "location" align [size] [font] [color] [op] ``` Place a marker at the locations specified in the specified file or coordinate string. ![geomark](images/geomark.png) ``` geomark "location" [size] [color] ``` Connect the points found in the specified file with straight lines. ``` geopathfile "file" [size] [color] ``` Connect two points with either straight lines or curves ![geopath](images/geopath.png) ![geoarc](images/geoarc.png) ``` geopath "point1" "point2" [size] [color] [op] geoarc "point1" "point2" [size] [color] [op] ```` ## Images on maps ![geoimage](images/geoimage.png) ``` geoimage "loc" image-width image-height ``` Place image(s) at location(s) The location is specified by lat/long and name of the image. The ```loc``` argument may be either a geo URL and a name, or a list of coordinates and names in a file. For example: ``` geoimage "geo:48.8588897,2.3200410 fra.png" 10 0 ``` places the image in "fra.png" at the coordinates of Paris, France.

Vector Graphics Data Visualisation
88 Github Stars
gensvg
Open Source

gensvg

# gensvg: A Go library for SVG generation # The library generates SVG as defined by the Scalable Vector Graphics 1.1 Specification (<http://www.w3.org/TR/SVG11/>). Output goes to the specified io.Writer. ## Supported SVG elements and functions ## ### Shapes, lines, text circle, ellipse, polygon, polyline, rect (including roundrects), line, text, tspan ### Paths general, arc, cubic and quadratic bezier paths, ### Image and Gradients image, linearGradient, radialGradient, ### Transforms ### translate, rotate, scale, skewX, skewY ### Animation ### animate, animateMotion, animateTranslate, animateRotate, animateScale, animateSkewX, animateSkewY ### Filter Effects filter, feBlend, feColorMatrix, feColorMatrix, feComponentTransfer, feComposite, feConvolveMatrix, feDiffuseLighting, feDisplacementMap, feDistantLight, feFlood, feGaussianBlur, feImage, feMerge, feMorphology, feOffset, fePointLight, feSpecularLighting, feSpotLight,feTile, feTurbulence ### Metadata elements ### desc, defs, g (style, transform, id), marker, mask, pattern, title, (a)ddress, link, script, use ## Building and Usage ## See svgdef.[svg|png|pdf] for a graphical view of the function calls Usage: (assuming GOPATH is set) go get github.com/ajstarks/gensvg a minimal program, to generate SVG to standard output. package main import ( "github.com/ajstarks/gensvg" "os" ) func main() { width := 500 height := 500 canvas := gensvg.New(os.Stdout) canvas.Start(width, height) canvas.Circle(width/2, height/2, 100) canvas.Text(width/2, height/2, "Hello, SVG", "text-anchor:middle;font-size:30px;fill:white") canvas.End() } Drawing in a web server: (http://localhost:2003/circle) package main import ( "log" "github.com/ajstarks/gensvg" "net/http" ) func main() { http.Handle("/circle", http.HandlerFunc(circle)) err := http.ListenAndServe(":2003", nil) if err != nil { log.Fatal("ListenAndServe:", err) } } func circle(w http.ResponseWriter, req *http.Request) { w.Header().Set("Content-Type", "image/svg+xml") s := gensvg.New(w) s.Start(500, 500) s.Circle(250, 250, 125, "fill:none;stroke:black") s.End() } You may view the SVG output with a browser that supports SVG (tested on Chrome, Opera, Firefox and Safari), or any other SVG user-agent such as Batik Squiggle. ### Graphics Sketching with gensvg and svgplay ### Combined with the svgplay command, gensvg can be used to "sketch" with code in a browser. To use svgplay and gensvg, first go to a directory with your code, and run: $ svgplay 2014/06/25 22:05:28 ☠ ☠ ☠ Warning: this server allows a client connecting to 127.0.0.1:1999 to execute code on this computer ☠ ☠ ☠ Next open your browser to the svgplay server you just started. svgplay only listens on localhost, and uses port 1999 (guess which year SVG was first introduced) by default http://localhost:1999/ Enter your code in the textarea, and when you are ready to run press Shift--Enter. The code will be compiled, with the results on the right. To update, change the code and repeat. Note that compilation errors are shown in red under the code. In order for svgplay/gensvg to work, make sure that the io.Writer specified with the New function is os.Stdout. If you want to sketch with an existing file, enter its URL: http://localhost:1999/foo.go ![SVGplay](https://farm4.staticflickr.com/3859/14322978157_31c0114850.jpg) ### Papers and presentations ### * SVGo paper from SVGOpen 2011 <http://www.svgopen.org/2011/papers/34-SVGo_a_Go_Library_for_SVG_generation> * Programming Pictures with SVGo <https://speakerdeck.com/u/ajstarks/p/programming-pictures-with-svgo> * SVGo Workshop <https://speakerdeck.com/u/ajstarks/p/svgo-workshop> ## Package contents ## * *.go: Library * svgdef: Creates a SVG representation of the API * am: Animate motion demo * amt: Animate transformation demo * android: The Android logo * animate: Animation demo * benchviz: visualize benchmarks * bubtrail: Bubble trails * bulletgraph: Bullet Graphs (via Stephen Few) * cascade: animation on curves * codepic: show code and pictures together * colortab: Display SVG named colors with RGB values * compx: Component diagrams * cube: random cubes * f50: Get 50 photos from Flickr based on a query * fe: Filter effects * flower: Random "flowers" * fontcompare: Compare two fonts * funnel: Funnel from transparent circles * gradient: Linear and radial gradients * html5logo: HTML5 logo with draggable elements * imfade: Show image fading * lewitt: Version of Sol Lewitt's Wall Drawing 91 * ltr: Layer Tennis Remixes * marker: Test markers * paths: Demonstrate SVG paths * pattern: Test patterns * planets: Show the scale of the Solar system * pmap: Proportion maps * randcomp: Compare random number generators * richter: Gerhard Richter's 256 colors * rl: Random lines (port of a Processing demo) * rpd: read/parse/draw * rr: radial graphs * skewabc: Skew ABC * span: Text span * stockproduct: Visualize product and stock prices * svgdef: gensvg placemat * svgopher: gensvg Mascot * svgplay: gensvg sketching server * svgplot: Plot data * svgrid: Compose SVG files in a grid * tsg: Twitter Search Grid * tumblrgrid: Tumblr picture grid * turbulence: Turbulence filter effect * vismem: Visualize data from files * webfonts: "Hello, World" with Google Web Fonts * websvg: Generate SVG as a web server ## Functions and types ## Many functions use x, y to specify an object's location, and w, h to specify the object's width and height. Where applicable, a final optional argument specifies the style to be applied to the object. The style strings follow the SVG standard; name:value pairs delimited by semicolons, or a series of name="value" pairs. For example: `"fill:none; opacity:0.3"` or `fill="none" opacity="0.3"` (see: <http://www.w3.org/TR/SVG11/styling.html>) The SVG type: type SVG struct { Writer io.Writer } Most operations are methods on this type, specifying the destination io.Writer. The Offcolor type: type Offcolor struct { Offset uint8 Color string Opacity float64 } is used to specify the offset, color, and opacity of stop colors in linear and radial gradients The Filterspec type: type Filterspec struct { In string In2 string Result string } is used to specify inputs and results for filter effects ### Structure, Scripting, Metadata, Transformation and Links ### New(w io.Writer) *SVG Constructor, Specify the output destination. Start(w int, h int, attributes ...string) begin the SVG document with the width w and height h. Optionally add additional elements (such as additional namespaces or scripting events) <http://www.w3.org/TR/SVG11/struct.html#SVGElement> Startview(w, h, minx, miny, vw, vh int) begin the SVG document with the width w, height h, with a viewBox at minx, miny, vw, vh. <http://www.w3.org/TR/SVG11/struct.html#SVGElement> Startunit(w int, h int, unit string, ns ...string) begin the SVG document, with width and height in the specified units. Optionally add additional elements (such as additional namespaces or scripting events) <http://www.w3.org/TR/SVG11/struct.html#SVGElement> Startpercent(w int, h int, ns ...string) begin the SVG document, with width and height in percent. Optionally add additional elements (such as additional namespaces or scripting events) <http://www.w3.org/TR/SVG11/struct.html#SVGElement> StartviewUnit(w, h int, unit string, minx, miny, vw, vh int) begin the SVG document with the width w, height h, in the specified unit, with a viewBox at minx, miny, vw, vh. <http://www.w3.org/TR/SVG11/struct.html#SVGElement> End() end the SVG document Script(scriptype string, data ...string) Script defines a script with a specified type, (for example "application/javascript"). if the first variadic argument is a link, use only the link reference. Otherwise, treat variadic arguments as the text of the script (marked up as CDATA). if no data is specified, simply close the script element. <http://www.w3.org/TR/SVG/script.html> Style(scriptype string, data ...string) Style defines a script with a specified type, (for example "text/css"). if the first variadic argument is a link, use only the link reference. Otherwise, treat variadic arguments as the text of the script (marked up as CDATA). if no data is specified, simply close the style element. <https://www.w3.org/TR/SVG/styling.html#StyleElement> Group(s ...string) begin a group, with arbitrary attributes <http://www.w3.org/TR/SVG11/struct.html#GElement> Gstyle(s string) begin a group, with the specified style. <http://www.w3.org/TR/SVG11/struct.html#GElement> Gid(s string) begin a group, with the specified id. Gtransform(s string) begin a group, with the specified transform, end with Gend(). <http://www.w3.org/TR/SVG11/coords.html#TransformAttribute> Translate(x, y int) begins coordinate translation to (x,y), end with Gend(). <http://www.w3.org/TR/SVG11/coords.html#TransformAttribute> Scale(n float64) scales the coordinate system by n, end with Gend(). <http://www.w3.org/TR/SVG11/coords.html#TransformAttribute> ScaleXY(x, y float64) scales the coordinate system by x, y. End with Gend(). <http://www.w3.org/TR/SVG11/coords.html#TransformAttribute> SkewX(a float64) SkewX skews the x coordinate system by angle a, end with Gend(). <http://www.w3.org/TR/SVG11/coords.html#TransformAttribute> SkewY(a float64) SkewY skews the y coordinate system by angle a, end with Gend(). <http://www.w3.org/TR/SVG11/coords.html#TransformAttribute> SkewXY(ax, ay float64) SkewXY skews x and y coordinate systems by ax, ay respectively, end with Gend(). <http://www.w3.org/TR/SVG11/coords.html#TransformAttribute> Rotate(r float64) rotates the coordinate system by r degrees, end with Gend(). <http://www.w3.org/TR/SVG11/coords.html#TransformAttribute> TranslateRotate(x, y int, r float64) translates the coordinate system to (x,y), then rotates to r degrees, end with Gend(). RotateTranslate(x, y int, r float64) rotates the coordinate system r degrees, then translates to (x,y), end with Gend(). Gend() end the group (must be paired with Gstyle, Gtransform, Gid). ClipPath(s ...string) Begin a ClipPath <http://www.w3.org/TR/SVG/masking.html#ClippingPaths> ClipEnd() End a ClipPath <http://www.w3.org/TR/SVG/masking.html#ClippingPaths> Def() begin a definition block. <http://www.w3.org/TR/SVG11/struct.html#DefsElement> DefEnd() end a definition block. Marker(id string, x, y, w, h int, s ...string) define a marker <http://www.w3.org/TR/SVG11/painting.html#MarkerElement> MarkerEnd() end a marker Mask(id string, x int, y int, w int, h int, s ...string) creates a mask with a specified id, dimension, and optional style. <http://www.w3.org/TR/SVG/masking.html> MaskEnd() ends the Mask element. Pattern(id string, x, y, width, height int, putype string, s ...string) define a Pattern with the specified dimensions, the putype can be either "user" or "obj", which sets the patternUnits attribute to be either userSpaceOnUse or objectBoundingBox. <http://www.w3.org/TR/SVG11/pservers.html#Patterns> Desc(s string) specify the text of the description. <http://www.w3.org/TR/SVG11/struct.html#DescElement> Title(s string) specify the text of the title. <http://www.w3.org/TR/SVG11/struct.html#TitleElement> Link(href string, title string) begin a link named "href", with the specified title. <http://www.w3.org/TR/SVG11/linking.html#Links> LinkEnd() end the link. Use(x int, y int, link string, s ...string) place the object referenced at link at the location x, y. <http://www.w3.org/TR/SVG11/struct.html#UseElement> ### Shapes ### Circle(x int, y int, r int, s ...string) draw a circle, centered at x,y with radius r. <http://www.w3.org/TR/SVG11/shapes.html#CircleElement> ![Circle](http://farm5.static.flickr.com/4144/5187953823_01a1741489_m.jpg) Ellipse(x int, y int, w int, h int, s ...string) draw an ellipse, centered at x,y with radii w, and h. <http://www.w3.org/TR/SVG11/shapes.html#EllipseElement> ![Ellipse](http://farm2.static.flickr.com/1271/5187953773_a9d1fc406c_m.jpg) Polygon(x []int, y []int, s ...string) draw a series of line segments using an array of x, y coordinates. <http://www.w3.org/TR/SVG11/shapes.html#PolygonElement> ![Polygon](http://farm2.static.flickr.com/1006/5187953873_337dc26597_m.jpg) Rect(x int, y int, w int, h int, s ...string) draw a rectangle with upper left-hand corner at x,y, with width w, and height h. <http://www.w3.org/TR/SVG11/shapes.html#RectElement> ![Rect](http://farm2.static.flickr.com/1233/5188556032_86c90e354b_m.jpg) CenterRect(x int, y int, w int, h int, s ...string) draw a rectangle with its center at x,y, with width w, and height h. Roundrect(x int, y int, w int, h int, rx int, ry int, s ...string) draw a rounded rectangle with upper the left-hand corner at x,y, with width w, and height h. The radii for the rounded portion is specified by rx (width), and ry (height). ![Roundrect](http://farm2.static.flickr.com/1275/5188556120_e2a9998fee_m.jpg) Square(x int, y int, s int, style ...string) draw a square with upper left corner at x,y with sides of length s. ![Square](http://farm5.static.flickr.com/4110/5187953659_54dcce242e_m.jpg) ### Paths ### Path(p string, s ...style) draw the arbitrary path as specified in p, according to the style specified in s. <http://www.w3.org/TR/SVG11/paths.html> Arc(sx int, sy int, ax int, ay int, r int, large bool, sweep bool, ex int, ey int, s ...string) draw an elliptical arc beginning coordinate at sx,sy, ending coordinate at ex, ey width and height of the arc are specified by ax, ay, the x axis rotation is r if sweep is true, then the arc will be drawn in a "positive-angle" direction (clockwise), if false, the arc is drawn counterclockwise. if large is true, the arc sweep angle is greater than or equal to 180 degrees, otherwise the arc sweep is less than 180 degrees. <http://www.w3.org/TR/SVG11/paths.html#PathDataEllipticalArcCommands> ![Arc](http://farm2.static.flickr.com/1300/5188556148_df1a176074_m.jpg) Bezier(sx int, sy int, cx int, cy int, px int, py int, ex int, ey int, s ...string) draw a cubic bezier curve, beginning at sx,sy, ending at ex,ey with control points at cx,cy and px,py. <http://www.w3.org/TR/SVG11/paths.html#PathDataCubicBezierCommands> ![Bezier](http://farm2.static.flickr.com/1233/5188556246_a03e67d013.jpg) Qbezier(sx int, sy int, cx int, cy int, ex int, ey int, tx int, ty int, s ...string) draw a quadratic bezier curve, beginning at sx, sy, ending at tx,ty with control points are at cx,cy, ex,ey. <http://www.w3.org/TR/SVG11/paths.html#PathDataQuadraticBezierCommands> ![Qbezier](http://farm2.static.flickr.com/1018/5187953917_9a43cf64fb.jpg) Qbez(sx int, sy int, cx int, cy int, ex int, ey int, s...string) draws a quadratic bezier curver, with optional style beginning at sx,sy, ending at ex, sy with the control point at cx, cy. <http://www.w3.org/TR/SVG11/paths.html#PathDataQuadraticBezierCommands> ![Qbez](http://farm6.static.flickr.com/5176/5569879349_5f726aab5e.jpg) ### Lines ### Line(x1 int, y1 int, x2 int, y2 int, s ...string) draw a line segment between x1,y1 and x2,y2. <http://www.w3.org/TR/SVG11/shapes.html#LineElement> ![Line](http://farm5.static.flickr.com/4154/5188556080_0be19da0bc.jpg) Polyline(x []int, y []int, s ...string) draw a polygon using coordinates specified in x,y arrays. <http://www.w3.org/TR/SVG11/shapes.html#PolylineElement> ![Polyline](http://farm2.static.flickr.com/1266/5188556384_a863273a69.jpg) ### Image and Text ### Image(x int, y int, w int, h int, link string, s ...string) place at x,y (upper left hand corner), the image with width w, and height h, referenced at link. <http://www.w3.org/TR/SVG11/struct.html#ImageElement> ![Image](http://farm5.static.flickr.com/4058/5188556346_e5ce3dcbc2_m.jpg) Text(x int, y int, t string, s ...string) Place the specified text, t at x,y according to the optional style specified in s. <http://www.w3.org/TR/SVG11/text.html#TextElement> Textspan(x int, y int, t string, s ...string) Place specified text, t at x,y according to the optional style specified in s. <https://www.w3.org/TR/SVG11/text.html#TSpanElement> Use this method with Span(...). End with TextEnd() Span(t string, s ...string) Create a text span t, using optional style s TextEnd() End a text span Textlines(x, y int, s []string, size, spacing int, fill, align string) Places lines of text in s, starting at x,y, at the specified size, fill, and alignment, and spacing. Textpath(t string, pathid string, s ...string) places optionally styled text along a previously defined path. <http://www.w3.org/TR/SVG11/text.html#TextPathElement> ![Image](http://farm4.static.flickr.com/3149/5694580737_4b291df768_m.jpg) ### Color ### RGB(r int, g int, b int) string creates a style string for the fill color designated by the (r)ed, g(reen), (b)lue components. <http://www.w3.org/TR/css3-color/> RGBA(r int, g int, b int, a float64) string as above, but includes the color's opacity as a value between 0.0 (fully transparent) and 1.0 (opaque). ### Gradients ### LinearGradient(id string, x1, y1, x2, y2 uint8, sc []Offcolor) constructs a linear color gradient identified by id, along the vector defined by (x1,y1), and (x2,y2). The stop color sequence defined in sc. Coordinates are expressed as percentages. <http://www.w3.org/TR/SVG11/pservers.html#LinearGradients> ![LinearGradient](http://farm5.static.flickr.com/4153/5187954033_3972f63fa9.jpg) RadialGradient(id string, cx, cy, r, fx, fy uint8, sc []Offcolor) constructs a radial color gradient identified by id, centered at (cx,cy), with a radius of r. (fx, fy) define the location of the focal point of the light source. The stop color sequence defined in sc. Coordinates are expressed as percentages. <http://www.w3.org/TR/SVG11/pservers.html#RadialGradients> ![RadialGradient](http://farm2.static.flickr.com/1302/5187954065_7ddba7b819.jpg) ### Animation ### Animate(link, attr string, from, to int, duration float64, repeat int, s ...string) Animate animates the item referenced by the link, using the specified attribute The animation starts at coordinate from, terminates at to, and repeats as specified. Addtional attributes may be added as needed. <https://www.w3.org/TR/SVG11/animate.html#AnimateElement> AnimateMotion(link, path string, duration float64, repeat int, s ...string) AnimateMotion animates the referenced object ```link``` along the specified ```path``` <https://www.w3.org/TR/SVG11/animate.html#AnimateMotionElement> AnimateTranslate(link string, fx, fy, tx, ty int, duration float64, repeat int, s ...string) AnimateTranslate animates the translation transformation (link refers to the object to animate, fx, fy are from coordinates, tx, ty are the to coordinates) <https://www.w3.org/TR/SVG11/animate.html#AnimateTransformElement> AnimateRotate(link string, fs, fc, fe, ts, tc, te int, duration float64, repeat int, s ...string) AnimateRotate animates the rotation transformation (link refers to the object to animate, f[s,c,e] are the from start, center, and end angles, t[s,c,e] are the start, center, and end angles) <https://www.w3.org/TR/SVG11/animate.html#AnimateTransformElement> AnimateScale(link string, from, to, duration float64, repeat int, s ...string) AnimateScale animates the scale transformation (link refers to the object to animate, from and to specify the scaling factor) <https://www.w3.org/TR/SVG11/animate.html#AnimateTransformElement> AnimateSkewX(link string, from, to, duration float64, repeat int, s ...string) AnimateSkewX animates the skewX transformation ((link refers to the object to animate, from and to specify the skew angle) <https://www.w3.org/TR/SVG11/animate.html#AnimateTransformElement> AnimateSkewY(link string, from, to, duration float64, repeat int, s ...string) AnimateSkewY animates the skewY transformation (link refers to the object to animate, and from and to specify the skew angle) <https://www.w3.org/TR/SVG11/animate.html#AnimateTransformElement> ### Filter Effects ### Filter(id string, s ...string) Filter begins a filter set Standard reference: <http://www.w3.org/TR/SVG11/filters.html#FilterElement> Fend() Fend ends a filter set Standard reference: <http://www.w3.org/TR/SVG11/filters.html#FilterElement> FeBlend(fs Filterspec, mode string, s ...string) FeBlend specifies a Blend filter primitive Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feBlendElement> FeColorMatrix(fs Filterspec, values [20]float64, s ...string) FeColorMatrix specifies a color matrix filter primitive, with matrix values Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feColorMatrixElement> FeColorMatrixHue(fs Filterspec, value float64, s ...string) FeColorMatrix specifies a color matrix filter primitive, with hue values Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feColorMatrixElement> FeColorMatrixSaturate(fs Filterspec, value float64, s ...string) FeColorMatrix specifies a color matrix filter primitive, with saturation values Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feColorMatrixElement> FeColorMatrixLuminence(fs Filterspec, s ...string) FeColorMatrix specifies a color matrix filter primitive, with luminence values Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feColorMatrixElement> FeComponentTransfer() FeComponentTransfer begins a feComponent filter Element> Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement> FeCompEnd() FeCompEnd ends a feComponent filter Element> FeComposite(fs Filterspec, operator string, k1, k2, k3, k4 int, s ...string) FeComposite specifies a feComposite filter primitive Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feCompositeElement> FeConvolveMatrix(fs Filterspec, matrix [9]int, s ...string) FeConvolveMatrix specifies a feConvolveMatrix filter primitive Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feConvolveMatrixElement> FeDiffuseLighting(fs Filterspec, scale, constant float64, s ...string) FeDiffuseLighting specifies a diffuse lighting filter primitive, a container for light source Element>s, end with DiffuseEnd() FeDiffEnd() FeDiffuseEnd ends a diffuse lighting filter primitive container Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feDiffuseLightingElement> FeDisplacementMap(fs Filterspec, scale float64, xchannel, ychannel string, s ...string) FeDisplacementMap specifies a feDisplacementMap filter primitive Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feDisplacementMapElement> FeDistantLight(fs Filterspec, azimuth, elevation float64, s ...string) FeDistantLight specifies a feDistantLight filter primitive Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feDistantLightElement> FeFlood(fs Filterspec, color string, opacity float64, s ...string) FeFlood specifies a flood filter primitive Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feFloodElement> FeFuncLinear(channel string, slope, intercept float64) FeFuncLinear is the linear form of feFunc Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement> FeFuncGamma(channel, amplitude, exponent, offset float64) FeFuncGamma is the gamma curve form of feFunc Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement> FeFuncTable(channel string, tv []float64) FeFuncGamma is the form of feFunc using a table of values Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement> FeFuncDiscrete(channel string, tv []float64) FeFuncGamma is the form of feFunc using discrete values Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement> FeGaussianBlur(fs Filterspec, stdx, stdy float64, s ...string) FeGaussianBlur specifies a Gaussian Blur filter primitive Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feGaussianBlurElement> FeImage(href string, result string, s ...string) FeImage specifies a feImage filter primitive Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feImageElement> FeMerge(nodes []string, s ...string) FeMerge specifies a feMerge filter primitive, containing feMerge Element>s Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feMergeElement> FeMorphology(fs Filterspec, operator string, xradius, yradius float64, s ...string) FeMorphologyLight specifies a feMorphologyLight filter primitive Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feMorphologyElement> FeOffset(fs Filterspec, dx, dy int, s ...string) FeOffset specifies the feOffset filter primitive Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feOffsetElement> FePointLight(x, y, z float64, s ...string) FePointLight specifies a fePpointLight filter primitive Standard reference: <http://www.w3.org/TR/SVG11/filters.html#fePointLightElement> FeSpecularLighting(fs Filterspec, scale, constant float64, exponent int, color string, s ...string) FeSpecularLighting specifies a specular lighting filter primitive, a container for light source elements, end with SpecularEnd() FeSpecEnd() FeSpecularEnd ends a specular lighting filter primitive container Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feSpecularLightingElement> FeSpotLight(fs Filterspec, x, y, z, px, py, pz float64, s ...string) FeSpotLight specifies a feSpotLight filter primitive Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feSpotLightElement> FeTile(fs Filterspec, in string, s ...string) FeTile specifies the tile utility filter primitive Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feTileElement> FeTurbulence(fs Filterspec, ftype string, bfx, bfy float64, octaves int, seed int64, stitch bool, s ...string) FeTurbulence specifies a turbulence filter primitive Standard reference: <http://www.w3.org/TR/SVG11/filters.html#feTurbulenceElement> ### Filter convenience functions (modeled on CSS filter effects) ### Blur(p float64) Blur function by standard deviation Brightness(p float64) Brightness function (0-100) Grayscale() Apply a grayscale filter to the image HueRotate(a float64) Rotate Hues (0-360 degrees) Invert() Invert the image's colors Saturate(p float64) Percent saturation, 0 is grayscale Sepia() Apply sepia tone ### Utility ### Grid(x int, y int, w int, h int, n int, s ...string) draws a grid of straight lines starting at x,y, with a width w, and height h, and a size of n. ![Grid](http://farm5.static.flickr.com/4133/5190957924_7a31d0db34.jpg) ### Credits ### Thanks to Jonathan Wright for the io.Writer update.

Vector Graphics
20 Github Stars