SlideShare a Scribd company logo
programming  pictures  with
Anthony  J.  Starks                  
ajstarks@gmail.com      
@ajstarks
The  views  and  opinions  presented  here  are  personal  views  and  
         do  not  necessarily  reflect  the  views  of  Sanofi
mo@va@on
inspira@on:  Processing
0.  Install  Go
1.  goinstall  github.com/ajstarks/svgo
2.  Make  pictures



geKng  started  with
‣ interfaces
   ‣ variadic  arguments
   ‣ composite  literals  and  types
   ‣ format,  string,  xml,  flag  libraries
   ‣ fast  compiles  
   ‣ goinstall
   ‣ goplay
   ‣ func@ons  as  the  unit  of  graphics  work


Go  Language  features  in  
SVGo: a Go Library for SVG generation
object       arguments                         CSS  style


 Rect(100,  200,  250,  125,"fill:gray;  stroke:blue")



                                    (100,200)
 <rect  x="100"  y="200"  
 width="250"  height="125"                                   125

 style="fill:gray;  stroke:blue"/>
                                                     250




objects,  API  and  output
object       arguments                          aZributes


 Rect(100,  200,  250,  125,
       `id="box"`,  `fill="gray"`,  `stroke="blue"`)

                                     (100,200)
 <rect  x="100"  y="200"
 width="250"  height="125"                                   125

 id="box"  fill="gray"  stroke="blue"/>
                                                     250




objects,  API  and  output
New(w  io.Writer)                                   Specify  the  des@na@on  for  the  generated  code

Start(w,  h  int,  op@ons  ...string)               Begin  the  SVG  document,  with  op@ons

Startview(w,  h,  minx,  miny,  vw,  vh  int)       Begin  the  document  with  a  viewport

Gid(id  string)/Gend()                              Begin/end  a  group  with  an  id

Gstyle(s  string)/Gend()                            Begin/end  a  group  style

Def(s  string)/DefEnd()                             Begin/end  defini@on  block

Title(s  string)                                    Specify  the  document  @tle

Desc(s  string)                                     Specify  the  document  descrip@on

Link(href,  @tle  string)/LinkEnd()                 Link  to  content  between  Link  and  LinkEnd

Use(x,  y  int,  link  string,  style  ...string)   Use  previously  defined  content

End()                                               End  the  SVG  document



Structure,  Metadata,  Links
Line(x1,  y1,  x2,  y2  int,  s  ...string)                            Polyline(x,  y  []int,  s  ...string)




              Qbez(sx,  sy,  cx,  cy,  ex,  ey  int,  s  ...string)       Bezier(sx,  sy,  cx,  cy,  px,  py,  ex,  ey  int,  s  ...string)




Arc(sx  sy,  ax,  ay,  r  int,  large,  sweep  bool,  ex  ey  int,  s  ...string)          Path(d  string,  s  ...string)


  Lines,  Curves,  and  Path
Scale(n  float64)                ScaleXY(dx,  dy  float64)




  SkewX(a  float64)
                                         SkewY(a  float64)                SkewXY(ax,  ay  float64)


                                                                Gtransform(s  string)
                                                                TranslateRotate(x,  y  int,  r  float64)
                                                                RotateTranslate(x,  y  int,  r  float64)


  Translate(x,  y  int)
                                         Rotate(r  float64)
Transforms
Text(x,  y  int,  t  string,  s  ...string)                           Image(x,  y,  w,  h  int,  link  string,  s  ...string)




Textlines(x,  y  int,  s  []string,  size,  spacing  int,  fill,  align  string)        Textpath(t,  pathid  string,  s  ...string)



Text  and  Image
Offcolor
                                                                              Offset  uint8
                                                                              Color  string
                                                                              Opacity  float64

  LinearGradient(id  string,  x1,  y1,  x2,  y2  uint8,  sc  []Offcolor)




  RadialGradient(id  string,  cx,  cy,  r,  fx,  fy  uint8,  sc  []Offcolor)




Gradients
⟶                                                                              ⟶
   44 77 232                                                             44 77 232 .33
     RGB(r,  g,  b  int)                                                 RGBA(r,  g,  b  int,  alpha  float64)




                           Grid(x,  y,  w,  h,  n  int,  s  ...string)




Colors,  Grid
1 canvas.Start(500, 500, `onload="Startup()"`)

  2 canvas.Script("application/javascript", "http://example.com/myscript.js")

  3 canvas.Rect(10, 10, 100, 200)

  4 canvas.End()



 example.com/myscript.js

    function StartUp()
                                     1    Begin  the  document,  load  your  func@on  
    {
    ...                              2    specify  the  script,  by  reference
    }
                                     3    specify  SVG  elements,  operate  on  these
    function doStuff(element)
    {                                4    end  the  SVG  document
    ...
    }


Scrip@ng
SVGo: a Go Library for SVG generation
fill:rgb(164,198,57)
Scale

                             Line

                             Arc
Roundrect
               Circle


        Line                 Rect
SVGo  Hello  world
SVGo: a Go Library for SVG generation
SVGo: a Go Library for SVG generation
SVGo: a Go Library for SVG generation
using  goplay  and  a  browser  to  sketch  
with  code
inspec@ng  the  generated  code
imports,  constants,  flags


                        main  func@on;  use  the  
                        circle  func@on  to  handle  
                        the  URL
                        in  the  circle  func@on,  
                        write  the  generated  SVG  
                        to  the  web  client

                        if  the  URL  contains  a  
                        color,  use  it


drawing  in  a  web  server
define  the  input  data  structures



                        read  the  input

             parse  the  input  into  the  structures

                             draw




read/parse/draw  paZern
SVGo: a Go Library for SVG generation
pmap  -­‐stagger  -­‐p  -­‐g  100  -­‐bg  lightsteelblue  
-­‐t  "Browser  Market  Share"  -­‐show@tle  bs.xml  >  bs.svg
rr:  radar  roadmap   servermap:                compx:  component  
                        infrastructure  models    diagrams




roadmap:  roadmaps      pmap:  percentage  maps   techstack:  technology  
and  @melines                                     stack  and  standards




IT  architecture  tools  using
Tools  -­‐  con@nued




pv:  porjolio  view     bulletgraph:  qualita@ve     Nmeline:  @meline/milestones
                        and  compara@ve  measures




                             arch9:  9-­‐box
Principle:  Automate  the  crea@on  of  
consistently-­‐styled  views  from  
standardized  data


   data
Visio  
                               Chrome
                               Firefox
XML     Tool     SVG  
                         PNG             Word
                         JPG             PowerPoint
                         PDF             Adobe  Reader



tool  workflow
compx    –w  1200  –h  900  –t  "Title"  file.xml  >  file.svg    

Tool  name      Command  op@ons             Input     Output
Browser   Editor




Command  lines
Visio   Editor




Command  lines
compx:  components  on  a  grid
top       guZer

      les

            0


            1
row


            2


            3

                      0           1         2   3
                                      col

compx  grid
Component
            opera@ng  system



              sosware
      nnw           n          nne
 nw                                  ne


wnw                                  ene


 w                                   e


wsw                                  ese

 sw                                  se
      ssw           s          sse
Thing  1                             Thing  2
                           Stuff
                   e                w




<comp  id="t1"  row="0"  col="0"  name="Thing  1"  .../>

<comp  id="t2"  row="0"  col="2"  name="Thing  2"...>
          <connect  sloc="w"  dloc="e"  dest="t1"  mark="d">
          Stuff
          </connect>
</comp>
ϴ  =  10   ϴ  =  30   ϴ  =  60   ϴ  =  90




varia@ons  on  the  leZer  i
flickr50  and  twiZer  update  frequency
tumblrpic
google  webfonts
layer  tennis  remixes
layer  Tennis:  all  of  season  3
“Have  fun  programming  pictures”




 Contact      @ajstarks,  ajstarks@gmail.com
 Repository   hZp://github.com/ajstarks/svgo
 Examples         hZp://flic.kr/s/aHsjpMnssp

More Related Content

PDF
SVGo workshop
PDF
Coding for
PDF
Dynamic C++ Silicon Valley Code Camp 2012
PDF
Dynamic C++ ACCU 2013
PDF
Coding in Style
PDF
Fabric.js @ Falsy Values
PDF
Hive function-cheat-sheet
PDF
Groovy's Builder
SVGo workshop
Coding for
Dynamic C++ Silicon Valley Code Camp 2012
Dynamic C++ ACCU 2013
Coding in Style
Fabric.js @ Falsy Values
Hive function-cheat-sheet
Groovy's Builder

What's hot (20)

PDF
Grammarware Memes
PPTX
Practical scalaz
PPTX
Java string handling
PDF
Kotlin Basics - Apalon Kotlin Sprint Part 2
PPT
SDC - Einführung in Scala
KEY
Scalaz
PPTX
Getting started with ES6
PDF
Functional Scala 2020
PDF
The Ring programming language version 1.8 book - Part 94 of 202
PDF
Haskell in the Real World
PDF
D3.js workshop
KEY
Fabric.js — Building a Canvas Library
PDF
PDF
C# v8 new features - raimundas banevicius
PDF
python-cheat-sheet-v1
PPTX
Connect() Mini 2016
PDF
A Divine Data Comedy
PDF
Maps and Meaning: Graph-based Entity Resolution in Apache Spark & GraphX
PDF
Reactive Feature Generation with Spark and MLlib by Jeffrey Smith (1)
PDF
Einführung in TypeScript
Grammarware Memes
Practical scalaz
Java string handling
Kotlin Basics - Apalon Kotlin Sprint Part 2
SDC - Einführung in Scala
Scalaz
Getting started with ES6
Functional Scala 2020
The Ring programming language version 1.8 book - Part 94 of 202
Haskell in the Real World
D3.js workshop
Fabric.js — Building a Canvas Library
C# v8 new features - raimundas banevicius
python-cheat-sheet-v1
Connect() Mini 2016
A Divine Data Comedy
Maps and Meaning: Graph-based Entity Resolution in Apache Spark & GraphX
Reactive Feature Generation with Spark and MLlib by Jeffrey Smith (1)
Einführung in TypeScript
Ad

Similar to SVGo: a Go Library for SVG generation (20)

PDF
SVG vs Canvas - Showdown of the Painters
PDF
Nodebox for Data Visualization
PDF
Power of canvas
PDF
Introduction to Canvas and Native Web Vector Graphics
PDF
DojoX GFX Keynote Eugene Lazutkin SVG Open 2007
PDF
MS TechDays 2011 - HTML 5 All the Awesome Bits
PDF
HTML5 Canvas
PDF
DojoX GFX Session Eugene Lazutkin SVG Open 2007
PPTX
HTML5 Graphics - Canvas and SVG
PDF
SVG (Devoxx 2011, 2011-NOV-14)
ODP
HTML5 & SVG in Cartography - Workshop
PDF
PDF
KEY
SVG overview
PDF
Programming methodology lecture11
PDF
Web mapping with vector data. Is it the future ? 2012
KEY
Processing presentation
PPTX
Academy PRO: HTML5 API graphics
PDF
Cg in Two Pages
PPT
CS 354 Vector Graphics & Path Rendering
SVG vs Canvas - Showdown of the Painters
Nodebox for Data Visualization
Power of canvas
Introduction to Canvas and Native Web Vector Graphics
DojoX GFX Keynote Eugene Lazutkin SVG Open 2007
MS TechDays 2011 - HTML 5 All the Awesome Bits
HTML5 Canvas
DojoX GFX Session Eugene Lazutkin SVG Open 2007
HTML5 Graphics - Canvas and SVG
SVG (Devoxx 2011, 2011-NOV-14)
HTML5 & SVG in Cartography - Workshop
SVG overview
Programming methodology lecture11
Web mapping with vector data. Is it the future ? 2012
Processing presentation
Academy PRO: HTML5 API graphics
Cg in Two Pages
CS 354 Vector Graphics & Path Rendering
Ad

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Encapsulation theory and applications.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Cloud computing and distributed systems.
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
MYSQL Presentation for SQL database connectivity
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Chapter 3 Spatial Domain Image Processing.pdf
Big Data Technologies - Introduction.pptx
sap open course for s4hana steps from ECC to s4
Encapsulation theory and applications.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Reach Out and Touch Someone: Haptics and Empathic Computing
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Understanding_Digital_Forensics_Presentation.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Mobile App Security Testing_ A Comprehensive Guide.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Cloud computing and distributed systems.
Advanced methodologies resolving dimensionality complications for autism neur...
Unlocking AI with Model Context Protocol (MCP)
20250228 LYD VKU AI Blended-Learning.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Dropbox Q2 2025 Financial Results & Investor Presentation
MYSQL Presentation for SQL database connectivity
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Chapter 3 Spatial Domain Image Processing.pdf

SVGo: a Go Library for SVG generation

  • 1. programming  pictures  with Anthony  J.  Starks                   ajstarks@gmail.com       @ajstarks
  • 2. The  views  and  opinions  presented  here  are  personal  views  and   do  not  necessarily  reflect  the  views  of  Sanofi
  • 5. 0.  Install  Go 1.  goinstall  github.com/ajstarks/svgo 2.  Make  pictures geKng  started  with
  • 6. ‣ interfaces ‣ variadic  arguments ‣ composite  literals  and  types ‣ format,  string,  xml,  flag  libraries ‣ fast  compiles   ‣ goinstall ‣ goplay ‣ func@ons  as  the  unit  of  graphics  work Go  Language  features  in  
  • 8. object arguments CSS  style Rect(100,  200,  250,  125,"fill:gray;  stroke:blue") (100,200) <rect  x="100"  y="200"   width="250"  height="125"   125 style="fill:gray;  stroke:blue"/> 250 objects,  API  and  output
  • 9. object arguments aZributes Rect(100,  200,  250,  125, `id="box"`,  `fill="gray"`,  `stroke="blue"`) (100,200) <rect  x="100"  y="200" width="250"  height="125" 125 id="box"  fill="gray"  stroke="blue"/> 250 objects,  API  and  output
  • 10. New(w  io.Writer) Specify  the  des@na@on  for  the  generated  code Start(w,  h  int,  op@ons  ...string) Begin  the  SVG  document,  with  op@ons Startview(w,  h,  minx,  miny,  vw,  vh  int) Begin  the  document  with  a  viewport Gid(id  string)/Gend() Begin/end  a  group  with  an  id Gstyle(s  string)/Gend() Begin/end  a  group  style Def(s  string)/DefEnd() Begin/end  defini@on  block Title(s  string) Specify  the  document  @tle Desc(s  string) Specify  the  document  descrip@on Link(href,  @tle  string)/LinkEnd() Link  to  content  between  Link  and  LinkEnd Use(x,  y  int,  link  string,  style  ...string) Use  previously  defined  content End() End  the  SVG  document Structure,  Metadata,  Links
  • 11. Line(x1,  y1,  x2,  y2  int,  s  ...string) Polyline(x,  y  []int,  s  ...string) Qbez(sx,  sy,  cx,  cy,  ex,  ey  int,  s  ...string) Bezier(sx,  sy,  cx,  cy,  px,  py,  ex,  ey  int,  s  ...string) Arc(sx  sy,  ax,  ay,  r  int,  large,  sweep  bool,  ex  ey  int,  s  ...string) Path(d  string,  s  ...string) Lines,  Curves,  and  Path
  • 12. Scale(n  float64) ScaleXY(dx,  dy  float64) SkewX(a  float64) SkewY(a  float64) SkewXY(ax,  ay  float64) Gtransform(s  string) TranslateRotate(x,  y  int,  r  float64) RotateTranslate(x,  y  int,  r  float64) Translate(x,  y  int) Rotate(r  float64) Transforms
  • 13. Text(x,  y  int,  t  string,  s  ...string) Image(x,  y,  w,  h  int,  link  string,  s  ...string) Textlines(x,  y  int,  s  []string,  size,  spacing  int,  fill,  align  string) Textpath(t,  pathid  string,  s  ...string) Text  and  Image
  • 14. Offcolor Offset  uint8 Color  string Opacity  float64 LinearGradient(id  string,  x1,  y1,  x2,  y2  uint8,  sc  []Offcolor) RadialGradient(id  string,  cx,  cy,  r,  fx,  fy  uint8,  sc  []Offcolor) Gradients
  • 15. ⟶ 44 77 232 44 77 232 .33 RGB(r,  g,  b  int) RGBA(r,  g,  b  int,  alpha  float64) Grid(x,  y,  w,  h,  n  int,  s  ...string) Colors,  Grid
  • 16. 1 canvas.Start(500, 500, `onload="Startup()"`) 2 canvas.Script("application/javascript", "http://example.com/myscript.js") 3 canvas.Rect(10, 10, 100, 200) 4 canvas.End() example.com/myscript.js function StartUp() 1 Begin  the  document,  load  your  func@on   { ... 2 specify  the  script,  by  reference } 3 specify  SVG  elements,  operate  on  these function doStuff(element) { 4 end  the  SVG  document ... } Scrip@ng
  • 18. fill:rgb(164,198,57) Scale Line Arc Roundrect Circle Line Rect
  • 23. using  goplay  and  a  browser  to  sketch   with  code
  • 25. imports,  constants,  flags main  func@on;  use  the   circle  func@on  to  handle   the  URL in  the  circle  func@on,   write  the  generated  SVG   to  the  web  client if  the  URL  contains  a   color,  use  it drawing  in  a  web  server
  • 26. define  the  input  data  structures read  the  input parse  the  input  into  the  structures draw read/parse/draw  paZern
  • 28. pmap  -­‐stagger  -­‐p  -­‐g  100  -­‐bg  lightsteelblue   -­‐t  "Browser  Market  Share"  -­‐show@tle  bs.xml  >  bs.svg
  • 29. rr:  radar  roadmap servermap:   compx:  component   infrastructure  models diagrams roadmap:  roadmaps   pmap:  percentage  maps techstack:  technology   and  @melines stack  and  standards IT  architecture  tools  using
  • 30. Tools  -­‐  con@nued pv:  porjolio  view bulletgraph:  qualita@ve   Nmeline:  @meline/milestones and  compara@ve  measures arch9:  9-­‐box
  • 31. Principle:  Automate  the  crea@on  of   consistently-­‐styled  views  from   standardized  data data
  • 32. Visio   Chrome Firefox XML   Tool   SVG   PNG Word JPG PowerPoint PDF Adobe  Reader tool  workflow
  • 33. compx    –w  1200  –h  900  –t  "Title"  file.xml  >  file.svg     Tool  name Command  op@ons Input Output
  • 34. Browser Editor Command  lines
  • 35. Visio Editor Command  lines
  • 37. top guZer les 0 1 row 2 3 0 1 2 3 col compx  grid
  • 38. Component opera@ng  system sosware nnw n nne nw ne wnw ene w e wsw ese sw se ssw s sse
  • 39. Thing  1 Thing  2 Stuff e w <comp  id="t1"  row="0"  col="0"  name="Thing  1"  .../> <comp  id="t2"  row="0"  col="2"  name="Thing  2"...>          <connect  sloc="w"  dloc="e"  dest="t1"  mark="d"> Stuff </connect> </comp>
  • 40. ϴ  =  10 ϴ  =  30 ϴ  =  60 ϴ  =  90 varia@ons  on  the  leZer  i
  • 41. flickr50  and  twiZer  update  frequency
  • 45. layer  Tennis:  all  of  season  3
  • 46. “Have  fun  programming  pictures” Contact @ajstarks,  ajstarks@gmail.com Repository hZp://github.com/ajstarks/svgo Examples hZp://flic.kr/s/aHsjpMnssp