Example #1
0
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]))
	}
}
Example #2
0
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))
		}
	}
}
Example #3
0
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 *)
}
Example #4
0
func (f *Imp) edit1() {
	//
	x0 := make([]int, 2)
	x0[0] = f.x[0]
	f.x = x0
	y0 := make([]int, 2)
	y0[0] = f.y[0]
	f.y = y0
	switch f.sort {
	case InfLine:
		if f.x[0] == 0 {
			f.x[1] = 1
		} else {
			f.x[1] = f.x[0] - 1
		}
		f.y[1] = f.y[0]
	case Rectangle:
		f.x[1] = f.x[0]
		f.y[1] = f.y[0]
	case Circle, Ellipse:
		f.x[1] = 0
		f.y[1] = 0
	default:
		return
	}
	//    scr.PointInv (f.x[0], f.y[0])
	f.invert1()
loop:
	for {
		K, T := kbd.Command()
		switch K {
		case kbd.Pull, kbd.Hither:
			f.invert1()
			f.x[1], f.y[1] = scr.MousePosGr()
			switch f.sort {
			case InfLine:
				if f.x[1] == f.x[0] && f.y[1] == f.y[0] {
					if f.x[0] == 0 {
						f.x[1] = 1
					} else {
						f.x[1] = f.x[0] - 1
					}
				}
			case Rectangle:

			case Circle, Ellipse:
				if f.x[1] > f.x[0] {
					f.x[1] -= f.x[0]
				} else {
					f.x[1] = f.x[0] - f.x[1]
				}
				if f.y[1] > f.y[0] {
					f.y[1] -= f.y[0]
				} else {
					f.y[1] = f.y[0] - f.y[1]
				}
				if f.sort == Circle {
					if f.x[1] > f.y[1] {
						f.y[1] = f.x[1]
					} else {
						f.x[1] = f.y[1]
					}
				}
			default:
				// stop (Modul, 1)
			}
			f.invert1()
			if K == kbd.Hither {
				f.filled = T > 0
				break loop
			}
		}
	}
	switch f.sort {
	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, 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]))
		}
	}
}
Example #5
0
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][:])
		}
	}
}