Difference between revisions of "VGA Flag Language"

From Foone Wiki
Jump to navigation Jump to search
(Created page with "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...")
 
Line 39: Line 39:
{| class="wikitable"
{| class="wikitable"
|+
|+
Value types
!Name
!Name
!Examples
!Examples
!Description
!Description
|-
|-
|Integer
|Integers
|4
|4
-5
-5
Line 50: Line 51:
|Whole signed numbers, 16-bits. Used for text sizing and ellipse width/height.
|Whole signed numbers, 16-bits. Used for text sizing and ellipse width/height.
|-
|-
|Color
|Colors
|RGB(10,20,30)
|RGB(10,20,30)
<nowiki>#</nowiki>FF00FF
<nowiki>#</nowiki>FF00FF
|A given color. Technically 6-bits-per-channel, but we're pretending they're not
|A given color. Technically 6-bits-per-channel, but we're pretending they're not
|-
|-
|Enumeration
|Enumerations
|Filled
|Filled
Medium
Medium
Line 62: Line 63:
|Used for special values in commands
|Used for special values in commands
|-
|-
|String
|Strings
|"foobar"
|"foobar"
'bazqux'
'bazqux'
|A text string used for metadata
|A text string used for metadata
|-
|-
|Point
|Points
|(10,25)
|(10,25)
(-50, 500)
(-50, 500)
|A point is a geometric location made of two integers.
|A point is a geometric location made of two integers.
|-
|-
|List
|Lists
|["hello"]
|["hello"]
[(25,0), (50,0)]
[(25,0), (50,0)]
Line 80: Line 81:
=== Metadata ===
=== Metadata ===
Some variable definitions are interpreted by VGAPride. These special definitions are:
Some variable definitions are interpreted by VGAPride. These special definitions are:
{| class="wikitable"
|+Metadata variables
!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:
{| class="wikitable"
|+Pre-defined colors
!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.
{| class="wikitable"
|+Commands
!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
|-
|Triangle
|3 Points & a color
|A triangle
|Triangle (0,0), (50,0), (0,50), $white
|-
|Quad
|4 Points & a color
|A 4-sided polygon
|Quad (0,0), (50, 0), (50,50), (0, 50), $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, list of points, and color
|A polygon, either filled, outlined, or with thick outlines
|Polygon Filled,[(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
|-
|Star
|A star-type enum, a point, and a color
|A star, in one of three sizes: Small, Medium, Large
|Star Big, (50,50), $white
|-
|Image
|A string to a PNG file
|Inserts a 16-color 640x480 image. Will overwrite any existing image
|Image "crabgay256.png"
|}

=== meta-include ===
<nowiki>#</nowiki>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 name.

Example:
#include "rainbow7"

Revision as of 02:22, 30 December 2023

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)
}

Triangle (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:

Value types
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:

Metadata variables
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:

Pre-defined colors
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.

Commands
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
Triangle 3 Points & a color A triangle Triangle (0,0), (50,0), (0,50), $white
Quad 4 Points & a color A 4-sided polygon Quad (0,0), (50, 0), (50,50), (0, 50), $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, list of points, and color A polygon, either filled, outlined, or with thick outlines Polygon Filled,[(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
Star A star-type enum, a point, and a color A star, in one of three sizes: Small, Medium, Large Star Big, (50,50), $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 name.

Example:

#include "rainbow7"