Exemple #1
0
// ParseLine parses LINE entities.
func ParseLine(d *drawing.Drawing, data [][2]string) (entity.Entity, error) {
	l := entity.NewLine()
	var err error
	for _, dt := range data {
		switch dt[0] {
		default:
			continue
		case "8":
			layer, err := d.Layer(dt[1], false)
			if err == nil {
				l.SetLayer(layer)
			}
		case "10":
			err = setFloat(dt, func(val float64) { l.Start[0] = val })
		case "20":
			err = setFloat(dt, func(val float64) { l.Start[1] = val })
		case "30":
			err = setFloat(dt, func(val float64) { l.Start[2] = val })
		case "11":
			err = setFloat(dt, func(val float64) { l.End[0] = val })
		case "21":
			err = setFloat(dt, func(val float64) { l.End[1] = val })
		case "31":
			err = setFloat(dt, func(val float64) { l.End[2] = val })
		}
		if err != nil {
			return l, err
		}
	}
	return l, nil
}
Exemple #2
0
// Line creates a new LINE from (x1, y1, z1) to (x2, y2, z2).
func (d *Drawing) Line(x1, y1, z1, x2, y2, z2 float64) (*entity.Line, error) {
	l := entity.NewLine()
	l.Start = []float64{x1, y1, z1}
	l.End = []float64{x2, y2, z2}
	l.SetLayer(d.CurrentLayer)
	d.AddEntity(l)
	return l, nil
}