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) 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 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) aus(n, n1 *node.Imp, directed bool) { // x0, y0, x1, y1, ok := x.pos(n, n1, directed) if !ok { return } scr.InfLine(int(x.x), int(x.y), int(x.x1), int(x.y1)) if directed { scr.CircleFull(int(x1), int(y1), r0) } if zk > 0 && WithValues { T := nat.StringFmt(x.val, zk, false) bx.WriteGr(T, int(x0), int(y0)) } }
func (x *Imp) write() { // r := x.Radius() /* if r <= R0 { scr.CircleFull (int(x.x), int(x.y), R0) } else { for n:= uint(0); n <= 1; n++ { scr.Circle (int(x.x), int(x.y), r + n) } } */ if x.length > 0 { n := str.ProperLen(x.name) xx := x.x - (n*scr.NX1())/2 + 1 yy := x.y - scr.NY1()/2 + 1 switch x.lab { case zentral: case rechts: xx = x.x + scr.NX1() + 1 case oben: yy -= 5 * scr.NY1() / 6 case links: xx = x.x - n*scr.NX1() - scr.NX1() + 1 case unten: yy += 5 * scr.NY1() / 6 } bx.SetTransparent(transparent) bx.Wd(x.length) bx.WriteGr(x.name, int(xx), int(yy)) } if r <= R0 { scr.CircleFull(int(x.x), int(x.y), R0) } else { for n := uint(0); n <= 1; n++ { scr.Circle(int(x.x), int(x.y), r+n) } } }
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 paint(f figure, fo format, x0, y0, x, y int) { // var a, b uint if x >= x0 { a = uint(x - x0) } else { a = uint(x0 - x) } if y >= y0 { b = uint(y - y0) } else { b = uint(y0 - y) } switch f { case line: switch fo { case border: scr.Line(x0, y0, x, y) case inv: scr.LineInv(x0, y0, x, y) case full: // scr.StrichAusgeben (x0, y0, x, y, Staerke) } case rectangle: switch fo { case border: scr.Rectangle(x0, y0, x, y) case inv: scr.RectangleInv(x0, y0, x, y) case full: scr.RectangleFull(x0, y0, x, y) } case circle: if b > a { a = b } switch fo { case border: scr.Circle(x0, y0, a) case inv: scr.CircleInv(x0, y0, a) case full: scr.CircleFull(x0, y0, a) } case ellipse: switch fo { case border: /* scr.Ellipse ((x0 + x) / 2, (y0 + y) / 2, a, b) case invers: scr.EllipseInv ((x0 + x) / 2, (y + y0) / 2, a, b) case full: scr.EllipseFull ((x0 + x) / 2, (y0 + y) / 2, a, b) */ scr.Ellipse(x0, y0, a, b) case inv: scr.EllipseInv(x0, y0, a, b) case full: scr.EllipseFull(x0, y0, a, b) } } // scr.Colour (paintColour), (* Wörkeraund: Bildschirm....Invertieren f *) }
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 (x *Imp) Write(aktuell bool) { // xx, yy := scale.Scale(x.breite, x.länge) lw := scr.ActLinewidth() scr.SetLinewidth(scr.Thin) if aktuell { scr.Colours(linie.Farbe[x.linie], col.ScreenB) } else { // umstieg scr.Colours(col.Black, col.ScreenB) } const r = 2 if xx >= r && yy >= r { scr.Circle(xx, yy, r) // scr.Colour (col.ScreenB) scr.CircleFull(xx, yy, r-1) } scr.SetLinewidth(lw) n := int(str.ProperLen(x.name)) if n <= 2 { return } n1 := int(str.ProperLen(x.name1)) if n1 > n { n = n1 } xn, yn := 0, 0 w, h := int(scr.NX1()), int(scr.NY1()) switch x.beschriftung { case 'r': xn = xx + w + 1 if n1 == 0 { yn = yy - h/2 } else { yn = yy - h } case 'o': xn = xx - (n*w)/2 + 1 if n1 == 0 { yn = yy - h - 1 } else { yn = yy - 2*h - 1 } case 'l': xn = xx - n*w - w + 1 if n1 == 0 { yn = yy - h/2 } else { yn = yy - h } case 'u': xn = xx - (n*w)/2 + 1 yn = yy + h/2 - 2 default: xn = xx - (n*w)/2 + 1 if n1 == 0 { yn = yy - h/2 } else { yn = yy - h } } xxx := x.name for i := uint(0); i < uint(len(xxx)); i++ { if xxx[i] == '_' { str.Replace(&xxx, i, ' ') } } xxx1 := x.name1 for i := uint(0); i < uint(len(xxx1)); i++ { if xxx1[i] == '_' { str.Replace(&xxx1, i, ' ') } } if aktuell { scr.Colours(linie.Farbe[x.linie], col.ScreenB) } else { // umstieg scr.Colours(col.Black, col.ScreenB) scr.Colours(col.Black, col.Pink) } scr.WriteGr(xxx, xn, yn) scr.WriteGr(xxx1, xn, yn+h+0) }