//http://localhost:12347/picky func main() { g := gx.OpenGraphics("key") b := make([]byte, 2) for { time.Sleep(50 * time.Millisecond) n, err := g.Read(b) fmt.Println(n, err, b) } g.Close() }
//http://localhost:4242/test func main() { var pts []Point randsrc = rand.New(rand.NewSource(0)) g := gx.OpenGraphics("test") x, y, m := 0, 0, 0 paint := true redraw(g, pts) g.Flush() for { time.Sleep(50*time.Millisecond) k := g.ReadKeyPress() if k != Nul { fmt.Printf("Read Key %c\t||\t", k) } g.ReadMouse(&x, &y, &m) if m == 1 { paint = true pts = append(pts, Point{x, y}) fmt.Printf("Mouse x: %d y: %d m: %d\t||\t", x, y, m) } else if m == 2 { pts = nil paint = true } else if m == 3 { break } else if m==0 && paint { paint = false pts = append(pts, Point{-1, -1}) //insert stop } if paint { g.SetPenCol(gx.BLACK, 1.0) g.SetPenWidth(1) g.SetFillCol(gx.BLACK, 1.0) redraw(g, pts) g.SetPenCol(gx.BLACK, 1.0) g.SetPenWidth(30) g.SetFillCol(gx.BLACK, 1.0) g.PosText(x+30, y+30, -math.Pi/4) fmt.Fprintf(g, "[%d, %d]", x, y) fmt.Fprintf(g, "\n") fmt.Fprintf(g, "pelota\n") fmt.Fprintf(g, "123456789") g.SetPenWidth(1) g.SetPenCol(gx.YELLOW, 1.0) g.SetFillCol(gx.BLUE, 0.5) g.Ellipse(x, y, 30, 25, math.Pi*float32(m)/3.0) g.SetPenCol(gx.BLACK, 1.0) g.SetFillCol(gx.BLACK, 0.5) g.Ellipse(x+30, y+30, 2, 2, 0.0) g.Flush() } } g.Close() }
func xgopen() { t1 := tfetch(int(pop32())) ip := popslice(u32sz) name := popn(int(t1.sz)) g := gx.OpenGraphics(name) if g == nil { panic("unable to open graphx") } i := xbgopen(g) err := pbytes.MarshalBinary(ip, i) if err != nil { panic("gopen marshal") } urlopen("http://localhost:4242/" + name) }