Skip to content

Commit

Permalink
Add Ignore configuration value
Browse files Browse the repository at this point in the history
Ignoring a set of characters allows for annotations on the map that can
be used by the DM (and these annotations will not interfere with future
versions that support additional map symbols).
  • Loading branch information
peterh committed Oct 22, 2021
1 parent 3fc959e commit 12ddbe5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions draw.go
Expand Up @@ -16,6 +16,7 @@ type MapData struct {
Light uint8 // wall at LightAngle angle this (max) amplification
LightAngle int16 // in degrees
Output string // Output filename (must end in .png)
Ignore string // Characters to ignore (default 1234567890)
line []string
pic image.Image
}
Expand All @@ -30,6 +31,7 @@ func (m *MapData) defaults() {
m.ShadowWidth = 0.2
m.Light = 15
m.LightAngle = 10
m.Ignore = "1234567890"
}

type fromType struct {
Expand Down
7 changes: 7 additions & 0 deletions read.go
Expand Up @@ -70,6 +70,13 @@ func read(fn string) (*MapData, error) {
}

func (m *MapData) rectangle() {
// Trim ignored characters
for _, c := range m.Ignore {
for i := range m.line {
m.line[i] = strings.ReplaceAll(m.line[i], string(c), " ")
}
}

// trim leading empty lines
for len(m.line) > 0 && len(strings.TrimSpace(m.line[0])) == 0 {
m.line = m.line[1:]
Expand Down

0 comments on commit 12ddbe5

Please sign in to comment.