当前位置: 首页>>代码示例>>Golang>>正文


Golang GraphicContext.ArcTo方法代码示例

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


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

示例1: 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

示例2: PathTransform

// PathTransform scales a path differently in horizontal and vertical direction.
func PathTransform(gc draw2d.GraphicContext, x, y, width, height float64) {
	gc.Save()
	gc.SetLineWidth(width / 10)
	gc.Translate(x+width/2, y+height/2)
	gc.Scale(1, 4)
	gc.ArcTo(0, 0, width/8, height/8, 0, math.Pi*2)
	gc.Close()
	gc.Stroke()
	gc.Restore()
}
开发者ID:stanim,项目名称:draw2d,代码行数:11,代码来源:geometry.go

示例3: Draw

// Draw the droid on a certain position.
func Draw(gc draw2d.GraphicContext, x, y float64) {
	// set the fill and stroke color of the droid
	gc.SetFillColor(color.RGBA{0x44, 0xff, 0x44, 0xff})
	gc.SetStrokeColor(color.RGBA{0x44, 0x44, 0x44, 0xff})

	// set line properties
	gc.SetLineCap(draw2d.RoundCap)
	gc.SetLineWidth(5)

	// head
	gc.MoveTo(x+30, y+70)
	gc.ArcTo(x+80, y+70, 50, 50, 180*(math.Pi/180), 180*(math.Pi/180))
	gc.Close()
	gc.FillStroke()
	gc.MoveTo(x+60, y+25)
	gc.LineTo(x+50, y+10)
	gc.MoveTo(x+100, y+25)
	gc.LineTo(x+110, y+10)
	gc.Stroke()

	// left eye
	draw2dkit.Circle(gc, x+60, y+45, 5)
	gc.FillStroke()

	// right eye
	draw2dkit.Circle(gc, x+100, y+45, 5)
	gc.FillStroke()

	// body
	draw2dkit.RoundedRectangle(gc, x+30, y+75, x+30+100, y+75+90, 10, 10)
	gc.FillStroke()
	draw2dkit.Rectangle(gc, x+30, y+75, x+30+100, y+75+80)
	gc.FillStroke()

	// left arm
	draw2dkit.RoundedRectangle(gc, x+5, y+80, x+5+20, y+80+70, 10, 10)
	gc.FillStroke()

	// right arm
	draw2dkit.RoundedRectangle(gc, x+135, y+80, x+135+20, y+80+70, 10, 10)
	gc.FillStroke()

	// left leg
	draw2dkit.RoundedRectangle(gc, x+50, y+150, x+50+20, y+150+50, 10, 10)
	gc.FillStroke()

	// right leg
	draw2dkit.RoundedRectangle(gc, x+90, y+150, x+90+20, y+150+50, 10, 10)
	gc.FillStroke()
}
开发者ID:zzn01,项目名称:draw2d,代码行数:51,代码来源:android.go

示例4: 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


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