本文整理汇总了Golang中github.com/yofu/dxf/drawing.Drawing类的典型用法代码示例。如果您正苦于以下问题:Golang Drawing类的具体用法?Golang Drawing怎么用?Golang Drawing使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Drawing类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:spyle,项目名称:dxf,代码行数:32,代码来源:parser.go
示例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
}
开发者ID:spyle,项目名称:dxf,代码行数:34,代码来源:parser.go
示例3: ParseEntities
// ParseEntities parses ENTITIES section.
func ParseEntities(d *drawing.Drawing, line int, data [][2]string) error {
tmpdata := make([][2]string, 0)
for i, dt := range data {
if dt[0] == "0" {
if len(tmpdata) > 0 {
e, err := ParseEntity(d, tmpdata)
if err != nil {
return fmt.Errorf("line %d: %s", line+2*i, err.Error())
}
d.AddEntity(e)
tmpdata = make([][2]string, 0)
}
}
tmpdata = append(tmpdata, dt)
}
if len(tmpdata) > 0 {
e, err := ParseEntity(d, tmpdata)
if err != nil {
return fmt.Errorf("line %d: %s", line+2*len(data), err.Error())
}
d.AddEntity(e)
tmpdata = make([][2]string, 0)
}
return nil
}
开发者ID:spyle,项目名称:dxf,代码行数:26,代码来源:parser.go
示例4: ParseLayer
// ParseLayer parses LAYER tables.
func ParseLayer(d *drawing.Drawing, data [][2]string) (table.SymbolTable, error) {
var name string
var flag int
var col color.ColorNumber
var lt *table.LineType
var lw int
for _, dt := range data {
switch dt[0] {
case "2":
name = dt[1]
case "70":
val, err := strconv.ParseInt(strings.TrimSpace(dt[1]), 10, 64)
if err != nil {
return nil, err
}
flag = int(val)
case "62":
val, err := strconv.ParseInt(strings.TrimSpace(dt[1]), 10, 64)
if err != nil {
return nil, err
}
col = color.ColorNumber(val)
case "6":
l, err := d.LineType(dt[1])
if err != nil {
return nil, err
}
lt = l
case "370":
val, err := strconv.ParseInt(strings.TrimSpace(dt[1]), 10, 64)
if err != nil {
return nil, err
}
lw = int(val)
case "390":
// plotstyle
}
}
l := table.NewLayer(name, col, lt)
l.SetFlag(flag)
l.SetLineWidth(lw)
l.SetPlotStyle(d.PlotStyle)
return l, nil
}
开发者ID:spyle,项目名称:dxf,代码行数:45,代码来源:parser.go
注:本文中的github.com/yofu/dxf/drawing.Drawing类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论