本文整理汇总了Golang中github.com/yofu/dxf/drawing.Drawing.Layer方法的典型用法代码示例。如果您正苦于以下问题:Golang Drawing.Layer方法的具体用法?Golang Drawing.Layer怎么用?Golang Drawing.Layer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/yofu/dxf/drawing.Drawing
的用法示例。
在下文中一共展示了Drawing.Layer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ParseLine
// 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
}
示例2: ParseBlock
// ParseBlock parses each BLOCK, which starts with "0\nBLOCK\n" and ends with "0\nENDBLK\n".
func ParseBlock(d *drawing.Drawing, data [][2]string) error {
b := block.NewBlock("", "")
var err error
for _, dt := range data {
switch dt[0] {
case "2":
b.Name = dt[1]
case "1": // 4?
b.Description = dt[1]
case "8":
layer, err := d.Layer(dt[1], false)
if err == nil {
b.SetLayer(layer)
}
case "10":
err = setFloat(dt, func(val float64) { b.Coord[0] = val })
case "20":
err = setFloat(dt, func(val float64) { b.Coord[1] = val })
case "30":
err = setFloat(dt, func(val float64) { b.Coord[2] = val })
case "70":
val, err := strconv.ParseInt(strings.TrimSpace(dt[1]), 10, 64)
if err != nil {
return err
}
b.Flag = int(val)
}
if err != nil {
return err
}
}
return nil
}