Add some very basic examples
This commit is contained in:
		
							parent
							
								
									9dc929f545
								
							
						
					
					
						commit
						c0124bf232
					
				
							
								
								
									
										18
									
								
								examples/blank/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								examples/blank/main.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "image"
 | 
				
			||||||
 | 
					import "git.tebibyte.media/tomo/x"
 | 
				
			||||||
 | 
					import "git.tebibyte.media/tomo/tomo"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func main () {
 | 
				
			||||||
 | 
						tomo.Register(0, x.NewBackend)
 | 
				
			||||||
 | 
						err := tomo.Run(run)
 | 
				
			||||||
 | 
						if err != nil { panic(err) }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func run () {
 | 
				
			||||||
 | 
						window, err := tomo.NewWindow(image.Rect(0, 0, 200, 300))
 | 
				
			||||||
 | 
						if err != nil { panic(err) }
 | 
				
			||||||
 | 
						window.OnClose(tomo.Stop)
 | 
				
			||||||
 | 
						window.SetVisible(true)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										29
									
								
								examples/text/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								examples/text/main.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "image"
 | 
				
			||||||
 | 
					import "image/color"
 | 
				
			||||||
 | 
					import "git.tebibyte.media/tomo/x"
 | 
				
			||||||
 | 
					import "git.tebibyte.media/tomo/tomo"
 | 
				
			||||||
 | 
					import "golang.org/x/image/font/basicfont"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func main () {
 | 
				
			||||||
 | 
						tomo.Register(0, x.NewBackend)
 | 
				
			||||||
 | 
						err := tomo.Run(run)
 | 
				
			||||||
 | 
						if err != nil { panic(err) }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func run () {
 | 
				
			||||||
 | 
						window, err := tomo.NewWindow(image.Rectangle { })
 | 
				
			||||||
 | 
						if err != nil { panic(err) }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						text := tomo.NewTextBox()
 | 
				
			||||||
 | 
						text.SetText("hello, world!")
 | 
				
			||||||
 | 
						text.SetTextColor(color.White)
 | 
				
			||||||
 | 
						text.SetColor(color.Black)
 | 
				
			||||||
 | 
						text.SetFace(basicfont.Face7x13)
 | 
				
			||||||
 | 
						text.SetPadding(tomo.I(8))
 | 
				
			||||||
 | 
						window.SetRoot(text)
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						window.OnClose(tomo.Stop)
 | 
				
			||||||
 | 
						window.SetVisible(true)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user