I've been looking into draw
and draw.x11
packages that come with Go. I didn't find out a simple way to draw a line on a X11 window.
Where I can find some simple 2D drawing examples?
I found myself the answer, here it goes a simple example:
package main
import (
"os"
"time"
"image"
"exp/draw/x11"
)
func main() {
win, _ := x11.NewWindow()
color := image.RGBAColor{255, 255, 255, 255}
img := win.Screen()
for i, j := 0, 0; i < 100 && j < 100; i, j = i + 1, j + 1 {
img.Set(i, j, color)
}
win.FlushImage()
time.Sleep(10 * 1000 * 1000 * 1000)
win.Close()
os.Exit(0)
}
While your solution works, I think what you're really looking for is X Go Binding
package main
import (
"fmt"
"code.google.ui/x11" // i'm not sure this is the actual package
"time" // name u better refer the packages
"os"
)
func main() {
win,err := x11.NewWindowArea(600,600) // it creates a window with 600 width&600
if err != nil { // height
fmt.Println(err)
os.Exit(0) // if any err occurs it exits
}
img :=win.Screen // in this newly created screen u cn draw
for i:=0;i<100;i++ { // any thing pixel by pixel
for j:=0;j<100;j++ {
img.Set(0+i,0+j,image.Black) // now this draws a square in the black
} // color oo the created screen
}
win.FlushImage() // its for flushing the image then only new
time.Sleep(time.Second*15) // image cn be draw
}