Exemple #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]))
	}
}
Exemple #2
0
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))
	}
}
Exemple #3
0
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))
}
Exemple #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]))
		}
	}
}