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 (x *Imp) Write(N, N1 node.Node, directed, vis, inv bool) { // n, n1 := N.(*node.Imp), N1.(*node.Imp) if inv { _, _, x1, y1, ok := x.pos(n, n1, directed) if !ok { return } scr.InfLineInv(int(x.x), int(x.y), int(x.x1), int(x.y1)) if directed { scr.CircleInv(int(x1), int(y1), r0) } return } b := col.ScreenB if vis { b = Farbe[0] } bx.ColourF(b) if vis { scr.Colour(col.ScreenB) x.aus(n, n, directed) } scr.Colour(b) x.aus(n, n1, directed) }
func (X *Imp) Write(l, c uint) { // r := rep[X.nr] switch format { case Short: switch system { case Life: f, b := r.cf[X.mark], r.cb[X.mark] if X.nr == nothing { f, b = b, f } x, y := int(8*c)+8, int(16*l)+8 scr.Colour(f) scr.Circle(x, y, 6) scr.Circle(x, y, 5) scr.Colour(b) scr.CircleFull(x, y, 2) case Eco: for y := 0; y < Height; y++ { for x := 0; x < Width; x++ { f, b := r.cf[X.mark], r.cb[X.mark] // ! if r.img[y][x] == ' ' { f, b = b, f } scr.Colours(f, b) scr.Point(Width*int(c)/2+x, Height*int(l)+y) } } } case Long: scr.Colour(r.cf[plantNothing]) scr.Write(r.word, l, c) } }
func (x *Imp) Write(aktuell bool) { // if aktuell || x.Linie == linie.Fußweg { scr.Colour(linie.Farbe[x.Linie]) } else { scr.Colour(col.Black) } if aktuell { scr.SetLinewidth(scr.Yetthicker) } else { scr.SetLinewidth(scr.Thin) } }
func write(FZ, B, x, y uint) { // f := col.ActualF for i := uint(0); i < FZ; i++ { switch FZ { case 16: scr.Colour(pattern16[i]) default: scr.Colour(pattern[i]) } scr.RectangleFull(int(x+i*B), int(y), int(x+i*B+B-1), int(y+H-1)) } col.ActualF = f }
func doodle(c col.Colour, n int) { col.ScreenB = c scr.Cls() ker.Msleep(50) col.ScreenB = col.Black scr.Cls() scr.Colour(col.LightGreen) scr.Write("The murus-tool to remove \" \" is going to be executed, i.e.", y0, x0) scr.Write("your disk will be completely reformatted, one moment please ... ", y0+1, x0) doof(y0, 26) const m = 1 << 16 x := str.Clr(m) ok = false for i := 0; i < 10*n; i++ { if i == 0 { go rot(n) } file := pseq.New(x) file.Name(f + strconv.Itoa(i) + ".tmp") file.Clr() file.Ins(x) file.Terminate() } ok = true }
func main() { // scr.Switch(scr.TXT) var today, birthday *Imp today = New() today.Actualize() birthday = New() birthday.SetColours(col.LightWhite, col.Blue) scr.Colour(col.Yellow) scr.Write("Ihr Geburtsdatum:", 12, 0) birthday.Edit(12, 18) if birthday.Empty() { birthday.Actualize() } else { scr.Write(" war ein ", 12, 26) birthday.SetFormat(WD) birthday.Write(12, 35) errh.Error2("Sie sind heute", birthday.Distance(today), "Tage alt.", 0) } scr.Colours(col.ScreenF, col.ScreenB) scr.Cls() errh.Hint(" vor-/rückwärts: Pfeiltasten fertig: Esc ") var ( c kbd.Comm t uint ) neu := true loop: for { if neu { birthday.WriteYear(0, 0) neu = false } switch c, t = kbd.Command(); c { case kbd.Esc: break loop case kbd.Down: if t == 0 { birthday.Inc(Yearly) } else { birthday.Inc(Decadic) } neu = true case kbd.Up: if t == 0 { birthday.Dec(Yearly) } else { birthday.Dec(Decadic) } neu = true case kbd.PrintScr: birthday.PrintYear(0, 0) prt.GoPrint() } } ker.Terminate() }
func (x *Imp) WriteCond(u bool) { // n := 0 if u { n = 1 } scr.Colour(Farbe[n]) bx.ColourF(Farbe[n]) x.write() }
func draw(right bool, c col.Colour, X, Y int) { // scr.Lock() for y := 0; y < H; y++ { for x := 0; x < W; x++ { if car[y][x] == '*' { scr.Colour(c) } else { scr.Colour(col.ScreenB) } if right { scr.Point(X+x, Y+y) } else { scr.Point(X+W-1-x, Y+y) } } } scr.Unlock() }
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 (x *Imp) WriteCond(N, N1 node.Node, directed, aktuell bool) { // n, n1 := N.(*node.Imp), N1.(*node.Imp) f := 0 if aktuell { f = 1 } bx.ColourF(Farbe[f]) // scr.SetLinewidth (scr.Thicker) if !aktuell { scr.Colour(col.ScreenB) x.aus(n, n1, directed) // scr.SetLinewidth (scr.Thin) } scr.Colour(Farbe[f]) x.aus(n, n1, directed) if aktuell { // scr.SetLinewidth (scr.Thin) } }
func (B *Imp) Write() { // scr.Colour(B.cF) var d uint if B.horizontal { scr.Rectangle(int(B.x0), int(B.y0), int(B.x0+B.width), int(B.y0+B.height-1)) d = ((B.width - 1) * B.value) / B.max scr.RectangleFull(int(B.x0), int(B.y0+1), int(B.x0+d), int(B.y0+B.height-2)) scr.Colour(B.cB) if d < B.width-1 { scr.RectangleFull(int(B.x0+d+1), int(B.y0+1), int(B.x0+B.width-1), int(B.y0+B.height-2)) } } else { scr.Rectangle(int(B.x0), int(B.y0), int(B.x0+B.width-1), int(B.y0+B.height)) d = ((B.height - 1) * B.value) / B.max scr.RectangleFull(int(B.x0+1), int(B.y0+B.height-d), int(B.x0+B.width-2), int(B.y0+B.height)) scr.Colour(B.cB) if d < B.height-1 { scr.RectangleFull(int(B.x0+1), int(B.y0+B.height-1-d), int(B.x0+B.width-2), int(B.y0+1)) } } }
func moon(x0 int) { // const r = 40 x, y, y1, ny := x0, r, 0, int(scr.NY()) for y < ny-r { scr.SaveGr(uint(x-r), uint(y-r), uint(x+r), uint(y+r)) scr.Colour(col.Sandgelb) scr.CircleFull(x, y, r) ker.Msleep(33) scr.RestoreGr(uint(x-r), uint(y-r), uint(x+r), uint(y+r)) y1++ y += y1 } }
func (x *Imp) Write(vis, inv bool) { // if inv { scr.CircleInv(int(x.x), int(x.y), x.Radius()) return } b := col.ScreenB if vis { b = Farbe[0] } scr.Colour(b) bx.ColourF(b) x.write() }
func April1st() { col.ScreenF, col.ScreenB = col.White, col.Black scr.Cls() scr.MouseCursor(false) scr.Colour(col.White) scr.Write("Found evil software: \" \"", 7, x0) doof(7, 22) scr.Colour(col.White) scr.Write("Remove (yes/no) ?", y0, x0) b := box.New() b.Wd(3) t := "yes" b.Edit(&t, y0, 23) scr.WarpMouseGr(2*int(scr.NX()), 2*int(scr.NY())) b.Colours(col.LightOrange, col.Black) b.Write("yes", y0, 23) doodle(col.LightWhite, 2) doodle(col.LightWhite, 2) doodle(col.LightYellow, 5) doodle(col.Yellow, 3) doodle(col.LightOrange, 5) doodle(col.Orange, 8) doodle(col.LightRed, 3) // TODO erase all (f + "*.tmp") t = str.Clr(70) scr.Write(t, y0, x0) scr.Write(t, y0+1, x0) col.ScreenF, col.ScreenB = col.LightGreen, col.DarkBlue scr.Cls() scr.Write("The murus-tool has removed \" \" - your disk is reformatted :-)", y0, x0) doof(y0, 28) scr.Colour(col.LightWhite) scr.Write("Please install Linux, TeX, mercurial, Go and murus completely new !", y0+2, x0) ker.Sleep(20) ker.Terminate() }
func (x *Imp) writeEdge(x1 *Imp, u bool) { // n := 0 if u { n = 1 } scr.Colour(Farbe[n]) /* if u { scr.LinienbreiteSetzen (scr.dicker) } else { scr.LinienbreiteSetzen (scr.duenn) } */ scr.InfLine(int(x.x), int(x.y), int(x1.x), int(x1.y)) }
func define(FZ, B uint, C *col.Colour) { // xi, yi := scr.MousePosGr() x, y := uint(xi), uint(yi) x -= X x = x / B if x < FZ && Y <= y && y < Y+H { if FZ == 16 { *C = pattern16[x] } else { *C = pattern[x] } scr.Colour(*C) } else { *C = col.ScreenB } }
func doof(y, x uint) { scr.Colour(col.LightOrange); scr.Write("d(o,o)f", y, x0+x) }
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() }
func (f *Imp) Edit() { // if f.Empty() { scr.Colour(f.colour) f.x, f.y = make([]int, 1), make([]int, 1) f.x[0], f.y[0] = scr.MousePosGr() switch f.sort { case Pointset, Segments, Polygon, Curve: f.editN() case InfLine, Rectangle, Circle, Ellipse: f.edit1() case Text: f.editText() case Image: // ALLOCATE (Imageptr, Groesse()) // img.Get (tx [...], Imageptr) f.editImage() } if f.x == nil { f.Clr() } } else { n := uint(len(f.x)) errh.Error("Figur hat Länge", n) switch f.sort { case Text: f.editText() case Image: f.editImage() default: f.Erase() f.Invert() if true { // f.sort == Curve { for i := uint(0); i < n; i++ { f.mark(i) } } i := f.uM() f.x[i], f.y[i] = scr.MousePosGr() loop: for { scr.MouseCursor(true) c, _ := kbd.Command() switch c { case kbd.Esc: break loop case kbd.Enter, kbd.Tab, kbd.LookFor: f.colour = sel.Colour() case kbd.Here: break loop case kbd.There: i = f.uM() case kbd.Push, kbd.Thither: if i < n { f.Invert() f.mark(i) f.x[i], f.y[i] = scr.MousePosGr() f.mark(i) f.Invert() if c == kbd.Thither { i = n } // ? ? ? } case kbd.This: switch f.sort { case Pointset, Segments, Polygon, Curve: if f.x == nil { f.Clr() } else { for i := uint(0); i < n; i++ { f.mark(i) } f.Erase() n-- // ? ? ? f.Invert() for i := uint(0); i < n; i++ { f.mark(i) } } } } errh.Hint(c.String()) } f.Invert() if true { // sort != Text { for i := uint(0); i < n; i++ { f.mark(i) } } f.Write() } } }
func (f *Imp) editN() { // switch f.sort { case Pointset, Segments, Polygon, Curve: default: return } x0 := make([]int, 2) x0[0] = f.x[0] f.x = x0 y0 := make([]int, 2) y0[0] = f.y[0] f.y = y0 f.x[1], f.y[1] = scr.MousePosGr() f.invertN() var ( K kbd.Comm T uint ) loop: for { K, T = kbd.Command() scr.MouseCursor(true) n := uint(len(f.x)) switch K { case kbd.Esc: break loop case kbd.Go, kbd.Here, kbd.Pull, kbd.Hither, kbd.There, kbd.Push, kbd.Thither, kbd.This: // kbd.ToThis: f.invertN() // if f.sort == Curve { // if n == scr.MaxBezierdegree { break loop } // } if f.sort == Pointset { if K != kbd.Go { n++ } } else { if K == kbd.Here { // TODO Curve: missing n++ } } if K == kbd.This { n := len(f.x) if n == 0 { break loop } else { // TODO n-- if n == 0 { break loop // } else { // x0 = make ([]int, n); copy (x0, f.x[:n]); f.x = x0 // y0 = make ([]int, n); copy (y0, f.y[:n]); f.y = y0 } } } if n > uint(len(f.x)) { x0 = make([]int, n) copy(x0, f.x) f.x = x0 y0 = make([]int, n) copy(y0, f.y) f.y = y0 } f.x[n-1], f.y[n-1] = scr.MousePosGr() f.invertN() if f.sort == Pointset { if K == kbd.Hither { break loop } } else { if K == kbd.Thither { break loop } } } } if f.x == nil { f.Clr() 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) f.filled = T > 0 && f.convex() if f.filled { // scr.PolygonFull (f.x, f.y) // not yet implemented } case Curve: scr.Curve(f.x, f.y) f.filled = T > 0 if f.filled { n := len(f.x) - 1 scr.CircleFull(f.x[n], f.y[n], 4) } } }
func circ(c col.Colour, x, y uint) { // scr.Colour(c) scr.Circle(int(8*x), int(16*y/2), 16*y/2-1) }
func (x *Imp) Remove() { // scr.Colour(col.ScreenB) scr.SetLinewidth(scr.Yetthicker) }
func ausgeben1(a arten, r Richtung, y uint, x uint, f, b col.Colour) { // y0 := (zellengroesse / int(scr.NY1())) * int(y+1) x0 := (zellengroesse / int(scr.NX1())) * int(x) x0 *= int(scr.NX1()) y0 = int(scr.NY1()) * (y0) // * (y0 - 1) if a == nichts { // schneller: scr.Colour(farbeH) scr.RectangleFull(x0+1, y0+1, x0+zellengroesse-2, y0+zellengroesse-1) scr.Colour(randfarbe) scr.Rectangle(x0, y0, x0+zellengroesse-1, y0+zellengroesse-1) } else { // Datenstrukturen zur Beschleunigung der Ausgabe unter X um das 171-fache // durch Reduktion der Aufrufe von X-Routinen von 2 * 32 * 32 = 2048 auf 2 * 6 = 12: const ( n = 6 // Farbzahl zz = zellengroesse * zellengroesse ) var ( nr int zelle [zellengroesse][zellengroesse]int ) for dy := 0; dy < zellengroesse; dy++ { for dx := 0; dx < zellengroesse; dx++ { nr = 0 // farbeH switch bild[a][dy][dx] { case 'o': nr = 1 // F case 'x': nr = 2 // randfarbe case '+': nr = 3 // farbeV case 'k': if Roboterwelt.kloetze(y, x) > 0 { nr = 4 // B } case 'm': if Roboterwelt.markiert(y, x) { nr = 4 // B } case ' ': if a == mauer { nr = 5 // mauerfarbe } else { nr = 0 // farbeH } default: return // stop } if a != einRoboter { r = Nord } switch r { case Nord: zelle[dx][dy] = nr case West: zelle[dy][dx] = nr case Sued: zelle[dx][zellengroesse-1-dy] = nr case Ost: zelle[zellengroesse-1-dy][dx] = nr } } } var ( anzahl [n]int xx, yy [n][zz]int ) for dy := 0; dy < zellengroesse; dy++ { for dx := 0; dx < zellengroesse; dx++ { nr = zelle[dx][dy] xx[nr][anzahl[nr]] = x0 + dx yy[nr][anzahl[nr]] = y0 + dy anzahl[nr]++ } } c := [n]col.Colour{farbeH, f, randfarbe, farbeV, b, mauerfarbe} for i := 0; i < n; i++ { scr.Colour(c[i]) scr.Pointset(xx[i][:], yy[i][:]) } } }