Pinstripe/Printer: Difference between revisions

Added Go
(Added Go)
Line 47:
NEXT y%
VDU 2,1,12,3</lang>
 
=={{header|Go}}==
{{libheader|Go Graphics}}
{{works with|Windows 10}}
<br>
The code for this task is exactly the same as for [[Pinstripe/Display#Go]] except that some code has been added to dump the image to the default printer.
<lang go>package main
import (
"github.com/fogleman/gg"
"log"
"os/exec"
)
 
var palette = [2]string{
"FFFFFF", // white
"000000", // black
}
func pinstripe(dc *gg.Context) {
w := dc.Width()
h := dc.Height() / 4
for b := 1; b <= 4; b++ {
for x, ci := 0, 0; x < w; x, ci = x+b, ci+1 {
dc.SetHexColor(palette[ci%2])
y := h * (b - 1)
dc.DrawRectangle(float64(x), float64(y), float64(b), float64(h))
dc.Fill()
}
}
}
func main() {
dc := gg.NewContext(900, 600)
pinstripe(dc)
dc.SavePNG("w_pinstripe.png")
cmd := exec.Command("mspaint", "/pt", "w_pinstripe.png")
if err := cmd.Run(); err != nil {
log.Fatal(err)
}
}</lang>
 
=={{header|Liberty BASIC}}==
9,485

edits