當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Canvas.DrawLines方法代碼示例

本文整理匯總了Golang中github.com/google/gxui.Canvas.DrawLines方法的典型用法代碼示例。如果您正苦於以下問題:Golang Canvas.DrawLines方法的具體用法?Golang Canvas.DrawLines怎麽用?Golang Canvas.DrawLines使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/google/gxui.Canvas的用法示例。


在下文中一共展示了Canvas.DrawLines方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: draw

func draw(p Pendulum, canvas gxui.Canvas, x, y int) {
	attachment := math.Point{X: ANIMATION_WIDTH/2 + x, Y: y}

	phi := p.GetPhi()
	ball := math.Point{X: x + ANIMATION_WIDTH/2 + math.Round(float32(l*omath.Sin(phi))), Y: y + math.Round(float32(l*omath.Cos(phi)))}

	line := gxui.Polygon{gxui.PolygonVertex{attachment, 0}, gxui.PolygonVertex{ball, 0}}

	canvas.DrawLines(line, gxui.DefaultPen)

	m := math.Point{int(BALL_RADIUS), int(BALL_RADIUS)}
	rect := math.Rect{ball.Sub(m), ball.Add(m)}
	canvas.DrawRoundedRect(rect, BALL_RADIUS, BALL_RADIUS, BALL_RADIUS, BALL_RADIUS, gxui.TransparentPen, gxui.CreateBrush(gxui.Yellow))
}
開發者ID:jefferyyuan,項目名稱:RosettaCodeData,代碼行數:14,代碼來源:animate-a-pendulum.go

示例2: drawTimeAxis

func drawTimeAxis(canvas gxui.Canvas) {
	p := gxui.Polygon{
		gxui.PolygonVertex{
			Position: math.Point{
				X: 0,
				Y: 400,
			},
			RoundedRadius: 0,
		},
		gxui.PolygonVertex{
			Position: math.Point{
				X: 400,
				Y: 400,
			},
			RoundedRadius: 0,
		},
	}

	canvas.DrawLines(p, gxui.CreatePen(1.0, gxui.White))
}
開發者ID:canejune,項目名稱:sandbox,代碼行數:20,代碼來源:bview.go

示例3: Draw

func (s Snake) Draw(canvas gxui.Canvas) {
	bendCount := len(s.bends)
	p := make(gxui.Polygon, 2+bendCount)

	p[0] = gxui.PolygonVertex{
		Position:      s.head,
		RoundedRadius: 0,
	}

	for i, bend := range s.bends {
		p[i+1] = gxui.PolygonVertex{
			Position:      bend.point,
			RoundedRadius: 0,
		}
	}

	p[bendCount+1] = gxui.PolygonVertex{
		Position:      s.tail,
		RoundedRadius: 0,
	}

	canvas.DrawLines(p, gxui.CreatePen(float32(s.width), gxui.Green70))
}
開發者ID:fesenko,項目名稱:snake,代碼行數:23,代碼來源:snake.go

示例4: drawVerticalLines

func (f Field) drawVerticalLines(canvas gxui.Canvas) {
	for x := f.cellWidth; x < f.width; x += f.cellWidth {
		p := make(gxui.Polygon, 2)

		p[0] = gxui.PolygonVertex{
			Position: math.Point{
				X: x,
				Y: 0,
			},
			RoundedRadius: 0,
		}

		p[1] = gxui.PolygonVertex{
			Position: math.Point{
				X: x,
				Y: f.height,
			},
			RoundedRadius: 0,
		}

		canvas.DrawLines(p, gxui.CreatePen(1, gxui.Gray80))
	}
}
開發者ID:fesenko,項目名稱:snake,代碼行數:23,代碼來源:field.go

示例5: drawHorizontalLines

func (f Field) drawHorizontalLines(canvas gxui.Canvas) {
	for y := f.cellHeight; y < f.height; y += f.cellHeight {
		p := make(gxui.Polygon, 2)

		p[0] = gxui.PolygonVertex{
			Position: math.Point{
				X: 0,
				Y: y,
			},
			RoundedRadius: 0,
		}

		p[1] = gxui.PolygonVertex{
			Position: math.Point{
				X: f.width,
				Y: y,
			},
			RoundedRadius: 0,
		}

		canvas.DrawLines(p, gxui.CreatePen(1, gxui.Gray80))
	}
}
開發者ID:fesenko,項目名稱:snake,代碼行數:23,代碼來源:field.go


注:本文中的github.com/google/gxui.Canvas.DrawLines方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。