diff options
author | Dimitri Sokolyuk <demon@dim13.org> | 2016-11-14 00:42:23 +0100 |
---|---|---|
committer | Dimitri Sokolyuk <demon@dim13.org> | 2016-11-14 00:42:23 +0100 |
commit | 05af31880498bf60316b85415f9d4c1dfa0d1577 (patch) | |
tree | e7040c967ee8e98ae67c3c89ab9bf6d9d5acb5f8 | |
parent | 360abb4272dea659de237b1c58d46acc1746ffa7 (diff) |
wip
-rw-r--r-- | marks.go | 36 | ||||
-rw-r--r-- | media.go | 76 | ||||
-rw-r--r-- | pic.go | 6 | ||||
-rw-r--r-- | robo.go | 2 | ||||
-rw-r--r-- | testpattern.go | 2 | ||||
-rw-r--r-- | text.go | 10 | ||||
-rw-r--r-- | units.go | 15 |
7 files changed, 54 insertions, 93 deletions
@@ -1,7 +1,5 @@ package robo -import "bufio" - /* Landscape Portrait +- H -+ +- W -+ |x1 3| |2 1x| @@ -11,41 +9,17 @@ import "bufio" |2 3| +- -+ */ - /* - Type1 - - | | - -+ +- - - - -+ - | + Type1 Type2 - Type2 + | | +-- --+ + --+ +-- | | - +- -+ - | | - - | - +- + --+ | + | +-- */ -func DrawMarks(c *bufio.Writer, offset, size Point, length int) { - Point{600, 3800}.Move(c) - Point{200, 3800}.Draw(c) - Point{200, 3400}.Draw(c) - - Point{200, 600}.Move(c) - Point{200, 200}.Draw(c) - Point{600, 200}.Draw(c) - - Point{4840, 200}.Move(c) - Point{5240, 200}.Draw(c) - Point{5240, 600}.Draw(c) -} - func (r Robo) DrawMarks() { r.Line(Point{600, 3800}, Point{200, 3800}, Point{200, 3400}) r.Line(Point{200, 600}, Point{200, 200}, Point{600, 200}) @@ -1,102 +1,84 @@ package robo -import ( - "bufio" - "fmt" -) - // Overcut: depends on blade, 0 for pens type Media struct { Descr string // Description - ID int // FW111 - Speed int // !10 - Force int // FX10,0 - Overcut int // FC ? -} - -var MediaID = make(map[int]Media) - -func init() { - for _, m := range Medias { - MediaID[m.ID] = m - } -} - -func (m Media) String() string { - return fmt.Sprintf("%v: Speed %2d, Force %2d %s", - m.ID, m.Speed, m.Force, m.Descr) + ID Unit // FW111 + Speed Unit // !10 + Force Unit // FX10,0 + Overcut Unit // FC ? } -func (m Media) Apply(c *bufio.Writer) { - Unit(m.ID).Media(c) - Unit(m.Speed).Speed(c) - Unit(m.Force).Force(c) - Unit(m.Overcut).Overcut(c) +func (r Robo) SetMedia(m Media) { + r.Media(m.ID) + r.Speed(m.Speed) + r.Force(m.Force) + r.Overcut(m.Overcut) } -var Medias = []Media{ - { +var ( + MediaCardWithoutCraftPaperBacking = Media{ Descr: "Card without Craft Paper Backing", ID: 100, Speed: 10, Force: 27, Overcut: 18, - }, - { + } + MediaCardWithCraftPaperBacking = Media{ Descr: "Card with Craft Paper Backing", ID: 101, Speed: 10, Force: 27, Overcut: 18, - }, - { + } + MediaVinylSticker = Media{ Descr: "Vinyl Sticker", ID: 102, Speed: 10, Force: 10, Overcut: 18, - }, - { + } + MediaFilmLables = Media{ Descr: "Film Labels", ID: 106, Speed: 10, Force: 14, Overcut: 18, - }, - { + } + MediaMagneticSheet = Media{ Descr: "Magnetic Sheet", ID: 107, Speed: 10, Force: 12, Overcut: 18, - }, - { + } + MediaThick = Media{ Descr: "Thick Media", ID: 111, Speed: 10, Force: 27, Overcut: 18, - }, - { + } + MediaThin = Media{ Descr: "Thin Media", ID: 112, Speed: 10, Force: 2, Overcut: 18, - }, - { + } + MediaPen = Media{ Descr: "Pen", ID: 113, Speed: 10, Force: 10, Overcut: 0, - }, - { + } + MediaCustom = Media{ Descr: "Custom", ID: 300, Speed: 10, Force: 10, Overcut: 18, - }, -} + } +) @@ -36,9 +36,9 @@ func parsePage() (pa Page) { return pa } -func DrawPic(c *bufio.Writer) { - Landscape.Orientation(c) +func (r Robo) DrawPic() { + //Landscape.Orientation(c) for _, p := range parsePage() { - p.Line(c) + r.Line(p...) } } @@ -1,3 +1,5 @@ +// +build ignore + package robo import ( diff --git a/testpattern.go b/testpattern.go index e9fb235..274ac0f 100644 --- a/testpattern.go +++ b/testpattern.go @@ -1,3 +1,5 @@ +// +build ignore + package robo import "bufio" @@ -15,19 +15,19 @@ type Glyph struct { type Set []Path -func Print(c *bufio.Writer, in io.Reader, scale Unit) { +func (r Robo) Print(in io.Reader, scale Unit) { var off Point scanner := bufio.NewScanner(in) for scanner.Scan() { - font.putchar(c, scanner.Text(), scale, &off) + font.putchar(r, scanner.Text(), scale, &off) } if err := scanner.Err(); err != nil { log.Fatal(err) } } -func (f Font) putchar(c *bufio.Writer, s string, scale Unit, off *Point) { +func (f Font) putchar(r Robo, s string, scale Unit, off *Point) { for _, ch := range s { gl, ok := f[ch] if ok { @@ -35,9 +35,9 @@ func (f Font) putchar(c *bufio.Writer, s string, scale Unit, off *Point) { off.X += height * scale off.Y = 0 } - off.Offset(c) + r.Offset(*off) for _, p := range gl.S { - p.Scale(scale).Line(c) + r.Line(p.Scale(scale)...) //p.Scale(scale).Curve(c, 0) } off.Y += gl.W * scale @@ -44,14 +44,15 @@ type Point struct { X, Y Unit } +func (p Point) Swap() Point { return Point{X: p.Y, Y: p.X} } + func (p Point) String() (s string) { switch orientation { case Portrait: - s = fmt.Sprintf("%v,%v", p.X, p.Y) case Landscape: - s = fmt.Sprintf("%v,%v", p.Y, p.X) + p = p.Swap() } - return + return fmt.Sprintf("%v,%v", p.X, p.Y) } func (p Point) Scale(f Unit) Point { @@ -86,10 +87,10 @@ func (p Path) String() string { return strings.Join(pp, ",") } -func (ph Path) Scale(f Unit) Path { - ret := make(Path, len(ph)) - for i, p := range ph { - ret[i] = p.Scale(f) +func (p Path) Scale(f Unit) Path { + ret := make(Path, len(p)) + for i, pt := range p { + ret[i] = pt.Scale(f) } return ret } |