aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-05-14 23:42:14 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-05-14 23:42:14 +0200
commit7dc2a4bd862f72e51935b97f0802dbba06fb9b95 (patch)
tree338861ba9256b64c9bccad3fbeeacda7efd8b743
parent054700bf7efb8a346f13e59b10afca3cade3dc52 (diff)
Switch to float values
-rw-r--r--hershey.go14
-rw-r--r--main.go8
2 files changed, 12 insertions, 10 deletions
diff --git a/hershey.go b/hershey.go
index 713da1f..f4618ed 100644
--- a/hershey.go
+++ b/hershey.go
@@ -9,8 +9,10 @@ import (
"strings"
)
+type Unit float64
+
type Point struct {
- X, Y int
+ X, Y Unit
}
type Path []Point
@@ -18,7 +20,7 @@ type Set []Path
type Glyph struct {
S Set
- W int
+ W Unit
}
type Font map[rune]Glyph
@@ -29,11 +31,11 @@ func parseInt(s string) (n int) {
return
}
-func parsePoint(in uint8) int {
- return int(in) - int('R')
+func parsePoint(in uint8) Unit {
+ return Unit(in) - Unit('R')
}
-func parseData(s string, w, h, scale int) Set {
+func parseData(s string, w, h, scale Unit) Set {
var st Set
for i, el := range strings.Fields(s) {
var ph Path
@@ -68,7 +70,7 @@ func loadFont(fname string) Font {
l := parsePoint(line[8])
r := parsePoint(line[9])
w := r - l
- scale := 5
+ scale := Unit(2.5)
fnt[rune(n)] = Glyph{
S: parseData(line[10:], w, 32, scale),
W: w * scale,
diff --git a/main.go b/main.go
index 149537e..c6332a2 100644
--- a/main.go
+++ b/main.go
@@ -25,9 +25,9 @@ var selector = map[string]string{
}
func main() {
- fnt := loadFont("data/hershey")
- var x, y int
+ var x, y Unit
+ fnt := loadFont("data/hershey")
m := getMap("data/" + selector["Roman Simplex"])
f := fnt.Select(m)
@@ -35,9 +35,9 @@ func main() {
gl := f[rune(i)]
if y+gl.W >= 4000 {
y = 0
- x += 200
+ x += 100
}
- fmt.Printf("^%d,%d,%s", x, y, gl)
+ fmt.Printf("^%v,%v,%s", x, y, gl)
y += gl.W
}
}