Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/enzet/iconscript

Generating icons using text commands
https://github.com/enzet/iconscript

antlr go icons

Last synced: about 2 months ago
JSON representation

Generating icons using text commands

Awesome Lists containing this project

README

        

# iconscript

Paperscript parser for icon shape drawing.

This is a part of [Map Machine](https://github.com/enzet/map-machine) project.

## JavaScript part

Install:

```shell
npm install paper paperjs-offset
npm install -g live-server
```

Run:

```shell
live-server
```

## Go part

Requires: Go 1.19, ANTLR 4.10.1.

Install:

```shell
cd grammar
antlr -Dlanguage=Go -o parser IconScript.g4
cd ..
go build
```

You may also test installation with `go test`.

```shell
go run main.go -i
```

## Syntax

### Global context

- __width__ — stroke width.
- __position__ — current position of the cursor.

### Commands

`` is 2D coordinates in the form `,` or `+,` (`+` means,
that the position is relative to the __position__).

| Command | Description |
|---|---|
| `a` | Set adding mode (default mode) |
| `r` | Set removing mode |
| `w ` | Set __width__ to a value |
| `p ` | Set __position__ to a value |
| `l []` | Draw lines between positions |
| `c ` | Draw circle specified by center point and radius |
| `s ` | Draw rectangle specified by top left and bottom right points |
| `ar ` | Draw arc specified by center point, radius, and two angles in radians |

### Variables

Variable can be defined with ` = []` and accessed with
`@`.

### Example

```iconscript
cube = lf +0,0 +2,0 +0,2 +-2,0 +0,-2
{
%glider
p 6,2 @cube p +4,4 @cube
p +-8,4 @cube p +4,0 @cube p +4,0 @cube
}
```