本文整理匯總了Golang中github.com/llgcode/draw2d.GraphicContext.Fill方法的典型用法代碼示例。如果您正苦於以下問題:Golang GraphicContext.Fill方法的具體用法?Golang GraphicContext.Fill怎麽用?Golang GraphicContext.Fill使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/llgcode/draw2d.GraphicContext
的用法示例。
在下文中一共展示了GraphicContext.Fill方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
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)
}
}
}
示例3: 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()
}
示例4: 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()
}
示例5: drawRightFace
func drawRightFace(ctx draw2d.GraphicContext, scale float64, colors []color.Color) {
ctx.SetFillColor(colors[0])
ctx.MoveTo(scale*13.305428, scale*51.540590)
ctx.LineTo(scale*40.343717, scale*72.760901)
ctx.CubicCurveTo(scale*43.734039, scale*75.464962, scale*45.237360, scale*82.490187,
scale*45.767910, scale*86.495547)
ctx.LineTo(scale*49.071660, scale*165.667350)
ctx.CubicCurveTo(scale*49.289247, scale*172.150290, scale*47.781718, scale*176.557160,
scale*44.096549, scale*172.925110)
ctx.LineTo(scale*14.319497, scale*148.460780)
ctx.CubicCurveTo(scale*12.537448, scale*146.848450, scale*11.649146, scale*144.480610,
scale*11.278686, scale*142.076270)
ctx.LineTo(scale*6.684044, scale*55.738325)
ctx.CubicCurveTo(scale*5.914454, scale*51.334595, scale*9.148533, scale*49.897364,
scale*13.305428, scale*51.540590)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[1])
ctx.MoveTo(scale*60.925762, scale*84.484801)
ctx.LineTo(scale*94.440727, scale*110.173380)
ctx.CubicCurveTo(scale*98.484160, scale*113.287130, scale*98.117046, scale*115.753300,
scale*98.906924, scale*122.400750)
ctx.LineTo(scale*99.906265, scale*206.016210)
ctx.CubicCurveTo(scale*100.082290, scale*212.185990, scale*98.954748, scale*216.917160,
scale*94.922195, scale*215.058640)
ctx.LineTo(scale*59.491492, scale*185.322390)
ctx.CubicCurveTo(scale*55.399174, scale*181.448720, scale*54.141798, scale*179.024610,
scale*53.773149, scale*173.562040)
ctx.LineTo(scale*51.281758, scale*92.445638)
ctx.CubicCurveTo(scale*50.977610, scale*83.275467, scale*56.920401, scale*82.791038,
scale*60.925762, scale*84.484801)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[2])
ctx.MoveTo(scale*114.953940, scale*121.045210)
ctx.LineTo(scale*159.771560, scale*153.233820)
ctx.CubicCurveTo(scale*163.559180, scale*156.470830, scale*165.579320, scale*161.453600,
scale*165.851460, scale*169.729030)
ctx.LineTo(scale*165.123240, scale*258.384880)
ctx.CubicCurveTo(scale*165.143180, scale*269.270490, scale*163.081960, scale*270.870600,
scale*159.695010, scale*268.501700)
ctx.LineTo(scale*113.597590, scale*227.818200)
ctx.CubicCurveTo(scale*108.062330, scale*222.322250, scale*108.218040, scale*221.408810,
scale*107.697890, scale*213.179000)
ctx.LineTo(scale*106.780440, scale*131.955830)
ctx.CubicCurveTo(scale*106.253030, scale*119.343540, scale*109.796840, scale*118.294520,
scale*114.953940, scale*121.045210)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[3])
ctx.MoveTo(scale*15.880212, scale*156.133970)
ctx.LineTo(scale*45.353913, scale*181.289430)
ctx.CubicCurveTo(scale*50.303506, scale*186.196870, scale*51.122928, scale*188.031090,
scale*51.146692, scale*194.603600)
ctx.LineTo(scale*55.126981, scale*267.337310)
ctx.CubicCurveTo(scale*55.038091, scale*274.160790, scale*54.210515, scale*276.038730,
scale*50.685456, scale*273.367280)
ctx.LineTo(scale*20.772099, scale*242.788520)
ctx.CubicCurveTo(scale*18.215174, scale*239.755780, scale*17.772229, scale*237.411820,
scale*17.401769, scale*232.926170)
ctx.LineTo(scale*12.455448, scale*161.175690)
ctx.CubicCurveTo(scale*11.924888, scale*156.529920, scale*13.177442, scale*153.868160,
scale*15.880212, scale*156.133970)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[4])
ctx.MoveTo(scale*63.560739, scale*196.668590)
ctx.LineTo(scale*95.849604, scale*224.215480)
ctx.CubicCurveTo(scale*99.860002, scale*227.900360, scale*101.420680, scale*227.848830,
scale*102.248290, scale*236.168620)
ctx.LineTo(scale*105.161150, scale*322.881310)
ctx.CubicCurveTo(scale*105.329610, scale*328.834720, scale*100.635400, scale*326.982890,
scale*97.270450, scale*323.991240)
ctx.LineTo(scale*64.004863, scale*289.914880)
ctx.CubicCurveTo(scale*60.376668, scale*285.922340, scale*60.812901, scale*283.086500,
scale*60.282344, scale*279.081140)
ctx.LineTo(scale*56.974857, scale*203.970330)
ctx.CubicCurveTo(scale*56.534832, scale*197.334610, scale*59.555379, scale*193.983720,
scale*63.560739, scale*196.668590)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[5])
ctx.MoveTo(scale*115.165350, scale*240.136900)
ctx.LineTo(scale*157.390730, scale*278.017180)
ctx.CubicCurveTo(scale*163.353530, scale*283.617540, scale*164.201130, scale*287.753760,
scale*164.337130, scale*292.739150)
ctx.LineTo(scale*164.464830, scale*372.926510)
ctx.CubicCurveTo(scale*164.837100, scale*382.725590, scale*163.118730, scale*386.721700,
scale*158.318310, scale*383.060650)
ctx.LineTo(scale*116.216280, scale*341.592770)
ctx.CubicCurveTo(scale*113.144360, scale*337.418810, scale*111.772190, scale*331.794540,
scale*111.565450, scale*326.252280)
ctx.LineTo(scale*108.059310, scale*249.470500)
ctx.CubicCurveTo(scale*107.834300, scale*242.185660, scale*110.331410, scale*236.363050,
scale*115.165350, scale*240.136900)
//.........這裏部分代碼省略.........
示例6: drawTopFace
func drawTopFace(ctx draw2d.GraphicContext, scale float64, colors []color.Color) {
ctx.SetFillColor(colors[0])
ctx.MoveTo(scale*208.015900, scale*16.168793)
ctx.LineTo(scale*269.753340, scale*6.060053)
ctx.CubicCurveTo(scale*273.758700, scale*5.529493, scale*275.214650, scale*4.917190,
scale*278.801420, scale*6.793998)
ctx.LineTo(scale*322.610240, scale*24.147523)
ctx.CubicCurveTo(scale*325.358840, scale*25.591285, scale*326.141010, scale*26.455624,
scale*322.135640, scale*27.626585)
ctx.LineTo(scale*261.396360, scale*37.422514)
ctx.CubicCurveTo(scale*257.043090, scale*37.934465, scale*249.375710, scale*37.324805,
scale*245.624890, scale*35.579744)
ctx.LineTo(scale*207.698020, scale*19.306437)
ctx.CubicCurveTo(scale*204.242400, scale*18.022573, scale*205.124320, scale*16.294930,
scale*208.015900, scale*16.168793)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[1])
ctx.MoveTo(scale*270.311910, scale*40.717976)
ctx.LineTo(scale*328.466220, scale*30.954512)
ctx.CubicCurveTo(scale*331.510970, scale*29.783553, scale*335.471800, scale*29.045434,
scale*339.489370, scale*31.094387)
ctx.LineTo(scale*389.781750, scale*51.331875)
ctx.CubicCurveTo(scale*394.042420, scale*53.506556, scale*393.023900, scale*54.981242,
scale*389.497210, scale*55.365944)
ctx.LineTo(scale*326.934390, scale*66.861350)
ctx.CubicCurveTo(scale*322.768930, scale*67.712108, scale*315.780670, scale*66.433592,
scale*312.688510, scale*64.669634)
ctx.LineTo(scale*269.272130, scale*44.479849)
ctx.CubicCurveTo(scale*266.461000, scale*43.031581, scale*266.626750, scale*41.728835,
scale*270.311910, scale*40.717976)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[2])
ctx.MoveTo(scale*336.566960, scale*69.287076)
ctx.LineTo(scale*397.636690, scale*58.137148)
ctx.CubicCurveTo(scale*401.086410, scale*57.208951, scale*404.778250, scale*58.130822,
scale*410.425770, scale*60.353676)
ctx.LineTo(scale*464.508550, scale*81.433424)
ctx.CubicCurveTo(scale*470.529060, scale*83.521457, scale*473.468440, scale*87.244831,
scale*469.463070, scale*89.216293)
ctx.LineTo(scale*411.530760, scale*101.470450)
ctx.CubicCurveTo(scale*408.147380, scale*102.502900, scale*397.189320, scale*102.662560,
scale*394.099790, scale*100.667720)
ctx.LineTo(scale*336.105750, scale*74.185386)
ctx.CubicCurveTo(scale*332.764730, scale*71.922386, scale*332.666750, scale*69.986992,
scale*336.566960, scale*69.287076)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[3])
ctx.MoveTo(scale*116.967040, scale*29.014065)
ctx.LineTo(scale*190.193710, scale*18.227759)
ctx.CubicCurveTo(scale*193.076740, scale*17.920153, scale*196.606750, scale*18.927933,
scale*197.950650, scale*19.968175)
ctx.LineTo(scale*231.617500, scale*34.951899)
ctx.CubicCurveTo(scale*234.874040, scale*36.701617, scale*234.418900, scale*38.896015,
scale*231.534230, scale*39.586675)
ctx.LineTo(scale*157.735500, scale*51.255524)
ctx.CubicCurveTo(scale*153.239700, scale*51.961389, scale*146.989730, scale*51.849221,
scale*143.961530, scale*49.794623)
ctx.LineTo(scale*112.967770, scale*33.044845)
ctx.CubicCurveTo(scale*109.396120, scale*31.009309, scale*112.961690, scale*29.864816,
scale*116.967040, scale*29.014065)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[4])
ctx.MoveTo(scale*170.482790, scale*53.739436)
ctx.LineTo(scale*241.651150, scale*41.973692)
ctx.CubicCurveTo(scale*245.656510, scale*41.443135, scale*251.717640, scale*41.248700,
scale*255.130010, scale*43.492950)
ctx.LineTo(scale*298.715100, scale*63.776222)
ctx.CubicCurveTo(scale*302.287560, scale*65.700282, scale*303.169380, scale*68.298399,
scale*299.164020, scale*68.828956)
ctx.LineTo(scale*221.423960, scale*83.385817)
ctx.CubicCurveTo(scale*218.058990, scale*83.916375, scale*210.913850, scale*82.856747,
scale*207.821680, scale*81.092790)
ctx.LineTo(scale*166.350150, scale*58.667629)
ctx.CubicCurveTo(scale*162.777690, scale*56.103179, scale*166.477420, scale*54.269994,
scale*170.482790, scale*53.739436)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[5])
ctx.MoveTo(scale*234.178580, scale*86.640558)
ctx.LineTo(scale*308.088400, scale*72.881494)
ctx.CubicCurveTo(scale*312.093770, scale*72.350935, scale*318.626430, scale*71.610297,
scale*322.839300, scale*74.494959)
ctx.LineTo(scale*380.232970, scale*101.016140)
ctx.CubicCurveTo(scale*382.844840, scale*103.260380, scale*383.275890, scale*107.177310,
scale*379.270530, scale*108.508370)
ctx.LineTo(scale*300.249640, scale*123.424200)
ctx.CubicCurveTo(scale*296.244280, scale*124.755250, scale*290.329430, scale*123.925920,
scale*285.476160, scale*120.881160)
ctx.LineTo(scale*232.466880, scale*92.266536)
ctx.CubicCurveTo(scale*229.374710, scale*90.342477, scale*230.173220, scale*87.971619,
scale*234.178580, scale*86.640558)
//.........這裏部分代碼省略.........
示例7: drawFrontFace
func drawFrontFace(ctx draw2d.GraphicContext, scale float64, colors []color.Color) {
ctx.SetFillColor(colors[0])
ctx.MoveTo(scale*182.178510, scale*158.388410)
ctx.LineTo(scale*273.788920, scale*136.410740)
ctx.CubicCurveTo(scale*277.794270, scale*135.880180, scale*280.165130, scale*138.037180,
scale*280.695680, scale*142.042540)
ctx.LineTo(scale*275.834450, scale*238.474950)
ctx.CubicCurveTo(scale*275.564510, scale*242.320210, scale*270.928300, scale*248.688840,
scale*266.922950, scale*250.340110)
ctx.LineTo(scale*181.549290, scale*272.707500)
ctx.CubicCurveTo(scale*177.543930, scale*273.238060, scale*174.372580, scale*267.403470,
scale*174.322330, scale*263.398110)
ctx.LineTo(scale*174.451510, scale*169.729120)
ctx.CubicCurveTo(scale*174.881550, scale*165.563670, scale*178.333260, scale*160.039680,
scale*182.178510, scale*158.388410)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[1])
ctx.MoveTo(scale*301.533600, scale*130.911780)
ctx.LineTo(scale*381.445870, scale*113.649400)
ctx.CubicCurveTo(scale*386.246530, scale*112.772630, scale*388.765240, scale*113.368590,
scale*388.005160, scale*120.526770)
ctx.LineTo(scale*379.365520, scale*210.847340)
ctx.CubicCurveTo(scale*378.615280, scale*214.532500, scale*378.836500, scale*220.530400,
scale*371.629130, scale*221.701360)
ctx.LineTo(scale*293.604020, scale*243.457870)
ctx.CubicCurveTo(scale*289.598660, scale*243.988420, scale*285.326310, scale*241.085870,
scale*284.795750, scale*237.080520)
ctx.LineTo(scale*289.940140, scale*142.544300)
ctx.CubicCurveTo(scale*290.137030, scale*136.892880, scale*296.598420, scale*132.556810,
scale*301.533600, scale*130.911780)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[2])
ctx.MoveTo(scale*406.907450, scale*110.062680)
ctx.LineTo(scale*473.534830, scale*95.080791)
ctx.CubicCurveTo(scale*479.983350, scale*94.205963, scale*478.799760, scale*98.364434,
scale*478.087960, scale*104.194870)
ctx.LineTo(scale*467.374240, scale*185.580620)
ctx.CubicCurveTo(scale*466.948710, scale*190.262530, scale*463.678950, scale*194.011820,
scale*459.513500, scale*195.663080)
ctx.LineTo(scale*398.568880, scale*214.054370)
ctx.CubicCurveTo(scale*391.807150, scale*215.885320, scale*389.296970, scale*209.675070,
scale*389.566920, scale*205.189420)
ctx.LineTo(scale*398.495680, scale*119.713910)
ctx.CubicCurveTo(scale*398.925730, scale*115.708560, scale*402.902090, scale*111.951730,
scale*406.907450, scale*110.062680)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[3])
ctx.MoveTo(scale*180.403970, scale*283.860000)
ctx.LineTo(scale*263.366350, scale*261.105010)
ctx.CubicCurveTo(scale*267.371700, scale*260.414350, scale*274.529440, scale*262.662370,
scale*274.090350, scale*269.271530)
ctx.LineTo(scale*270.061710, scale*352.515730)
ctx.CubicCurveTo(scale*269.630150, scale*358.628000, scale*262.098910, scale*361.822870,
scale*258.413760, scale*363.314040)
ctx.LineTo(scale*181.857750, scale*388.147890)
ctx.CubicCurveTo(scale*177.852390, scale*388.678450, scale*173.671550, scale*388.186410,
scale*173.133220, scale*383.341780)
ctx.LineTo(scale*173.635250, scale*298.803250)
ctx.CubicCurveTo(scale*173.584990, scale*295.598380, scale*175.906260, scale*285.671360,
scale*180.403970, scale*283.860000)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[4])
ctx.MoveTo(scale*292.972170, scale*253.393720)
ctx.LineTo(scale*369.040340, scale*231.810550)
ctx.CubicCurveTo(scale*373.045690, scale*231.280000, scale*377.680550, scale*234.108220,
scale*377.557150, scale*240.249120)
ctx.LineTo(scale*370.219790, scale*316.723460)
ctx.CubicCurveTo(scale*369.949840, scale*321.529330, scale*364.677580, scale*326.480350,
scale*361.622270, scale*327.497240)
ctx.LineTo(scale*288.849550, scale*352.520860)
ctx.CubicCurveTo(scale*284.644920, scale*354.019550, scale*280.273320, scale*348.357450,
scale*279.742760, scale*344.352090)
ctx.LineTo(scale*283.597730, scale*265.296000)
ctx.CubicCurveTo(scale*283.707570, scale*260.810350, scale*287.829540, scale*255.205080,
scale*292.972170, scale*253.393720)
ctx.Close()
ctx.Fill()
ctx.SetFillColor(colors[5])
ctx.MoveTo(scale*393.257250, scale*226.028330)
ctx.LineTo(scale*459.130590, scale*204.762730)
ctx.CubicCurveTo(scale*463.830180, scale*203.400880, scale*464.561690, scale*207.213150,
scale*464.131650, scale*211.218510)
ctx.LineTo(scale*453.012820, scale*288.384290)
ctx.CubicCurveTo(scale*452.665860, scale*292.487700, scale*451.548370, scale*293.973060,
scale*447.962620, scale*295.542070)
ctx.LineTo(scale*383.523150, scale*317.937580)
ctx.CubicCurveTo(scale*379.272390, scale*318.670880, scale*377.827440, scale*315.821090,
scale*378.333770, scale*310.715990)
ctx.LineTo(scale*385.766580, scale*235.103530)
ctx.CubicCurveTo(scale*386.050770, scale*232.713450, scale*388.879710, scale*227.099910,
scale*393.257250, scale*226.028330)
//.........這裏部分代碼省略.........
示例8: Draw
// Draw a gopher head (not rotated)
func Draw(gc draw2d.GraphicContext, x, y, w, h float64) {
h23 := (h * 2) / 3
blf := color.RGBA{0, 0, 0, 0xff} // black
wf := color.RGBA{0xff, 0xff, 0xff, 0xff} // white
nf := color.RGBA{0x8B, 0x45, 0x13, 0xff} // brown opaque
brf := color.RGBA{0x8B, 0x45, 0x13, 0x99} // brown transparant
brb := color.RGBA{0x8B, 0x45, 0x13, 0xBB} // brown transparant
// round head top
gc.MoveTo(x, y+h*1.002)
gc.CubicCurveTo(x+w/4, y-h/3, x+3*w/4, y-h/3, x+w, y+h*1.002)
gc.Close()
gc.SetFillColor(brb)
gc.Fill()
// rectangle head bottom
draw2d.RoundRect(gc, x, y+h, x+w, y+h+h, h/5, h/5)
gc.Fill()
// left ear outside
draw2d.Circle(gc, x, y+h, w/12)
gc.SetFillColor(brf)
gc.Fill()
// left ear inside
draw2d.Circle(gc, x, y+h, 0.5*w/12)
gc.SetFillColor(nf)
gc.Fill()
// right ear outside
draw2d.Circle(gc, x+w, y+h, w/12)
gc.SetFillColor(brf)
gc.Fill()
// right ear inside
draw2d.Circle(gc, x+w, y+h, 0.5*w/12)
gc.SetFillColor(nf)
gc.Fill()
// left eye outside white
draw2d.Circle(gc, x+w/3, y+h23, w/9)
gc.SetFillColor(wf)
gc.Fill()
// left eye black
draw2d.Circle(gc, x+w/3+w/24, y+h23, 0.5*w/9)
gc.SetFillColor(blf)
gc.Fill()
// left eye inside white
draw2d.Circle(gc, x+w/3+w/24+w/48, y+h23, 0.2*w/9)
gc.SetFillColor(wf)
gc.Fill()
// right eye outside white
draw2d.Circle(gc, x+w-w/3, y+h23, w/9)
gc.Fill()
// right eye black
draw2d.Circle(gc, x+w-w/3+w/24, y+h23, 0.5*w/9)
gc.SetFillColor(blf)
gc.Fill()
// right eye inside white
draw2d.Circle(gc, x+w-(w/3)+w/24+w/48, y+h23, 0.2*w/9)
gc.SetFillColor(wf)
gc.Fill()
// left tooth
gc.SetFillColor(wf)
draw2d.RoundRect(gc, x+w/2-w/8, y+h+h/2.5, x+w/2-w/8+w/8, y+h+h/2.5+w/6, w/10, w/10)
gc.Fill()
// right tooth
draw2d.RoundRect(gc, x+w/2, y+h+h/2.5, x+w/2+w/8, y+h+h/2.5+w/6, w/10, w/10)
gc.Fill()
// snout
draw2d.Ellipse(gc, x+(w/2), y+h+h/2.5, w/6, w/12)
gc.SetFillColor(nf)
gc.Fill()
// nose
draw2d.Ellipse(gc, x+(w/2), y+h+h/7, w/10, w/12)
gc.SetFillColor(blf)
gc.Fill()
}