Exemplo n.º 1
0
func (p Polygon) Draw(src *draw.Image, im *draw.Image, cameraPos *Point3) {

	//	for i := range p {
	//		if i+1 == len(p) {
	//			(&Line3{p[i], p[0]}).Draw(src, im, cameraPos)
	//		} else {
	//			(&Line3{p[i], p[i+1]}).Draw(src, im, cameraPos)
	//		}
	//	}

	pts := make([]image.Point, 0)
	for _, pt := range p {
		pt2 := pt.ProjectFrom(cameraPos)
		pts = append(pts, image.Point{int(pt2.X), int(pt2.Y)})
	}
	im.FillPoly(pts, 1, 1, 1, src, image.Point{0, 0})
}
Exemplo n.º 2
0
func (l *Line2) Draw(src *draw.Image, i *draw.Image) {
	i.Line(image.Point{int(l.V1.X), int(l.V1.Y)}, image.Point{int(l.V2.X), int(l.V2.Y)},
		1, 1, 1,
		src, image.Point{0, 0})
}