项目作者: rubenpieters

项目描述 :
textbased ui position configuration
高级语言: PureScript
项目地址: git://github.com/rubenpieters/tupc.git
创建时间: 2018-02-13T18:00:56Z
项目社区:https://github.com/rubenpieters/tupc

开源协议:MIT License

下载


Build Status

TUPC: Textbased UI Position Configuration

This library parses a textbased & visual representation to create UI positions.

For example, the following positions:

  1. (0,0) ----- (100,0) ---- (150,0)
  2. | | |
  3. | | |
  4. | | |
  5. | | |
  6. (0,100) --- (100,100) -- (150,100)
  7. | |
  8. | |
  9. (0,150) ---------------- (150,150)

are the result of parsing the following file:

  1. # scale=50
  2. 113
  3. 113
  4. 222

Where 1 corresponds to the section in the top-left, 2 to the section in the bottom and 3 to the section in the top-right.

Parsing will output data to a Map:

  1. Map.fromFoldable
  2. [ (Tuple '1' (Pos { xLeft: 0, xRight: 100, yTop: 0, yBot: 100 }))
  3. , (Tuple '2' (Pos { xLeft: 0, xRight: 150, yTop: 100, yBot: 150 }))
  4. , (Tuple '3' (Pos { xLeft: 100, xRight: 150, yTop: 0, yBot: 100 }))
  5. ]

Configuration

Configuration parameters are specified by lines starting with # and then providing parameter = value. These lines are called the configuration section.

The following configurations are supported:

parameter info default value
scale scale for both axes 1
scaleX scale for x-axis
scaleY scale for y-axis
ignore these characters are ignored in the content section +-\
ignoreExtra these characters are ignored in the content section, use this if you don’t want to override the default ones in ignore
originX location for x-origin, where x=0 Left
originY location for y-origin, where y=0 Up
directionX direction where x-axis increases Right
directionY direction where y-axis increases Down

Content

The rest of the file is the content section. From this section the bounds for a specific character is calculated to obtain its position.

Only the outermost positions count. Meaning that this:

  1. 11111
  2. 11111
  3. 11111
  4. 11111
  5. 11111

or this:

  1. 1+++1
  2. +++++
  3. +++++
  4. +++++
  5. 1+++1

are equivalent.

The calculated positions are multiplied by the scale setting (or scaleX and scaleY if they are set).