VGA Flag Language
The VGA Flag Language is a DSL for defining pride flags, to be used in VGAPride.
Example flag script:
$names=["demisexual"] $description="The Demisexual pride flag" // Unknown creator. Maybe research further? $textcolor=$black vertical{ RGB(255,255,255) RGB(255,255,255) RGB(110, 0,112) RGB(210,210,210) RGB(210,210,210) } Polygon Filled, (0,0), [(0,0), (240,240), (0,480)], $black
Rendering context
Scripts generate a 640x480 image which uses a max of 16 colors.
The only pre-defined color is 0, which is black. The other 15 colors will be allocated as they are used, and the compiler will throw an error if too many colors are used.
The coordinate system is 0-639 horizontally, 0-479 vertically, starting in the top-left.
Overall structure
The main elements of a script are comments, variable declarations, structures, and commands.
Comments can start anywhere on a line and begin with // and continue to a newline.
Variable declarations take the form $variable_name = SOMEVALUE (see Value Types below)
Structures are curly-brace delimited blocks which automatically generate rectangle commands based on colors. See Structures below.
Commands are functions which draw different shapes into the image. See Command List below.
Value Types
There are six value types used for variables:
Name | Examples | Description |
---|---|---|
Integer | 4
-5 +15 |
Whole signed numbers, 16-bits. Used for text sizing and ellipse width/height. |
Color | RGB(10,20,30)
#FF00FF |
A given color. Technically 6-bits-per-channel, but we're pretending they're not |
Enumeration | Filled
Medium Outline |
Used for special values in commands |
String | "foobar"
'bazqux' |
A text string used for metadata |
Point | (10,25)
(-50, 500) |
A point is a geometric location made of two integers. |
List | ["hello"]
[(25,0), (50,0)] |
A list is a static array of values. Only used for Points and Strings. |
Metadata
Some variable definitions are interpreted by VGAPride. These special definitions are:
Name | Description | Type | Default value |
---|---|---|---|
$names | Used to look up the flag from the command line. The first one is considered the canonically name, and will be shown in the help. Required | List of Strings | N/A |
$description | The longform description shown in the list. Required. | String | N/A |
$credits | Gives credit to the creator/lists creation details like variants. | String | N/A |
$textsize | the font size to use when displaying the description on the slideshow mode. | Integer | 4 |
$textcolor | The color to use when displaying the description on the slideshow mode. | Color | RGB(255,255,255) |
$textlayout | Where to place the description text in slideshow mode. Can be set to Left/Right/Center | Enumeration | Center |
Predefined colors:
Some variables are predefined with colors to be used in images. The pre-defined colors are:
Name | Color |
---|---|
$black | RGB(0,0,0) |
$white | RGB(255,255,255) |
Structures
Structures automatically generate commands in a given order to simplify generating common flag types. The two available structures are "vertical" and "horizontal", which align the colors top-to-bottom and left-to-right, respectively. The stripes are given equal heights/widths.
An example structure:
vertical{ RGB( 7,141,112) RGB( 38,206,170) RGB(153,232,194) RGB(255,255,255) RGB(123,173,227) RGB( 80, 73,203) RGB( 62, 26,120) }
Commands
Commands draw to the image, taking some number of parameters. There's also one meta-command, #include, explained below.
Name | Arguments | Description | Example |
---|---|---|---|
Rectangle | 2 Points & a color | A rectangle defined by the upper-left and bottom-right points | Rectangle (0,50), (200,60), $white |
Ellipse | A point, width/height integers, and a color | An ellipse (or circle), defined by the given width/height | Ellipse (320,240), 72, 72, RGB(27,23,30) |
Polygon | A polygon-type enum, a base point, a list of points, and color | A polygon, either filled, outlined, or with thick outlines.
(The polygon is shifted by the base point before rendering) |
Polygon Filled,(0,0), [(232,292),(319,135),(319,169),(260,274)],$white |
Lines | A line-type enum, a list of points, and a color | A series of (connected?) lines, Regular or Thick | Lines Thick, [(25,0), (0,25)], $white |
Image | A string to a PNG file | Inserts a 16-color 640x480 image. Will overwrite any existing image | Image "crabgay256.png" |
meta-include
#include is a meta-command which looks up another flag and inserts it at the current position, as if all the commands from that flag had been copy-pasted into this one. It takes a string to look up the flag by filename. Paths aren't supported: it's only a filename
Example:
#include "seven-stripe-rainbow.flag"