func write(p uint) { // if stat[p] == satisfied { scr.Colour(thinkColour) writePlate(p, false) scr.WriteGr(text[stat[p]], xt[p]-12*4, yt[p]-8) img.Get(image[p], uint(xt[p])-50, uint(yt[p])-50) } else { img.Get(image[max], uint(xt[p]-50), uint(yt[p])-50) scr.Colour(colour[p]) writePlate(p, false) scr.WriteGr(text[stat[p]], xt[p]-12*4, yt[p]-8) } switch stat[p] { case satisfied: writePlate(p, true) scr.Colour(notUsedColour) writeFork(left(p)) writeFork(p) case hungry: case starving: case hasRightFork: writeFork(p) case hasLeftFork: writeFork(left(p)) case dining: writePlate(p, true) writeFork(p) writeFork(left(p)) } }
func (f *Imp) Write() { // if f.Empty() { return } scr.Colour(f.colour) switch f.sort { case Pointset: scr.Pointset(f.x, f.y) case Segments: scr.Segments(f.x, f.y) case Polygon: scr.Polygon(f.x, f.y) if f.filled { // scr.PolygonFull (f.x, f.y) // not yet implemented } case Curve: scr.Curve(f.x, f.y) if f.filled { n := len(f.x) - 1 scr.CircleFull(f.x[n], f.y[n], 4) // ? } case InfLine: scr.InfLine(f.x[0], f.y[0], f.x[1], f.y[1]) case Rectangle: if f.filled { scr.RectangleFull(f.x[0], f.y[0], f.x[1], f.y[1]) } else { scr.Rectangle(f.x[0], f.y[0], f.x[1], f.y[1]) } case Circle: if f.filled { scr.CircleFull(f.x[0], f.y[0], uint(f.x[1])) } else { scr.Circle(f.x[0], f.y[0], uint(f.x[1])) } case Ellipse: if f.filled { scr.EllipseFull(f.x[0], f.y[0], uint(f.x[1]), uint(f.y[1])) } else { scr.Ellipse(f.x[0], f.y[0], uint(f.x[1]), uint(f.y[1])) } case Text: bx.Wd(str.ProperLen(f.tx)) bx.ColourF(f.colour) bx.WriteGr(f.tx, f.x[0], f.y[0]) case Image: // if bewegt { // scr.RectangleFullInv (...) // } else { // copy from Imageptr in Framebuffer // } img.Get(f.tx, uint(f.x[0]), uint(f.y[0])) } }
func main() { const a = 100 var p []string = []string{"Anaxagoras", "Aristoteles", "Cicero", "Jemand", "Demokrit", "Diogenes", "Epikur", "Heraklit", "Platon", "Protagoras", "Pythagoras", "Sokrates", "Thales", "Niemand"} var x, y uint for _, s := range p { img.Get(s, x, y) errh.Error(s, 0) if x+2*a < scr.NX() { x += a } else { x = 0 y = a } } errh.Error2("", uint(len(p)), "Philosophen", 0) ker.Terminate() }
func joke(x0, x1, y0, nx1, ny1, x, y, w int, cl col.Colour, s string, b bool) { // h := y + 8 + 1 y1 := y0 + 8*h if b { y1 -= 40 } dr(x0, x0+x*nx1, y0+y*ny1, cl, false) scr.SaveGr(uint(x0+x*nx1), uint(y1), uint(x0+(x+w)*nx1), uint(y1+8*w)) img.Get(s, uint(x0+x*nx1), uint(y1)) t := uint(1) if b { t = 2 } ker.Sleep(t) scr.RestoreGr(uint(x0+x*nx1), uint(y1), uint(x0+(x+w)*nx1), uint(y1+8*w)) if b { w = 2 * w / 3 } dr(x0+(x+w)*nx1, x1, y0+y*ny1, cl, false) }
func main() { // if !scr.MouseEx() { return } var symbol [Nfigure]byte symbol[line] = 'S' // "Strecke" symbol[rectangle] = 'R' // "Rechteck" symbol[circle] = 'K' // "Kreis" symbol[ellipse] = 'E' // "Ellipse" X, Y := 0, 0 X1, Y1 := scr.NX(), scr.NY() // Farbe, Papier:= col.LightWhite, col.Black Farbe, Papier := col.Black, col.LightWhite col.ScreenF, col.ScreenB = Farbe, Papier scr.Cls() paintColour := Farbe scr.Colour(paintColour) // Staerke = 3 bx := box.New() bx.Wd(20) bx.Colours(Papier, Farbe) Name := env.Par(1) if str.Empty(Name) { Name = "temp" } scr.Save(0, 0, 20, 1) for { bx.Edit(&Name, 0, 0) if !str.Empty(Name) { str.RemSpaces(&Name) break } } scr.Restore(0, 0, 20, 1) img.Get(Name, uint(X), uint(Y)) scr.MouseCursor(true) Figur := figure(rectangle) var x, y, x0, y0 int loop: for { scr.Colour(paintColour) Zeichen, Kommando, T := kbd.Read() switch Kommando { case kbd.None: x, y = scr.MousePosGr() scr.SwitchTransparence(true) scr.Write1Gr(Zeichen, x, y-int(scr.NY1())) // scr.WarpMouse (x + scr.NX1(), y) case kbd.Esc: break loop case kbd.Back: switch T { case 0: x, y = scr.MousePosGr() x -= int(scr.NX1()) scr.Colour(Papier) scr.Write1Gr(' ', x, y-int(scr.NY1())) // scr.RectangleFull (x, y - scr.NY1(), x + scr.NX1(), y) // scr.WarpMouseGr (x, y) scr.Colour(paintColour) default: scr.Cls() } /* case kbd.Ins: img.Write (X, Y, X1, Y1 - 16, Name) box.Edit (Feld, Name, scr.Zeilenzahl () - 1, 0) img.Get (X, Y, Name) */ case kbd.Help: paintColour = sel.Colour() // case kbd.LookFor: // Staerke = Strichstaerken.Staerke() case kbd.Enter: if T > 0 { x0, y0 = scr.MousePosGr() // scr.Fill1 (x0, y0) } case kbd.PrintScr: img.Print(uint(X), uint(Y), X1, Y1-16) case kbd.Tab: if T == 0 { if Figur+1 < Nfigure { Figur++ } else { Figur = figure(0) } } else { if Figur > 0 { Figur-- } else { Figur = figure(Nfigure - 1) } } scr.Colours(col.White, Papier) scr.Write1(symbol[Figur], scr.NY()-1, 0) case kbd.Here: x0, y0 = scr.MousePosGr() scr.CircleFull(x0, y0, 3/2) case kbd.Pull: x, y = scr.MousePosGr() scr.Line(x0, y0, x, y) x0, y0 = x, y case kbd.Hither: x, y = scr.MousePosGr() scr.Line(x0, y0, x, y) case kbd.There: x0, y0 = scr.MousePosGr() x, y = x0, y0 case kbd.Push: paint(Figur, inv, x0, y0, x, y) x, y = scr.MousePosGr() paint(Figur, inv, x0, y0, x, y) case kbd.Thither: paint(Figur, inv, x0, y0, x, y) // scr.Colour (paintColour) x, y = scr.MousePosGr() paint(Figur, border, x0, y0, x, y) x0, y0 = x, y case kbd.This: x0, y0 = scr.MousePosGr() x, y = x0, y0 case kbd.Move: scr.LineInv(x0, y0, x, y) x, y = scr.MousePosGr() scr.LineInv(x0, y0, x, y) case kbd.Thus: scr.LineInv(x0, y0, x, y) x, y = scr.MousePosGr() scr.Line(x0, y0, x, y) x0, y0 = x, y } } scr.Save(0, 0, 20, 1) for { bx.Edit(&Name, 0, 0) // TODO make sure, that "Name" is x{x|y} where x is letter, y is digit if !str.Empty(Name) { str.RemSpaces(&Name) break } } scr.Restore(0, 0, 20, 1) img.Put(Name, uint(X), uint(Y), X1, Y1) ker.Terminate() }