Пример #1
0
func main() {
	t := throfflib.MakeEngine()
	//t = throfflib.LoadGraphics(t)
	t = t.RunString(throfflib.BootStrapString(), "Internal Bootstrap")
	app.Main(func(a app.App) {
		var glctx gl.Context
		var sz size.Event
		for e := range a.Events() {
			//fmt.Printf("")
			//fmt.Printf("PRINTLN [ 1 %v ]",e)
			//if (e) {
			// }

			switch e := a.Filter(e).(type) {
			case lifecycle.Event:
				t.RunString("PRINTLN lifecycle", "HELLO")
				t.RunString(fmt.Sprintf("PRINTLN .S ->STRING [ lifecycle event ] ", e), "HELLO2")
				switch e.Crosses(lifecycle.StageVisible) {
				case lifecycle.CrossOn:
					glctx, _ = e.DrawContext.(gl.Context)
					onStart(glctx)
					a.Send(paint.Event{})
				case lifecycle.CrossOff:
					onStop(glctx)
					glctx = nil
				}
			case size.Event:
				//t.RunString("PRINTLN size", "HELLO")
				//t.RunString(fmt.Sprintf("PRINTLN .S  ->STRING [ size %v ] ", e), "HELLO2")
				//fmt.Printf("PRINTLN .S ->STRING [ size %v ]", e)
				sz = e
				touchX = float32(sz.WidthPx / 2)
				touchY = float32(sz.HeightPx / 2)
			case paint.Event:
				if glctx == nil || e.External {
					// As we are actively painting as fast as
					// we can (usually 60 FPS), skip any paint
					// events sent by the system.
					continue
				}

				onPaint(glctx, sz)
				a.Publish()
				// Drive the animation by preparing to paint the next frame
				// after this one is shown.
				a.Send(paint.Event{})
			case touch.Event:
				//t.RunString("PRINTLN touch", "HELLO")
				//t.RunString(fmt.Sprintf("PRINTLN  ->STRING [ touch %v ]", e), "HELLO2")
				touchX = e.X
				touchY = e.Y
			}
		}
	})
}
Пример #2
0
func main() {
	go func() {
		//log.Println(http.ListenAndServe("localhost:6060", nil))
	}()
	t := throfflib.MakeEngine()
	t = throfflib.LoadGraphics(t)
	//t = throfflib.LoadAudio(t)
	strs := os.Args[1:]
	//t = t.RunFile("bootstrapgo.lib")
	t = t.RunString(throfflib.BootStrapString(), "Internal Bootstrap")
	if len(strs) == 0 {
		t = t.RunString("PRINTLN [ Welcome to the THROFF command shell v0.1.  Type HELP for help. ]", "repl")
		throfflib.Repl(t)
	} else {

		fmt.Printf("")
		tokens := throfflib.StringsToTokens(strs)
		t.LoadTokens(tokens)
		t = t.Run()
		t.RunString("PRINTLN", "replprint")
	}
}