• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang draw2d.GraphicContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/llgcode/draw2d.GraphicContext的典型用法代码示例。如果您正苦于以下问题:Golang GraphicContext类的具体用法?Golang GraphicContext怎么用?Golang GraphicContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了GraphicContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Main

// Main draws "Hello World" and returns the filename. This should only be
// used during testing.
func Main(gc draw2d.GraphicContext, ext string) (string, error) {
	// Draw hello world
	Draw(gc, fmt.Sprintf("Hello World %d dpi", gc.GetDPI()))

	// Return the output filename
	return samples.Output("helloworld", ext), nil
}
开发者ID:zzn01,项目名称:draw2d,代码行数:9,代码来源:helloworld.go


示例2: drawSnake

func (h *spaceFillingImage) drawSnake(gc draw2d.GraphicContext, snake *draw2d.Path) {
	gc.SetStrokeColor(h.SnakeColor)
	gc.SetLineCap(draw2d.SquareCap)
	gc.SetLineJoin(draw2d.MiterJoin)
	gc.SetLineWidth(2)

	gc.Stroke(snake)
}
开发者ID:google,项目名称:hilbert,代码行数:8,代码来源:demo.go


示例3: UseImageWithContext

// UseImageWithContext specifies both an image
// and a graphic context to create the canvas from.
// The minimum point of the given image
// should probably be 0,0.
func UseImageWithContext(img draw.Image, gc draw2d.GraphicContext) option {
	return func(c *Canvas) uint32 {
		c.img = img
		c.gc = gc
		c.dpi = gc.GetDPI()
		return setsDPI | setsSize
	}
}
开发者ID:zzn01,项目名称:plot,代码行数:12,代码来源:vgimg.go


示例4: lineCircle

func lineCircle(gc d2d.GraphicContext, cx, cy, r float64) {
	count := int(1000.0 * r)

	trace := traceCircle(count, cx, cy, r)

	gc.MoveTo(cx+r, cy)

	for _, pos := range trace {
		gc.LineTo(pos.X, pos.Y)
	}
}
开发者ID:johnny-morrice,项目名称:amoebethics,代码行数:11,代码来源:amoerender.go


示例5: Draw

func (ps *PolygonSymbolizer) Draw(gc draw2d.GraphicContext, shape geom.Shape) {
	if !ps.Applies(shape) {
		return
	}
	if polygon, ok := shape.(geom.PolygonShape); ok {
		gc.SetFillColor(ps.s.Fill)
		for _, path := range polygon.Polygon() {
			l := ps.r.coordsAsPath(path)
			gc.Fill(l)
		}
	}
}
开发者ID:samlecuyer,项目名称:ecumene,代码行数:12,代码来源:symbolizers.go


示例6: draw

func (c squareplot) draw(gc d2d.GraphicContext) {
	for _, cb := range c.boxes {
		gc.SetStrokeColor(black)
		gc.SetFillColor(clear)
		gc.SetLineWidth(1.0)

		side := cb.Radius / 2.0
		lineSquare(gc, cb.P.X, cb.P.Y, side)
		gc.Close()
		gc.FillStroke()
	}
}
开发者ID:johnny-morrice,项目名称:amoebethics,代码行数:12,代码来源:amoerender.go


示例7: Draw

// Draw "Hello World"
func Draw(gc draw2d.GraphicContext, text string) {
	// Draw a rounded rectangle using default colors
	draw2dkit.RoundedRectangle(gc, 5, 5, 135, 95, 10, 10)
	gc.FillStroke()

	// Set the font luximbi.ttf
	gc.SetFontData(draw2d.FontData{Name: "luxi", Family: draw2d.FontFamilyMono, Style: draw2d.FontStyleBold | draw2d.FontStyleItalic})
	// Set the fill text color to black
	gc.SetFillColor(image.Black)
	gc.SetFontSize(14)
	// Display Hello World
	gc.FillStringAt("Hello World", 8, 52)
}
开发者ID:zzn01,项目名称:draw2d,代码行数:14,代码来源:helloworld.go


示例8: Main

// Main draws vertically spaced lines and returns the filename.
// This should only be used during testing.
func Main(gc draw2d.GraphicContext, ext string) (string, error) {
	gc.SetFillRule(draw2d.FillRuleWinding)
	gc.Clear()
	// Draw the line
	for x := 5.0; x < 297; x += 10 {
		Draw(gc, x, 0, x, 210)
	}
	gc.ClearRect(100, 75, 197, 135)
	draw2d.Ellipse(gc, 148.5, 105, 35, 25)
	gc.SetFillColor(color.RGBA{0xff, 0xff, 0x44, 0xff})
	gc.FillStroke()

	// Return the output filename
	return samples.Output("line", ext), nil
}
开发者ID:stanim,项目名称:draw2d,代码行数:17,代码来源:line.go


示例9: drawRectange

func (h *spaceFillingImage) drawRectange(gc draw2d.GraphicContext, px1, py1, px2, py2 float64) {
	gc.SetFillColor(h.BackgroundColor)
	gc.SetStrokeColor(h.GridColor)
	gc.SetLineWidth(1)

	draw2dkit.Rectangle(gc, px1, py1, px2, py2)
	gc.FillStroke()
}
开发者ID:google,项目名称:hilbert,代码行数:8,代码来源:demo.go


示例10: Plot

func Plot(g draw2d.GraphicContext, points []Point) {
	g.MoveTo(0, 0)
	for _, p := range points {
		g.LineTo(p.x*100, p.y*100)
	}
	g.Close()
	g.FillStroke()
}
开发者ID:taysom,项目名称:va,代码行数:8,代码来源:2d.go


示例11: Main

// Main draws the tiger
func Main(gc draw2d.GraphicContext, ext string) (string, error) {
	gc.Save()

	// flip the image
	gc.Translate(0, 200)
	gc.Scale(0.35, -0.35)
	gc.Translate(70, -200)

	// Tiger postscript drawing
	tiger := samples.Resource("image", "tiger.ps", ext)

	// Draw tiger
	Draw(gc, tiger)
	gc.Restore()

	// Return the output filename
	return samples.Output("postscript", ext), nil
}
开发者ID:zzn01,项目名称:draw2d,代码行数:19,代码来源:postscript.go


示例12: Main

// Main draws a left hand and ear of a gopher. Afterwards it returns
// the filename. This should only be used during testing.
func Main(gc draw2d.GraphicContext, ext string) (string, error) {
	gc.Save()
	gc.Scale(0.5, 0.5)
	// Draw a (partial) gopher
	Draw(gc)
	gc.Restore()

	// Return the output filename
	return samples.Output("gopher", ext), nil
}
开发者ID:stanim,项目名称:draw2d,代码行数:12,代码来源:gopher.go


示例13: lineSquare

func lineSquare(gc d2d.GraphicContext, x, y, side float64) {
	xmin, ymin := x-side, y-side
	xmax, ymax := x+side, y+side

	gc.MoveTo(xmin, ymin)
	gc.LineTo(xmin, ymax)
	gc.LineTo(xmax, ymax)
	gc.LineTo(xmax, ymin)
	gc.LineTo(xmin, ymin)
}
开发者ID:johnny-morrice,项目名称:amoebethics,代码行数:10,代码来源:amoerender.go


示例14: drawText

func drawText(gc draw2d.GraphicContext, text string, x, y float64) {
	var fontSize float64 = 14
	fontSizeHeight := fontSize + 14
	if y < fontSizeHeight {
		return
	}
	gc.SetFontData(draw2d.FontData{Name: "luxi", Family: draw2d.FontFamilyMono, Style: draw2d.FontStyleNormal})
	// Set the fill text color to black

	gc.SetFillColor(image.Black)
	gc.SetFontSize(fontSize)
	// 9px width each letter and 2px letter spacing at font-size 14

	var yPos float64
	for ; yPos < y; yPos = yPos + fontSizeHeight {
		gc.FillStringAt(text, x, yPos)
	}
}
开发者ID:SchumacherFM,项目名称:mediamock,代码行数:18,代码来源:record.go


示例15: drawText

func (h *spaceFillingImage) drawText(gc draw2d.GraphicContext, px1, py1 float64, t int) {
	if !h.DrawText {
		return
	}

	text := strconv.Itoa(t)
	_, top, _, _ := gc.GetStringBounds(text)

	gc.SetFillColor(h.TextColor)
	gc.FillStringAt(text, px1+h.TextMargin, py1-top+h.TextMargin)
}
开发者ID:google,项目名称:hilbert,代码行数:11,代码来源:demo.go


示例16: Arc

// Arc draws a link between two points
func Arc(gc draw2d.GraphicContext, x, y1, y2 float64) {
	// Center
	yc := (y1 + y2) / 2
	// x radius
	xRadius := y2 - y1
	// y radius
	yRadius := y2 - yc
	// Start at -45 degrees
	startAngle := -math.Pi / 2
	// 180 degrees = half a circle
	angle := math.Pi
	gc.ArcTo(x, yc, xRadius, yRadius, startAngle, angle)
	gc.Stroke()
	gc.Fill()
}
开发者ID:MaxHalford,项目名称:arcgonaut,代码行数:16,代码来源:arcgonaut.go


示例17: Draw

// Draw a left hand and ear of a gopher using a gc thanks to
// https://github.com/golang-samples/gopher-vector/
func Draw(gc draw2d.GraphicContext) {
	// Initialize Stroke Attribute
	gc.SetLineWidth(3)
	gc.SetLineCap(draw2d.RoundCap)
	gc.SetStrokeColor(color.Black)

	// Left hand
	// <path fill-rule="evenodd" clip-rule="evenodd" fill="#F6D2A2" stroke="#000000" stroke-width="3" stroke-linecap="round" d="
	// M10.634,300.493c0.764,15.751,16.499,8.463,23.626,3.539c6.765-4.675,8.743-0.789,9.337-10.015
	// c0.389-6.064,1.088-12.128,0.744-18.216c-10.23-0.927-21.357,1.509-29.744,7.602C10.277,286.542,2.177,296.561,10.634,300.493"/>
	gc.SetFillColor(color.RGBA{0xF6, 0xD2, 0xA2, 0xff})
	gc.MoveTo(10.634, 300.493)
	gc.RCubicCurveTo(0.764, 15.751, 16.499, 8.463, 23.626, 3.539)
	gc.RCubicCurveTo(6.765, -4.675, 8.743, -0.789, 9.337, -10.015)
	gc.RCubicCurveTo(0.389, -6.064, 1.088, -12.128, 0.744, -18.216)
	gc.RCubicCurveTo(-10.23, -0.927, -21.357, 1.509, -29.744, 7.602)
	gc.CubicCurveTo(10.277, 286.542, 2.177, 296.561, 10.634, 300.493)
	gc.FillStroke()

	// <path fill-rule="evenodd" clip-rule="evenodd" fill="#C6B198" stroke="#000000" stroke-width="3" stroke-linecap="round" d="
	// M10.634,300.493c2.29-0.852,4.717-1.457,6.271-3.528"/>
	gc.MoveTo(10.634, 300.493)
	gc.RCubicCurveTo(2.29, -0.852, 4.717, -1.457, 6.271, -3.528)
	gc.Stroke()

	// Left Ear
	// <path fill-rule="evenodd" clip-rule="evenodd" fill="#6AD7E5" stroke="#000000" stroke-width="3" stroke-linecap="round" d="
	// M46.997,112.853C-13.3,95.897,31.536,19.189,79.956,50.74L46.997,112.853z"/>
	gc.MoveTo(46.997, 112.853)
	gc.CubicCurveTo(-13.3, 95.897, 31.536, 19.189, 79.956, 50.74)
	gc.LineTo(46.997, 112.853)
	gc.Close()
	gc.Stroke()
}
开发者ID:stanim,项目名称:draw2d,代码行数:36,代码来源:gopher.go


示例18: ArcNegative

// ArcNegative draws an arc with a negative angle (anti clockwise).
func ArcNegative(gc draw2d.GraphicContext, xc, yc, width, height float64) {
	xc += width / 2
	yc += height / 2
	radiusX, radiusY := width/2, height/2
	startAngle := 45.0 * (math.Pi / 180.0) /* angles are specified */
	angle := -225 * (math.Pi / 180.0)      /* clockwise in radians */
	gc.SetLineWidth(width / 10)
	gc.SetLineCap(draw2d.ButtCap)
	gc.SetStrokeColor(image.Black)

	gc.ArcTo(xc, yc, radiusX, radiusY, startAngle, angle)
	gc.Stroke()
	// fill a circle
	gc.SetStrokeColor(color.NRGBA{255, 0x33, 0x33, 0x80})
	gc.SetFillColor(color.NRGBA{255, 0x33, 0x33, 0x80})
	gc.SetLineWidth(width / 20)

	gc.MoveTo(xc+math.Cos(startAngle)*radiusX, yc+math.Sin(startAngle)*radiusY)
	gc.LineTo(xc, yc)
	gc.LineTo(xc-radiusX, yc)
	gc.Stroke()

	gc.ArcTo(xc, yc, width/10.0, height/10.0, 0, 2*math.Pi)
	gc.Fill()
}
开发者ID:stanim,项目名称:draw2d,代码行数:26,代码来源:geometry.go


示例19: CurveRectangle

// CurveRectangle draws a rectangle with bezier curves (not rounded rectangle).
func CurveRectangle(gc draw2d.GraphicContext, x0, y0,
	rectWidth, rectHeight float64, stroke, fill color.Color) {
	radius := (rectWidth + rectHeight) / 4

	x1 := x0 + rectWidth
	y1 := y0 + rectHeight
	if rectWidth/2 < radius {
		if rectHeight/2 < radius {
			gc.MoveTo(x0, (y0+y1)/2)
			gc.CubicCurveTo(x0, y0, x0, y0, (x0+x1)/2, y0)
			gc.CubicCurveTo(x1, y0, x1, y0, x1, (y0+y1)/2)
			gc.CubicCurveTo(x1, y1, x1, y1, (x1+x0)/2, y1)
			gc.CubicCurveTo(x0, y1, x0, y1, x0, (y0+y1)/2)
		} else {
			gc.MoveTo(x0, y0+radius)
			gc.CubicCurveTo(x0, y0, x0, y0, (x0+x1)/2, y0)
			gc.CubicCurveTo(x1, y0, x1, y0, x1, y0+radius)
			gc.LineTo(x1, y1-radius)
			gc.CubicCurveTo(x1, y1, x1, y1, (x1+x0)/2, y1)
			gc.CubicCurveTo(x0, y1, x0, y1, x0, y1-radius)
		}
	} else {
		if rectHeight/2 < radius {
			gc.MoveTo(x0, (y0+y1)/2)
			gc.CubicCurveTo(x0, y0, x0, y0, x0+radius, y0)
			gc.LineTo(x1-radius, y0)
			gc.CubicCurveTo(x1, y0, x1, y0, x1, (y0+y1)/2)
			gc.CubicCurveTo(x1, y1, x1, y1, x1-radius, y1)
			gc.LineTo(x0+radius, y1)
			gc.CubicCurveTo(x0, y1, x0, y1, x0, (y0+y1)/2)
		} else {
			gc.MoveTo(x0, y0+radius)
			gc.CubicCurveTo(x0, y0, x0, y0, x0+radius, y0)
			gc.LineTo(x1-radius, y0)
			gc.CubicCurveTo(x1, y0, x1, y0, x1, y0+radius)
			gc.LineTo(x1, y1-radius)
			gc.CubicCurveTo(x1, y1, x1, y1, x1-radius, y1)
			gc.LineTo(x0+radius, y1)
			gc.CubicCurveTo(x0, y1, x0, y1, x0, y1-radius)
		}
	}
	gc.Close()
	gc.SetStrokeColor(stroke)
	gc.SetFillColor(fill)
	gc.SetLineWidth(10.0)
	gc.FillStroke()
}
开发者ID:stanim,项目名称:draw2d,代码行数:48,代码来源:geometry.go


示例20: Dash

// Dash draws a line with a dash pattern
func Dash(gc draw2d.GraphicContext, x, y, width, height float64) {
	sx, sy := width/162, height/205
	gc.SetStrokeColor(image.Black)
	gc.SetLineDash([]float64{height / 10, height / 50, height / 50, height / 50}, -50.0)
	gc.SetLineCap(draw2d.ButtCap)
	gc.SetLineJoin(draw2d.RoundJoin)
	gc.SetLineWidth(height / 50)

	gc.MoveTo(x+sx*60.0, y)
	gc.LineTo(x+sx*60.0, y)
	gc.LineTo(x+sx*162, y+sy*205)
	gc.RLineTo(sx*-102.4, 0.0)
	gc.CubicCurveTo(x+sx*-17, y+sy*205, x+sx*-17, y+sy*103, x+sx*60.0, y+sy*103.0)
	gc.Stroke()
	gc.SetLineDash(nil, 0.0)
}
开发者ID:stanim,项目名称:draw2d,代码行数:17,代码来源:geometry.go



注:本文中的github.com/llgcode/draw2d.GraphicContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang draw2d.PathBuilder类代码示例发布时间:2022-05-23
下一篇:
Golang httpreq.PostForm函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap