Skip to content

xem/miniSVG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Mini vector format

characteristics

  • binary encoding, 100% ASCII (values 0-127)
  • exportable to SVG and JS canvas2D
  • fixed width/height/viewport: 127x127
  • all distances/coordinates are integers between 0 and 127
  • path/text items limited to 127 bytes.
  • missing features: line/polyline/polygon (use path), circle (use ellipse)

Encoding

For each shape/path:

[item][bytes*][attributes*][fill*][fill-opacity*][stroke*][stroke-dasharray*]

  1. Item type and options: 1 byte

7 6 5 4 3 2 1 0 [ 0 a a b c d e f ]

aa (2 bits): identifier

  • 00 ellipse
  • 01 rect
  • 10 text
  • 11 path

b: fill (color)

  • 0: none
  • 1: specified

c: fill-opacity

  • 0: none
  • 1: specified

d: stroke and stroke-width

  • 0: none
  • 1: specified

e: stroke-dasharray

  • 0: none
  • 1: specified

f: fill (def)

  • 0: none
  • 1: the last one specified
  1. (Only for text and path) Number of bytes to read before the next shape, not counting fill/stroke options
  • rect: 4 bytes, implicit (x, y, width, height)
  • ellipse: 4 bytes, implicit (cx, cy, rx, ry)
  • text: 3 bytes (x, y, font-size) + N bytes (font) + 1b (0x7F) + N bytes (text)
  • path: N bytes (d) (1 byte per letter + 1 byte per number)
  1. Shape attributes and options (b/c/d/e, if enabled)

Attributes:

  • x, y, width, height, cx, cy, rx, ry, font-size, opacity: 1 byte
  • font, text, d: N bytes
  • colors: 3 bytes (r/2, g/2, b/2)

Options:

  • b: 3 bytes
  • c: 1 byte
  • d: 3 + 1 bytes
  • e: 1 + 1 bytes
  • f: 0 bytes

About

Compressed vector graphics format spec + editor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages