Pangraph

From LXF Wiki

Pangraph is an idea for a vector graphics language suited to hand-coding and for parsing to svg by a wiki server. Not that I know anything about vector languages as such - only that svg is not as concise or as readable as I would like.

I'm sketching out the basics without reference to the present panscript syntax. The idea is to then compare the two syntaxes and pick the best features of both.

Table of contents

The idea

Pangraph has three inspirations, as:

  • An implementation of panscript.
  • A common language for vector graphics and graphical user interfaces (GUIs), in both 2- and 3-D.
  • A wiki markup language. The idea is that it will be parsed and served as svg in exactly the same way that wikitext is parsed and served as html. It will enable you to collaboratively create and share 2- and 3-D graphic images of any reasonable complexity.

The basics

Code essentially comprises two things: objects and metadata. Another fundamental concept is that of size.

Metadata

Metadata includes all the stuff typically found in html <head> and <!-- --> (comment) containers, i.e. anything that is not directly related to the displayed content.

Objects

Everything else, whether rendered or not, is a graphic object. There are a handful of primary object classes, such as lines and fills. Everything else is a property of a primary object, including embedded (e.g. grouped) objects, and embedded or linked executables (methods).

Many things such as guides, connectors, layers and so on are just primary objects with special properties such as stickiness, transparency and so on.

Units and scale

pangraph does not insist on absolute sizes of anything. You can scale everything relative to the frame it finds itself in. All such positioning measurements are made in "pangraph units". The larger of the horizontal and vertical drawing dimensions is deemed to be 1,000 pangraph units, the shorter is reduced in proportion. For finer resolutions, decimals are used.

However, you can use fixed units if you need to, for example to ensure uniform font and line weight when several images are displayed at different scalings, or to fix the drawing size when flowing text around it.

Object classes

Primary object classes

There are only a few primary object classes, perhaps surprisingly few:

  • Point
  • Line, including segment (group of points with additional group properties?)
  • Area or Fill (group of line/s with additional group properties?)
  • Text
  • Group
  • Bitmap (or foreign object generally?)

Properties

Typical properties include:

  • Stickiness
  • Transparency
  • Transformation
  • Replication: patterns, grids, symmetries, clones
  • Style (weight, colour, etc)
  • Depth

Sub-classes

Many common object classes are primary types with specific properties defined, such as:

  • Connection point: sticky point
  • Connector: line with (optional) smart routing
  • Arrow: line with styled end point/s
  • Guide: point, line or area which is transparent (and optionally sticky)
    • Grid: guide which is replicated

Embedded objects

Other common classes comprise a primary type with a specific second type embedded:

  • Pattern fill: area with embedded and replicated graphic
  • Texture fill: area with embedded and replicated bitmap
  • Layer: group with layer property set
  • Timeline: group with time-related transformation parameters
  • Widget: group with embedded area, text and (no or more) sub-groups.

Syntax

Like wikitext, pangraph uses easily-found characters, simple repetition and short strings. Candidate characters for the most common uses are:

 , . ; ' # / [ ]

Maybe I ought to use one of these for the metadata container.

Metadata

Metadata includes anything that is not directly related to the displayed content such as declarations, comments and so on. In pangraph it can take two related formats:

A single line is denoted by an initial ! character, and terminated by an end-of-line, <cr><lf>, or similar:

! This is a single line of metadata or comment.

Multiple lines are delineated by a !! ... !! container:

!! This is a multiple-line set of metadata or comments or whatever.
It can contain:
  [t /c pangraph code snippets, that will not be executed, /c ]t
  <p>Bits'n'bobs in other languages, that will not be executed,</p>
 
      white space
 
  and anything else 
!!

Objects

Objects are delimited by a [x ... ]x container, where x is the object class:

[t This is a simple text object ]t

The container markup provides the same functionality as an XML container such as <text> ... </text> but is quicker to type and less cluttered to read.