本文整理匯總了Golang中github.com/Tradnaiofh/plotinum/vg.Length.Inches方法的典型用法代碼示例。如果您正苦於以下問題:Golang Length.Inches方法的具體用法?Golang Length.Inches怎麽用?Golang Length.Inches使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Tradnaiofh/plotinum/vg.Length
的用法示例。
在下文中一共展示了Length.Inches方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: New
func New(w, h vg.Length) *Canvas {
buf := new(bytes.Buffer)
c := &Canvas{
svg: svgo.New(buf),
w: w,
h: h,
buf: buf,
ht: w.Points(),
stk: []context{context{}},
}
// This is like svg.Start, except it uses floats
// and specifies the units.
fmt.Fprintf(buf, `<?xml version="1.0"?>
<!-- Generated by SVGo and Plotinum VG -->
<svg width="%.*gin" height="%.*gin"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">`+"\n",
pr, w.Inches(), pr, h.Inches())
// Swap the origin to the bottom left.
// This must be matched with a </g> when saving,
// before the closing </svg>.
c.svg.Gtransform(fmt.Sprintf("scale(1, -1) translate(0, -%.*g)", pr, h.Dots(c)))
vg.Initialize(c)
return c
}
示例2: New
// New returns a new image canvas with
// the size specified rounded up to the
// nearest pixel.
func New(width, height vg.Length) *Canvas {
w := width.Inches() * dpi
h := height.Inches() * dpi
img := image.NewRGBA(image.Rect(0, 0, int(w+0.5), int(h+0.5)))
return NewImage(img)
}