本文整理匯總了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
}