本文整理匯總了Golang中github.com/llgcode/draw2d.GraphicContext.LineTo方法的典型用法代碼示例。如果您正苦於以下問題:Golang GraphicContext.LineTo方法的具體用法?Golang GraphicContext.LineTo怎麽用?Golang GraphicContext.LineTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/llgcode/draw2d.GraphicContext
的用法示例。
在下文中一共展示了GraphicContext.LineTo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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()
}
示例2: 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()
}
示例3: graticule
func (r *Renderer) graticule(gc draw2d.GraphicContext) {
b := r.m.Bounds()
d2r := math.Pi / 180.
gc.SetFillColor(AlphaHex("#ce4251"))
// iterate over all the latitudes
padding := 20 * d2r
dxy := 0.001
for phi := b[1]; phi > b[3]; phi -= padding {
x, y, _ := r.m.Srs.Forward(b[0], phi)
x, y = r.matrix.TransformPoint(x, y)
gc.MoveTo(phi, b[0])
for lam := b[0] + dxy; lam < b[2]; lam += dxy {
x, y, _ = r.m.Srs.Forward(lam, phi)
x, y = r.matrix.TransformPoint(x, y)
gc.LineTo(x, y)
}
gc.Stroke()
}
for lam := b[0]; lam <= b[2]; lam += padding {
x, y, _ := r.m.Srs.Forward(lam, b[1])
x, y = r.matrix.TransformPoint(x, y)
gc.MoveTo(lam, b[1])
for phi := b[1] + dxy; phi >= b[3]; phi -= dxy {
x, y, _ = r.m.Srs.Forward(lam, phi)
x, y = r.matrix.TransformPoint(x, y)
gc.LineTo(x, y)
}
gc.Stroke()
}
}
示例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()
}
示例5: 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()
}
示例6: 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)
}
示例7: 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)
}
}
示例8: Star
// Star draws many lines from a center.
func Star(gc draw2d.GraphicContext, x, y, width, height float64) {
gc.Save()
gc.Translate(x+width/2, y+height/2)
gc.SetLineWidth(width / 40)
for i := 0.0; i < 360; i = i + 10 { // Go from 0 to 360 degrees in 10 degree steps
gc.Save() // Keep rotations temporary
gc.Rotate(i * (math.Pi / 180.0)) // Rotate by degrees on stack from 'for'
gc.MoveTo(0, 0)
gc.LineTo(width/2, 0)
gc.Stroke()
gc.Restore()
}
gc.Restore()
}
示例9: 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()
}
示例10: 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)
}
示例11: 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()
}
示例12: CubicCurve
// CubicCurve draws a cubic curve with its control points.
func CubicCurve(gc draw2d.GraphicContext, x, y, width, height float64) {
sx, sy := width/162, height/205
x0, y0 := x, y+sy*100.0
x1, y1 := x+sx*75, y+sy*205
x2, y2 := x+sx*125, y
x3, y3 := x+sx*205, y+sy*100
gc.SetStrokeColor(image.Black)
gc.SetFillColor(color.NRGBA{0xAA, 0xAA, 0xAA, 0xFF})
gc.SetLineWidth(width / 10)
gc.MoveTo(x0, y0)
gc.CubicCurveTo(x1, y1, x2, y2, x3, y3)
gc.Stroke()
gc.SetStrokeColor(color.NRGBA{0xFF, 0x33, 0x33, 0x88})
gc.SetLineWidth(width / 20)
// draw segment of curve
gc.MoveTo(x0, y0)
gc.LineTo(x1, y1)
gc.LineTo(x2, y2)
gc.LineTo(x3, y3)
gc.Stroke()
}
示例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()
}
示例14: drawBackground
func drawBackground(ctx draw2d.GraphicContext, scale float64) {
ctx.SetFillColor(color.RGBA{0, 0, 0, 0xff})
ctx.MoveTo(scale*11.990545, scale*44.171840)
ctx.LineTo(scale*95.535232, scale*31.131780)
ctx.CubicCurveTo(scale*98.081930, scale*30.656558, scale*103.345620,
scale*32.728518, scale*104.703640, scale*34.460855)
ctx.CubicCurveTo(scale*104.061640, scale*32.551663, scale*106.363050,
scale*29.397183, scale*108.890890, scale*28.733281)
ctx.LineTo(scale*190.738900, scale*17.118886)
ctx.CubicCurveTo(scale*193.333050, scale*16.619595, scale*196.447530,
scale*17.641259, scale*198.761490, scale*19.103199)
ctx.CubicCurveTo(scale*198.459060, scale*18.215170, scale*199.757620,
scale*16.526638, scale*202.056810, scale*16.078885)
ctx.LineTo(scale*266.470780, scale*5.596570)
ctx.CubicCurveTo(scale*269.916580, scale*4.989706, scale*275.757580,
scale*4.023428, scale*279.377290, scale*5.807541)
ctx.LineTo(scale*328.994430, scale*25.448971)
ctx.CubicCurveTo(scale*331.366920, scale*26.641237, scale*331.978300,
scale*28.233753, scale*331.068740, scale*29.986371)
ctx.CubicCurveTo(scale*332.213790, scale*28.563663, scale*336.480800,
scale*28.421758, scale*338.586460, scale*29.560657)
ctx.LineTo(scale*397.816620, scale*52.989911)
ctx.CubicCurveTo(scale*399.922280, scale*53.915343, scale*400.266830,
scale*55.401127, scale*399.570730, scale*56.726810)
ctx.CubicCurveTo(scale*401.222770, scale*55.731036, scale*405.276310,
scale*55.855966, scale*408.369250, scale*57.101598)
ctx.LineTo(scale*477.845850, scale*84.373262)
ctx.CubicCurveTo(scale*480.769450, scale*86.058786, scale*482.447750,
scale*89.555639, scale*482.201520, scale*93.392117)
ctx.LineTo(scale*469.349560, scale*192.524630)
ctx.CubicCurveTo(scale*468.858040, scale*194.455440, scale*466.611800,
scale*196.499460, scale*464.648580, scale*196.788750)
ctx.CubicCurveTo(scale*466.232550, scale*197.134640, scale*467.929720,
scale*199.065450, scale*467.872170, scale*200.826450)
ctx.LineTo(scale*455.586260, scale*293.675910)
ctx.CubicCurveTo(scale*455.245690, scale*295.380300, scale*452.923980,
scale*298.103570, scale*451.451330, scale*298.562670)
ctx.CubicCurveTo(scale*452.733400, scale*298.927440, scale*453.902280,
scale*300.424280, scale*453.769250, scale*301.694710)
ctx.LineTo(scale*442.049370, scale*382.487510)
ctx.CubicCurveTo(scale*441.850010, scale*384.876280, scale*440.122330,
scale*388.397130, scale*438.055030, scale*389.144390)
ctx.LineTo(scale*369.192450, scale*418.103260)
ctx.CubicCurveTo(scale*367.672330, scale*418.812770, scale*364.906920,
scale*418.786440, scale*362.933960, scale*417.458200)
ctx.CubicCurveTo(scale*362.432710, scale*419.733770, scale*360.640940,
scale*421.150550, scale*359.177420, scale*421.954410)
ctx.LineTo(scale*277.567550, scale*455.055080)
ctx.CubicCurveTo(scale*275.839870, scale*456.028750, scale*271.207630,
scale*454.455240, scale*269.706370, scale*453.560970)
ctx.CubicCurveTo(scale*270.790040, scale*454.874260, scale*267.622030,
scale*460.044680, scale*265.988690, scale*460.508910)
ctx.LineTo(scale*179.489770, scale*495.063540)
ctx.CubicCurveTo(scale*176.235420, scale*496.727830, scale*169.131990,
scale*496.920420, scale*164.971970, scale*493.263930)
ctx.LineTo(scale*114.856600, scale*435.258830)
ctx.CubicCurveTo(scale*113.715460, scale*434.262730, scale*112.228330,
scale*431.113330, scale*112.841920, scale*430.173830)
ctx.CubicCurveTo(scale*111.663050, scale*430.366410, scale*109.861530,
scale*429.936350, scale*108.343030, scale*428.487410)
ctx.LineTo(scale*65.510165, scale*378.237080)
ctx.CubicCurveTo(scale*64.444502, scale*376.825890, scale*62.706615,
scale*374.042170, scale*63.628113, scale*373.661510)
ctx.CubicCurveTo(scale*62.518512, scale*373.479850, scale*60.798671,
scale*373.820260, scale*59.355648, scale*372.144910)
ctx.LineTo(scale*23.724535, scale*329.873400)
ctx.CubicCurveTo(scale*22.079585, scale*328.373510, scale*21.340299,
scale*326.420780, scale*21.167054, scale*324.354850)
ctx.LineTo(scale*16.345410, scale*249.213300)
ctx.CubicCurveTo(scale*16.058958, scale*246.770010, scale*18.149875,
scale*245.798410, scale*20.014377, scale*245.619280)
ctx.CubicCurveTo(scale*18.407161, scale*244.308070, scale*16.120698,
scale*242.317610, scale*15.758773, scale*239.308270)
ctx.LineTo(scale*10.710713, scale*154.204410)
ctx.CubicCurveTo(scale*10.688412, scale*151.836590, scale*12.024608,
scale*150.261220, scale*13.587221, scale*149.365100)
ctx.CubicCurveTo(scale*11.376230, scale*148.582190, scale*10.184112,
scale*146.554000, scale*9.671242, scale*143.959760)
ctx.LineTo(scale*4.509975, scale*58.516275)
ctx.CubicCurveTo(scale*3.995835, scale*53.080715, scale*3.981734,
scale*46.348545, scale*11.990545, scale*44.171840)
ctx.Close()
ctx.Fill()
}
示例15: 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()
}