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


Golang GraphicContext.SetStrokeColor方法代码示例

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


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

示例1: draw

func (c circleplot) draw(gc d2d.GraphicContext) {
	for _, cb := range c.boxes {
		x := cb.P.X
		y := cb.P.Y
		gc.SetStrokeColor(black)
		gc.SetFillColor(clear)
		gc.SetLineWidth(1.0)

		lineCircle(gc, x, y, cb.Radius)

		gc.Close()
		gc.FillStroke()

		// Inner shades
		round := traceCircle(len(cb.Colors), x, y, cb.Radius/2.0)

		for i, pos := range round {
			shade := cb.Colors[i]
			prim := c.palette.Get(shade)
			col := color.RGBA{prim.R, prim.G, prim.B, 255}
			gc.SetStrokeColor(col)
			gc.SetFillColor(clear)
			gc.SetLineWidth(1.0)

			lineCircle(gc, pos.X, pos.Y, cb.Radius/10)
			gc.Close()
			gc.FillStroke()
		}
	}
}
开发者ID:johnny-morrice,项目名称:amoebethics,代码行数:30,代码来源:amoerender.go

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

示例3: FillStyle

// FillStyle demonstrates the difference between even odd and non zero winding rule.
func FillStyle(gc draw2d.GraphicContext, x, y, width, height float64) {
	sx, sy := width/232, height/220
	gc.SetLineWidth(width / 40)

	draw2d.Rect(gc, x+sx*0, y+sy*12, x+sx*232, y+sy*70)

	wheel1 := new(draw2d.PathStorage)
	wheel1.ArcTo(x+sx*52, y+sy*70, sx*40, sy*40, 0, 2*math.Pi)
	wheel2 := new(draw2d.PathStorage)
	wheel2.ArcTo(x+sx*180, y+sy*70, sx*40, sy*40, 0, -2*math.Pi)

	gc.SetFillRule(draw2d.FillRuleEvenOdd)
	gc.SetFillColor(color.NRGBA{0, 0xB2, 0, 0xFF})

	gc.SetStrokeColor(image.Black)
	gc.FillStroke(wheel1, wheel2)

	draw2d.Rect(gc, x, y+sy*140, x+sx*232, y+sy*198)
	wheel1 = new(draw2d.PathStorage)
	wheel1.ArcTo(x+sx*52, y+sy*198, sx*40, sy*40, 0, 2*math.Pi)
	wheel2 = new(draw2d.PathStorage)
	wheel2.ArcTo(x+sx*180, y+sy*198, sx*40, sy*40, 0, -2*math.Pi)

	gc.SetFillRule(draw2d.FillRuleWinding)
	gc.SetFillColor(color.NRGBA{0, 0, 0xE5, 0xFF})
	gc.FillStroke(wheel1, wheel2)
}
开发者ID:stanim,项目名称:draw2d,代码行数:28,代码来源:geometry.go

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

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

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

示例7: Main

// Main draws a rotated face of the gopher. Afterwards it returns
// the filename. This should only be used during testing.
func Main(gc draw2d.GraphicContext, ext string) (string, error) {
	gc.SetStrokeColor(image.Black)
	gc.SetFillColor(image.White)
	gc.Save()
	// Draw a (partial) gopher
	gc.Translate(-60, 65)
	gc.Rotate(-30 * (math.Pi / 180.0))
	Draw(gc, 48, 48, 240, 72)
	gc.Restore()

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

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

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

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

示例11: Draw

func (ps *PathSymbolizer) Draw(gc draw2d.GraphicContext, shape geom.Shape) {
	if !ps.Applies(shape) {
		return
	}
	gc.SetStrokeColor(ps.s.Stroke)
	gc.SetLineWidth(ps.s.Weight)
	switch specific := shape.(type) {
	case geom.LineShape:
		l := ps.r.coordsAsPath(specific.Path())
		gc.Stroke(l)
	case geom.MultiLineShape:
		for _, path := range specific.Paths() {
			l := ps.r.coordsAsPath(path)
			gc.Stroke(l)
		}
	}
}
开发者ID:samlecuyer,项目名称:ecumene,代码行数:17,代码来源:symbolizers.go

示例12: FillStroke

// FillStroke first fills and afterwards strokes a path.
func FillStroke(gc draw2d.GraphicContext, x, y, width, height float64) {
	sx, sy := width/210, height/215
	gc.MoveTo(x+sx*113.0, y)
	gc.LineTo(x+sx*215.0, y+sy*215)
	gc.RLineTo(sx*-100, 0)
	gc.CubicCurveTo(x+sx*35, y+sy*215, x+sx*35, y+sy*113, x+sx*113.0, y+sy*113)
	gc.Close()

	gc.MoveTo(x+sx*50.0, y)
	gc.RLineTo(sx*51.2, sy*51.2)
	gc.RLineTo(sx*-51.2, sy*51.2)
	gc.RLineTo(sx*-51.2, sy*-51.2)
	gc.Close()

	gc.SetLineWidth(width / 20.0)
	gc.SetFillColor(color.NRGBA{0, 0, 0xFF, 0xFF})
	gc.SetStrokeColor(image.Black)
	gc.FillStroke()
}
开发者ID:stanim,项目名称:draw2d,代码行数:20,代码来源:geometry.go

示例13: Draw

// Draw a line with an angle with specified line cap and join
func Draw(gc draw2d.GraphicContext, cap draw2d.Cap, join draw2d.Join,
	x0, y0, x1, y1, offset float64) {
	gc.SetLineCap(cap)
	gc.SetLineJoin(join)

	// Draw thick line
	gc.SetStrokeColor(color.NRGBA{0x33, 0x33, 0x33, 0xFF})
	gc.SetLineWidth(30.0)
	gc.MoveTo(x0, y0)
	gc.LineTo((x0+x1)/2+offset, (y0+y1)/2)
	gc.LineTo(x1, y1)
	gc.Stroke()

	// Draw thin helping line
	gc.SetStrokeColor(color.NRGBA{0xFF, 0x33, 0x33, 0xFF})
	gc.SetLineWidth(2.56)
	gc.MoveTo(x0, y0)
	gc.LineTo((x0+x1)/2+offset, (y0+y1)/2)
	gc.LineTo(x1, y1)
	gc.Stroke()
}
开发者ID:stanim,项目名称:draw2d,代码行数:22,代码来源:linecapjoin.go

示例14: FillString

// FillString draws a filled and stroked string.
func FillString(gc draw2d.GraphicContext, x, y, width, height float64) {
	sx, sy := width/100, height/100
	gc.Save()
	gc.SetStrokeColor(image.Black)
	gc.SetLineWidth(1)
	draw2d.RoundRect(gc, x+sx*5, y+sy*5, x+sx*95, y+sy*95, sx*10, sy*10)
	gc.FillStroke()
	gc.SetFillColor(image.Black)
	gc.SetFontSize(height / 6)
	gc.Translate(x+sx*6, y+sy*52)
	gc.SetFontData(draw2d.FontData{
		Name:   "luxi",
		Family: draw2d.FontFamilyMono,
		Style:  draw2d.FontStyleBold | draw2d.FontStyleItalic})
	w := gc.FillString("Hug")
	gc.Translate(w+sx, 0)
	left, top, right, bottom := gc.GetStringBounds("cou")
	gc.SetStrokeColor(color.NRGBA{255, 0x33, 0x33, 0x80})
	draw2d.Rect(gc, left, top, right, bottom)
	gc.SetLineWidth(height / 50)
	gc.Stroke()
	gc.SetFillColor(color.NRGBA{0x33, 0x33, 0xff, 0xff})
	gc.SetStrokeColor(color.NRGBA{0x33, 0x33, 0xff, 0xff})
	gc.SetLineWidth(height / 100)
	gc.StrokeString("Hug")
	gc.Restore()
}
开发者ID:stanim,项目名称:draw2d,代码行数:28,代码来源:geometry.go

示例15: Draw

// Draw "Hello World"
func Draw(gc draw2d.GraphicContext, text string) {
	// Draw a rounded rectangle using default colors
	draw2d.RoundRect(gc, 5, 5, 292, 205, 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.SetDPI(72)
	gc.SetFontSize(14)
	// Display Hello World
	gc.SetStrokeColor(color.NRGBA{0x33, 0xFF, 0x33, 0xFF})
	gc.MoveTo(8, 0)
	gc.LineTo(8, 52)
	gc.LineTo(297, 52)
	gc.Stroke()
	gc.FillString(text)
	gc.FillStringAt(text, 8, 52)

	gc.Save()
	gc.SetFillColor(color.NRGBA{0xFF, 0x33, 0x33, 0xFF})
	gc.SetStrokeColor(color.NRGBA{0xFF, 0x33, 0x33, 0xFF})
	gc.Translate(145, 85)
	gc.StrokeStringAt(text, -50, 0)
	gc.Rotate(math.Pi / 4)
	gc.SetFillColor(color.NRGBA{0x33, 0x33, 0xFF, 0xFF})
	gc.SetStrokeColor(color.NRGBA{0x33, 0x33, 0xFF, 0xFF})
	gc.StrokeString(text)
	gc.Restore()
}
开发者ID:stanim,项目名称:draw2d,代码行数:35,代码来源:helloworld.go


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