• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang gxui.Driver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/google/gxui.Driver的典型用法代码示例。如果您正苦于以下问题:Golang Driver类的具体用法?Golang Driver怎么用?Golang Driver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: CreateFont

func CreateFont(size int, driver gxui.Driver) gxui.Font {
	font, err := driver.CreateFont(gxfont.Monospace, size)
	if err != nil {
		panic(err)
	}
	return font
}
开发者ID:dspencerr,项目名称:Go-Open-XML-Parser,代码行数:7,代码来源:gui.go


示例2: appMain

func appMain(driver gxui.Driver) {
	theme := dark.CreateTheme(driver)

	label := theme.CreateLabel()
	label.SetText("This is a progress bar:")

	progressBar := theme.CreateProgressBar()
	progressBar.SetDesiredSize(math.Size{W: 400, H: 20})
	progressBar.SetTarget(100)

	layout := theme.CreateLinearLayout()
	layout.AddChild(label)
	layout.AddChild(progressBar)
	layout.SetHorizontalAlignment(gxui.AlignCenter)

	window := theme.CreateWindow(800, 600, "Progress bar")
	window.SetScale(flags.DefaultScaleFactor)
	window.AddChild(layout)
	window.OnClose(driver.Terminate)

	progress := 0
	pause := time.Millisecond * 500
	var timer *time.Timer
	timer = time.AfterFunc(pause, func() {
		driver.Call(func() {
			progress = (progress + 3) % progressBar.Target()
			progressBar.SetProgress(progress)
			timer.Reset(pause)
		})
	})
}
开发者ID:linux-mac,项目名称:gxui,代码行数:31,代码来源:main.go


示例3: appMain

func appMain(driver gxui.Driver) {
	theme := dark.CreateTheme(driver)
	img := theme.CreateImage()

	// mx := source.Bounds().Max
	// fmt.Println(mx)

	window := theme.CreateWindow(500, 500, "Screenshot")
	size := window.Viewport().SizePixels()
	fmt.Println(size)
	window.SetScale(flags.DefaultScaleFactor)
	window.AddChild(img)

	go func() {
		for {
			source, err := goss.Capture()
			if err != nil {
				fmt.Fprintln(os.Stderr, "Failed to capture screenshot.")
				os.Exit(1)
			}

			rgba := image.NewRGBA(source.Bounds())
			draw.Draw(rgba, source.Bounds(), source, image.ZP, draw.Src)
			texture := driver.CreateTexture(rgba, 1)
			img.SetTexture(texture)
		}
	}()

	window.OnClose(driver.Terminate)
}
开发者ID:ww24,项目名称:goss,代码行数:30,代码来源:main.go


示例4: appMain

func appMain(driver gxui.Driver) {
	theme := dark.CreateTheme(driver)

	window := theme.CreateWindow(ANIMATION_WIDTH, 2*ANIMATION_HEIGHT, "Pendulum")
	window.SetBackgroundBrush(gxui.CreateBrush(gxui.Gray50))

	image := theme.CreateImage()

	ticker := time.NewTicker(time.Millisecond * 15)
	pendulum := &mathematicalPendulum{}
	pendulum2 := &numericalPendulum{PHI_ZERO, 0.0, 0.0, time.Time{}}

	go func() {
		for _ = range ticker.C {
			canvas := driver.CreateCanvas(math.Size{ANIMATION_WIDTH, 2 * ANIMATION_HEIGHT})
			canvas.Clear(gxui.White)

			draw(pendulum, canvas, 0, 0)
			draw(pendulum2, canvas, 0, ANIMATION_HEIGHT)

			canvas.Complete()
			driver.Call(func() {
				image.SetCanvas(canvas)
			})
		}
	}()

	window.AddChild(image)

	window.OnClose(ticker.Stop)
	window.OnClose(driver.Terminate)
}
开发者ID:jefferyyuan,项目名称:RosettaCodeData,代码行数:32,代码来源:animate-a-pendulum.go


示例5: drawWalkPath

//画行走路线
func drawWalkPath(window gxui.Window, theme gxui.Theme, driver gxui.Driver, x1, y1, x2, y2 int64) {
	ps, isWalk := nm.FindPath(nmastar, x1, y1, x2, y2)
	if !isWalk {
		return
	}
	canvas := driver.CreateCanvas(math.Size{W: int(nmj.Width), H: int(nmj.Heigth)})

	var polys []gxui.PolygonVertex
	for i := 0; i < len(ps); i++ {

		polys = append(polys,
			gxui.PolygonVertex{
				Position: math.Point{
					int(ps[i].X),
					int(ps[i].Y),
				}})
	}
	canvas.DrawLines(polys, gxui.CreatePen(2, gxui.Green))

	canvas.Complete()
	image := theme.CreateImage()
	image.SetCanvas(canvas)
	window.AddChild(image)

}
开发者ID:gbember,项目名称:gt,代码行数:26,代码来源:main.go


示例6: appMain

func appMain(driver gxui.Driver) {
	theme := dark.CreateTheme(driver)

	window := theme.CreateWindow(800, 600, "Hi")
	window.SetBackgroundBrush(gxui.CreateBrush(gxui.Gray50))

	fontData, err := ioutil.ReadFile(sysFont("幼圆")) //this font comes from windows
	if err != nil {
		log.Fatalf("error reading font: %v", err)
	}
	font, err := driver.CreateFont(fontData, 50)
	if err != nil {
		panic(err)
	}
	label := theme.CreateLabel()
	label.SetFont(font)
	label.SetColor(gxui.Red50)
	label.SetText("支持一下中文")

	button := theme.CreateButton()
	button.SetText("点我一下")

	window.AddChild(label)
	window.AddChild(button)

	window.OnClose(driver.Terminate)

}
开发者ID:CodyGuo,项目名称:Go-Cody,代码行数:28,代码来源:main.go


示例7: appMain

func appMain(driver gxui.Driver) {
	file := "./img/block.bmp"
	f, err := os.Open(file)
	if err != nil {
		fmt.Printf("Failed to open image '%s': %v\n", file, err)
		os.Exit(1)
	}

	source, _, err := image.Decode(f)
	if err != nil {
		fmt.Printf("Failed to read image '%s': %v\n", file, err)
		os.Exit(1)
	}

	theme := flags.CreateTheme(driver)
	img := theme.CreateImage()

	//mx := source.Bounds().Max
	window := theme.CreateWindow(1000, 1000, "Tetris")
	window.SetScale(flags.DefaultScaleFactor)
	window.AddChild(img)

	rgba := image.NewRGBA(source.Bounds())
	draw.Draw(rgba, source.Bounds(), source, image.ZP, draw.Src)
	texture := driver.CreateTexture(rgba, 1)
	img.SetTexture(texture)

	window.OnClose(driver.Terminate)
}
开发者ID:delaemon,项目名称:go-tetris,代码行数:29,代码来源:tetris.go


示例8: route

func route(driver gxui.Driver, src_id, dest_id int32, src, dest Point3) (canvas gxui.Canvas) {
	defer func() {
		canvas.Complete()
	}()
	canvas = driver.CreateCanvas(math.Size{W: 800, H: 600})
	t0 := time.Now()
	// Phase 1. Use Dijkstra to find shortest path on Triangles
	path := dijkstra.Run(src_id)

	// Phase 2.  construct path indices
	// Check if this path include src & dest
	path_triangle := [][3]int32{triangles[dest_id]}
	prev_id := dest_id
	for {
		cur_id, ok := path[prev_id]
		if !ok {
			return canvas
		}
		path_triangle = append([][3]int32{triangles[cur_id]}, path_triangle...)
		if cur_id == src_id {
			break
		}
		prev_id = cur_id
	}

	// Phase 3. use Navmesh to construct line
	start, end := &Point3{X: src.X, Y: src.Y}, &Point3{X: dest.X, Y: dest.Y}
	nm := NavMesh{}
	trilist := TriangleList{vertices, path_triangle}
	r, _ := nm.Route(trilist, start, end)
	log.Println("navmesh time:", time.Now().Sub(t0))

	var poly []gxui.PolygonVertex
	poly = append(poly,
		gxui.PolygonVertex{
			Position: math.Point{
				int(SCALE_FACTOR * start.X),
				int(SCALE_FACTOR * start.Y),
			}})

	for k := range r.Line {
		poly = append(poly,
			gxui.PolygonVertex{
				Position: math.Point{
					int(SCALE_FACTOR * r.Line[k].X),
					int(SCALE_FACTOR * r.Line[k].Y),
				}})
	}
	poly = append(poly,
		gxui.PolygonVertex{
			Position: math.Point{
				int(SCALE_FACTOR * end.X),
				int(SCALE_FACTOR * end.Y),
			}})

	canvas.DrawLines(poly, gxui.CreatePen(2, gxui.Green))
	return
}
开发者ID:imnotanderson,项目名称:navmesh,代码行数:58,代码来源:main.go


示例9: CreateTheme

func CreateTheme(driver gxui.Driver) gxui.Theme {
	defaultFont, err := driver.CreateFont(gxfont.Default, 12)
	if err == nil {
		defaultFont.LoadGlyphs(32, 126)
	} else {
		fmt.Printf("Warning: Failed to load default font - %v\n", err)
	}

	defaultMonospaceFont, err := driver.CreateFont(gxfont.Monospace, 12)
	if err == nil {
		defaultFont.LoadGlyphs(32, 126)
	} else {
		fmt.Printf("Warning: Failed to load default monospace font - %v\n", err)
	}

	scrollBarRailDefaultBg := gxui.Black
	scrollBarRailDefaultBg.A = 0.7

	scrollBarRailOverBg := gxui.Gray20
	scrollBarRailOverBg.A = 0.7

	neonBlue := gxui.ColorFromHex(0xFF5C8CFF)
	focus := gxui.ColorFromHex(0xA0C4D6FF)

	return &basic.Theme{
		DriverInfo:               driver,
		DefaultFontInfo:          defaultFont,
		DefaultMonospaceFontInfo: defaultMonospaceFont,
		WindowBackground:         gxui.Black,

		//                                   fontColor    brushColor   penColor
		BubbleOverlayStyle:        basic.CreateStyle(gxui.Gray80, gxui.Gray20, gxui.Gray40, 1.0),
		ButtonDefaultStyle:        basic.CreateStyle(gxui.Gray80, gxui.Gray10, gxui.Gray20, 1.0),
		ButtonOverStyle:           basic.CreateStyle(gxui.Gray90, gxui.Gray15, gxui.Gray50, 1.0),
		ButtonPressedStyle:        basic.CreateStyle(gxui.Gray20, gxui.Gray70, gxui.Gray30, 1.0),
		CodeSuggestionListStyle:   basic.CreateStyle(gxui.Gray80, gxui.Gray20, gxui.Gray10, 1.0),
		DropDownListDefaultStyle:  basic.CreateStyle(gxui.Gray80, gxui.Gray10, gxui.Gray20, 1.0),
		DropDownListOverStyle:     basic.CreateStyle(gxui.Gray80, gxui.Gray15, gxui.Gray50, 1.0),
		FocusedStyle:              basic.CreateStyle(gxui.Gray80, gxui.Transparent, focus, 1.0),
		HighlightStyle:            basic.CreateStyle(gxui.Gray80, gxui.Transparent, neonBlue, 2.0),
		LabelStyle:                basic.CreateStyle(gxui.Gray80, gxui.Transparent, gxui.Transparent, 0.0),
		PanelBackgroundStyle:      basic.CreateStyle(gxui.Gray80, gxui.Gray10, gxui.Gray15, 1.0),
		ScrollBarBarDefaultStyle:  basic.CreateStyle(gxui.Gray80, gxui.Gray30, gxui.Gray40, 1.0),
		ScrollBarBarOverStyle:     basic.CreateStyle(gxui.Gray80, gxui.Gray50, gxui.Gray60, 1.0),
		ScrollBarRailDefaultStyle: basic.CreateStyle(gxui.Gray80, scrollBarRailDefaultBg, gxui.Transparent, 1.0),
		ScrollBarRailOverStyle:    basic.CreateStyle(gxui.Gray80, scrollBarRailOverBg, gxui.Gray20, 1.0),
		SplitterBarDefaultStyle:   basic.CreateStyle(gxui.Gray80, gxui.Gray10, gxui.Gray10, 1.0),
		SplitterBarOverStyle:      basic.CreateStyle(gxui.Gray80, gxui.Gray10, gxui.Gray50, 1.0),
		TabActiveHighlightStyle:   basic.CreateStyle(gxui.Gray90, neonBlue, neonBlue, 0.0),
		TabDefaultStyle:           basic.CreateStyle(gxui.Gray80, gxui.Gray30, gxui.Gray40, 1.0),
		TabOverStyle:              basic.CreateStyle(gxui.Gray90, gxui.Gray30, gxui.Gray50, 1.0),
		TabPressedStyle:           basic.CreateStyle(gxui.Gray20, gxui.Gray70, gxui.Gray30, 1.0),
		TextBoxDefaultStyle:       basic.CreateStyle(gxui.Gray80, gxui.Gray10, gxui.Gray20, 1.0),
		TextBoxOverStyle:          basic.CreateStyle(gxui.Gray80, gxui.Gray10, gxui.Gray50, 1.0),
	}
}
开发者ID:langxj,项目名称:gxui,代码行数:56,代码来源:theme.go


示例10: appMain

func appMain(driver gxui.Driver) {
	theme = light.CreateTheme(driver)
	window = theme.CreateWindow(800, 600, "Snake")

	playGround = field.Create(800, 600, 20, 20)
	sn = snake.Create(math.Point{X: 380, Y: 200}, math.Point{X: 380, Y: 280}, 20)

	drawScene(driver)
	fmt.Println(sn.Direction())

	window.OnKeyUp(func(event gxui.KeyboardEvent) {
		dir := sn.Direction()
		key := event.Key

		switch {
		case key == gxui.KeyRight && dir == snake.Top:
			sn.TurnRight()
		case key == gxui.KeyRight && dir == snake.Bottom:
			sn.TurnLeft()
		case key == gxui.KeyLeft && dir == snake.Top:
			sn.TurnLeft()
		case key == gxui.KeyLeft && dir == snake.Bottom:
			sn.TurnRight()
		case key == gxui.KeyUp && dir == snake.Left:
			sn.TurnRight()
		case key == gxui.KeyUp && dir == snake.Right:
			sn.TurnLeft()
		case key == gxui.KeyDown && dir == snake.Left:
			sn.TurnLeft()
		case key == gxui.KeyDown && dir == snake.Right:
			sn.TurnRight()

		}
	})

	ticker := time.NewTicker(time.Millisecond * 200)

	go func() {
		for _ = range ticker.C {
			driver.Call(func() {
				(&sn).Move()
				drawScene(driver)
			})
		}
	}()

	window.OnClose(func() {
		driver.Terminate()
		ticker.Stop()
	})

}
开发者ID:fesenko,项目名称:snake,代码行数:52,代码来源:main.go


示例11: drawScene

func drawScene(driver gxui.Driver) {
	window.RemoveAll()

	canvas = driver.CreateCanvas(math.Size{W: 800, H: 600})

	sn.Draw(canvas)
	playGround.Draw(canvas)

	canvas.Complete()
	image := theme.CreateImage()
	image.SetCanvas(canvas)
	window.AddChild(image)
}
开发者ID:fesenko,项目名称:snake,代码行数:13,代码来源:main.go


示例12: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)
	width := int(nmj.Width)
	height := int(nmj.Heigth)

	window := theme.CreateWindow(width, height, "navmesh")
	canvas := driver.CreateCanvas(math.Size{W: width, H: height})

	ps := nmj.Points

	// mouse
	isStart := true
	x1, y1, x2, y2 := int64(0), int64(0), int64(0), int64(0)

	window.OnMouseDown(func(me gxui.MouseEvent) {
		if nm.IsWalkOfPoint(navmesh.Point{X: int64(me.Point.X), Y: int64(me.Point.Y)}) {
			if isStart {
				x1 = int64(me.Point.X)
				y1 = int64(me.Point.Y)
			} else {
				x2 = int64(me.Point.X)
				y2 = int64(me.Point.Y)
			}
			if !isStart {
				drawWalkPath(window, theme, driver, x1, y1, x2, y2)
			}
			isStart = !isStart
		}
	})

	// draw mesh
	for i := 0; i < len(ps); i++ {
		polys := make([]gxui.PolygonVertex, 0, len(ps[i]))
		for j := 0; j < len(ps[i]); j++ {
			polys = append(polys, gxui.PolygonVertex{
				Position: math.Point{
					int(ps[i][j].X),
					int(ps[i][j].Y),
				}})
		}
		//		canvas.DrawPolygon(polys, gxui.CreatePen(2, gxui.Gray80), gxui.CreateBrush(gxui.Gray40))
		canvas.DrawPolygon(polys, gxui.CreatePen(2, gxui.Red), gxui.CreateBrush(gxui.Yellow))
	}

	canvas.Complete()
	image := theme.CreateImage()
	image.SetCanvas(canvas)
	window.AddChild(image)
	window.OnClose(driver.Terminate)
}
开发者ID:gbember,项目名称:gt,代码行数:50,代码来源:main.go


示例13: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)

	// ┌───────┐║┌───────┐
	// │       │║│       │
	// │   A   │║│   B   │
	// │       │║│       │
	// └───────┘║└───────┘
	// ═══════════════════
	// ┌───────┐║┌───────┐
	// │       │║│       │
	// │   C   │║│   D   │
	// │       │║│       │
	// └───────┘║└───────┘

	ftData, err := ioutil.ReadFile("static/font/simhei.ttf")
	if err != nil {
		log.Println(err)
	}
	ft, err := driver.CreateFont(ftData, 20)
	if err != nil {
		log.Println(err)
	}
	menu := theme.CreateLinearLayout()
	menu.SetDirection(gxui.LeftToRight)
	logo_label := theme.CreateLabel()
	logo_label.SetColor(gxui.White)
	logo_label.SetFont(ft)
	logo_label.SetText("百度盘")
	logo_label.SetSize(math.Size{300, 200})
	menu.AddChild(logo_label)

	splitterCD := theme.CreateSplitterLayout()
	splitterCD.SetOrientation(gxui.Horizontal)
	splitterCD.AddChild(panelHolder("C", theme))
	splitterCD.AddChild(panelHolder("D", theme))

	vSplitter := theme.CreateSplitterLayout()
	vSplitter.SetOrientation(gxui.Vertical)
	vSplitter.AddChild(menu)
	vSplitter.AddChild(splitterCD)

	window := theme.CreateWindow(800, 600, "百度盘")
	window.SetScale(flags.DefaultScaleFactor)
	window.AddChild(vSplitter)
	window.OnClose(driver.Terminate)
}
开发者ID:kelwang,项目名称:godu-pan,代码行数:47,代码来源:ui.go


示例14: Init

func (w *Window) Init(outer WindowOuter, driver gxui.Driver, width, height int, title string) {
	w.Attachable.Init(outer)
	w.BackgroundBorderPainter.Init(outer)
	w.Container.Init(outer)
	w.Paddable.Init(outer)
	w.PaintChildren.Init(outer)
	w.outer = outer
	w.driver = driver

	w.onClose = gxui.CreateEvent(func() {})
	w.onResize = gxui.CreateEvent(func() {})
	w.onMouseMove = gxui.CreateEvent(func(gxui.MouseEvent) {})
	w.onMouseEnter = gxui.CreateEvent(func(gxui.MouseEvent) {})
	w.onMouseExit = gxui.CreateEvent(func(gxui.MouseEvent) {})
	w.onMouseDown = gxui.CreateEvent(func(gxui.MouseEvent) {})
	w.onMouseUp = gxui.CreateEvent(func(gxui.MouseEvent) {})
	w.onMouseScroll = gxui.CreateEvent(func(gxui.MouseEvent) {})
	w.onKeyDown = gxui.CreateEvent(func(gxui.KeyboardEvent) {})
	w.onKeyUp = gxui.CreateEvent(func(gxui.KeyboardEvent) {})
	w.onKeyRepeat = gxui.CreateEvent(func(gxui.KeyboardEvent) {})
	w.onKeyStroke = gxui.CreateEvent(func(gxui.KeyStrokeEvent) {})

	w.onClick = gxui.CreateEvent(func(gxui.MouseEvent) {})
	w.onDoubleClick = gxui.CreateEvent(func(gxui.MouseEvent) {})

	w.focusController = gxui.CreateFocusController(outer)
	w.mouseController = gxui.CreateMouseController(outer, w.focusController)
	w.keyboardController = gxui.CreateKeyboardController(outer)

	w.onResize.Listen(func() {
		w.outer.LayoutChildren()
		w.Draw()
	})

	w.SetBorderPen(gxui.TransparentPen)

	w.setViewport(driver.CreateWindowedViewport(width, height, title))

	// Window starts shown
	w.Attach()

	// Interface compliance test
	_ = gxui.Window(w)
}
开发者ID:4ydx,项目名称:gxui,代码行数:44,代码来源:window.go


示例15: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)

	canvas := driver.CreateCanvas(math.Size{W: 500, H: 300})

	layout := theme.CreateLinearLayout()
	layout.SetSizeMode(gxui.Fill)
	layout.SetDirection(gxui.TopToBottom)

	buttonsLayout := theme.CreateLinearLayout()
	buttonsLayout.SetSizeMode(gxui.Fill)
	buttonsLayout.SetDirection(gxui.LeftToRight)

	button := func(name string, action func()) gxui.Button {
		b := theme.CreateButton()
		b.SetText(name)
		b.OnClick(func(gxui.MouseEvent) { action() })
		return b
	}

	okayButton := button("Okay", func() { log.Println("Okay") })
	buttonsLayout.AddChild(okayButton)
	cancelButton := button("Cancel", func() { log.Println("Cancel") })
	buttonsLayout.AddChild(cancelButton)

	drawPlot(canvas)
	canvas.Complete()

	image := theme.CreateImage()
	image.SetCanvas(canvas)

	window := theme.CreateWindow(800, 600, "bview")
	window.SetBackgroundBrush(gxui.CreateBrush(gxui.Gray50))
	layout.AddChild(buttonsLayout)
	layout.AddChild(image)
	window.AddChild(layout)
	window.OnClose(driver.Terminate)
	window.SetPadding(math.Spacing{L: 10, T: 10, R: 10, B: 10})

	window.OnResize(func() { log.Println(layout.Children().String()) })

}
开发者ID:canejune,项目名称:sandbox,代码行数:42,代码来源:bview.go


示例16: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)
	window := theme.CreateWindow(800, 600, "Polygon")
	window.SetScale(flags.DefaultScaleFactor)

	canvas := driver.CreateCanvas(math.Size{W: 1000, H: 1000})
	drawStar(canvas, math.Point{X: 100, Y: 100}, 50, 0.2, 6)
	drawStar(canvas, math.Point{X: 650, Y: 170}, 70, 0.5, 7)
	drawStar(canvas, math.Point{X: 40, Y: 300}, 20, 0, 5)
	drawStar(canvas, math.Point{X: 410, Y: 320}, 25, 0.9, 5)
	drawStar(canvas, math.Point{X: 220, Y: 520}, 45, 0, 6)

	drawMoon(canvas, math.Point{X: 400, Y: 300}, 200)
	canvas.Complete()

	image := theme.CreateImage()
	image.SetCanvas(canvas)
	window.AddChild(image)

	window.OnClose(driver.Terminate)
}
开发者ID:langxj,项目名称:gxui,代码行数:21,代码来源:main.go


示例17: appMain

func appMain(driver gxui.Driver) {
	theme := dark.CreateTheme(driver)

	canvas := driver.CreateCanvas(math.Size{W: 800, H: 600})

	for i := 0; i < 800; i++ {
		var fy = maths.Sin(float64(i) * (maths.Pi / 180))
		y := (int(fy*100) + 240)
		plot(canvas, i, y)
	}

	canvas.Complete()

	image := theme.CreateImage()
	image.SetCanvas(canvas)

	window := theme.CreateWindow(800, 600, "")
	window.AddChild(image)
	window.OnClose(driver.Terminate)

}
开发者ID:stmuk,项目名称:go-examples,代码行数:21,代码来源:sin_wave.go


示例18: appMain

func appMain(driver gxui.Driver) {
	theme := dark.CreateTheme(driver)
	window := theme.CreateWindow(800, 600, "Polygon")

	container := theme.CreateLinearLayout()

	//	texture := driver.CreateTexture(getImage(cacheDir, tweet.User.ProfileImageURL), 96)
	f, err := os.Open("data/icont19.png")
	if err != nil {
		log.Fatalln(err)
	}
	defer f.Close()
	im, _, err := image.Decode(f)
	if err != nil {
		log.Fatalln(err)
	}

	for i := 0; i < 100; i++ {
		pict := theme.CreateImage()
		texture := driver.CreateTexture(im, 96)
		texture.SetFlipY(true)
		pict.SetTexture(texture)
		pict.SetExplicitSize(math.Size{32, 32})
		pict.SetMargin(math.CreateSpacing(4))
		container.AddChild(pict)
	}

	label := theme.CreateLabel()
	label.SetText("hogehogehoge")
	label.SetMargin(math.CreateSpacing(200))
	container.AddChild(label)

	window.OnClose(driver.Terminate)

	window.AddChild(container)

	gxui.EventLoop(driver)
}
开发者ID:kyokomi-sandbox,项目名称:sandbox,代码行数:38,代码来源:main.go


示例19: appMain

func appMain(driver gxui.Driver) {

	d = driver
	source := image.Image(newMandelbrot())

	theme := flags.CreateTheme(driver)

	mx := source.Bounds().Max

	img = theme.CreateImage()

	window = theme.CreateWindow(mx.X, mx.Y, "Image viewer")
	window.SetScale(flags.DefaultScaleFactor)
	window.AddChild(img)

	rgba := image.NewRGBA(source.Bounds())
	draw.Draw(rgba, source.Bounds(), source, image.ZP, draw.Src)
	texture = driver.CreateTexture(rgba, 1)
	img.SetTexture(texture)

	window.OnClick(windowOnClickHandler)
	window.OnClose(driver.Terminate)
}
开发者ID:rustyoz,项目名称:mandelbrot,代码行数:23,代码来源:mandelbrot.go


示例20: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)

	font, err := driver.CreateFont(gxfont.Default, 75)
	if err != nil {
		panic(err)
	}

	window := theme.CreateWindow(380, 100, "Hi")
	window.SetBackgroundBrush(gxui.CreateBrush(gxui.Gray50))

	label := theme.CreateLabel()
	label.SetFont(font)
	label.SetText("Hello world")

	window.AddChild(label)

	ticker := time.NewTicker(time.Millisecond * 30)
	go func() {
		phase := float32(0)
		for _ = range ticker.C {
			c := gxui.Color{
				R: 0.75 + 0.25*math.Cosf((phase+0.000)*math.TwoPi),
				G: 0.75 + 0.25*math.Cosf((phase+0.333)*math.TwoPi),
				B: 0.75 + 0.25*math.Cosf((phase+0.666)*math.TwoPi),
				A: 0.50 + 0.50*math.Cosf(phase*10),
			}
			phase += 0.01
			driver.Call(func() {
				label.SetColor(c)
			})
		}
	}()

	window.OnClose(ticker.Stop)
	window.OnClose(driver.Terminate)
}
开发者ID:liulnn,项目名称:gxui,代码行数:37,代码来源:main.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gxui.Theme类代码示例发布时间:2022-05-23
下一篇:
Golang gxui.Canvas类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap