本文整理汇总了Golang中golang.org/x/mobile/geom.Pt函数的典型用法代码示例。如果您正苦于以下问题:Golang Pt函数的具体用法?Golang Pt怎么用?Golang Pt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Pt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: updateConfig
//export updateConfig
func updateConfig(width, height int) {
eventsIn <- config.Event{
Width: geom.Pt(float32(screenScale*width) / pixelsPerPt),
Height: geom.Pt(float32(screenScale*height) / pixelsPerPt),
PixelsPerPt: pixelsPerPt,
}
}
开发者ID:SpruceHealth,项目名称:mobile,代码行数:8,代码来源:darwin_armx.go
示例2: onResize
//export onResize
func onResize(w, h int) {
// TODO(nigeltao): don't assume 72 DPI. DisplayWidth / DisplayWidthMM
// is probably the best place to start looking.
geom.PixelsPerPt = 1
geom.Width = geom.Pt(w)
geom.Height = geom.Pt(h)
}
开发者ID:Miaque,项目名称:mojo,代码行数:8,代码来源:x11.go
示例3: processEvent
func processEvent(e *C.AInputEvent) {
switch C.AInputEvent_getType(e) {
case C.AINPUT_EVENT_TYPE_KEY:
log.Printf("TODO input event: key")
case C.AINPUT_EVENT_TYPE_MOTION:
// At most one of the events in this batch is an up or down event; get its index and change.
upDownIndex := C.size_t(C.AMotionEvent_getAction(e)&C.AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> C.AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT
upDownType := touch.TypeMove
switch C.AMotionEvent_getAction(e) & C.AMOTION_EVENT_ACTION_MASK {
case C.AMOTION_EVENT_ACTION_DOWN, C.AMOTION_EVENT_ACTION_POINTER_DOWN:
upDownType = touch.TypeBegin
case C.AMOTION_EVENT_ACTION_UP, C.AMOTION_EVENT_ACTION_POINTER_UP:
upDownType = touch.TypeEnd
}
for i, n := C.size_t(0), C.AMotionEvent_getPointerCount(e); i < n; i++ {
t := touch.TypeMove
if i == upDownIndex {
t = upDownType
}
eventsIn <- touch.Event{
Sequence: touch.Sequence(C.AMotionEvent_getPointerId(e, i)),
Type: t,
Loc: geom.Point{
X: geom.Pt(float32(C.AMotionEvent_getX(e, i)) / pixelsPerPt),
Y: geom.Pt(float32(C.AMotionEvent_getY(e, i)) / pixelsPerPt),
},
}
}
default:
log.Printf("unknown input event, type=%d", C.AInputEvent_getType(e))
}
}
开发者ID:sunqb,项目名称:mobile,代码行数:33,代码来源:loop_android.go
示例4: onResize
//export onResize
func onResize(w, h int) {
// TODO(nigeltao): don't assume 72 DPI. DisplayWidth and DisplayWidthMM
// is probably the best place to start looking.
pixelsPerPt = 1
eventsIn <- event.Config{
Width: geom.Pt(w),
Height: geom.Pt(h),
PixelsPerPt: pixelsPerPt,
}
// This gl.Viewport call has to be in a separate goroutine because any gl
// call can block until gl.DoWork is called, but this goroutine is the one
// responsible for calling gl.DoWork.
// TODO: does this (GL-using) code belong here in the x/mobile/app
// package?? See similar TODOs in the Android x/mobile/app implementation.
c := make(chan struct{})
go func() {
gl.Viewport(0, 0, w, h)
close(c)
}()
for {
select {
case <-gl.WorkAvailable:
gl.DoWork()
case <-c:
return
}
}
}
开发者ID:handong890,项目名称:mobile,代码行数:30,代码来源:x11.go
示例5: main
func main() {
e := Engine{}
app.Main(func(a app.App) {
var c size.Event
for eve := range a.Events() {
switch eve := app.Filter(eve).(type) {
case lifecycle.Event:
switch eve.Crosses(lifecycle.StageVisible) {
case lifecycle.CrossOn:
e.Start()
case lifecycle.CrossOff:
e.Stop()
}
case size.Event:
c = eve
e.touchLoc = geom.Point{c.WidthPt / 2, c.HeightPt / 2}
case paint.Event:
e.Draw(c)
a.EndPaint(eve)
case touch.Event:
e.touchLoc = geom.Point{geom.Pt(eve.X), geom.Pt(eve.Y)}
}
}
})
}
开发者ID:lomoalbert,项目名称:gomobileapp,代码行数:26,代码来源:main.go
示例6: processEvent
func processEvent(cb Callbacks, e *C.AInputEvent) {
switch C.AInputEvent_getType(e) {
case C.AINPUT_EVENT_TYPE_KEY:
log.Printf("TODO input event: key")
case C.AINPUT_EVENT_TYPE_MOTION:
if cb.Touch == nil {
return
}
x := C.AMotionEvent_getX(e, 0)
y := C.AMotionEvent_getY(e, 0)
var ty event.TouchType
switch C.AMotionEvent_getAction(e) {
case C.AMOTION_EVENT_ACTION_DOWN:
ty = event.TouchStart
case C.AMOTION_EVENT_ACTION_MOVE:
ty = event.TouchMove
case C.AMOTION_EVENT_ACTION_UP:
ty = event.TouchEnd
}
cb.Touch(event.Touch{
Type: ty,
Loc: geom.Point{
X: geom.Pt(float32(x) / geom.PixelsPerPt),
Y: geom.Pt(float32(y) / geom.PixelsPerPt),
},
})
default:
log.Printf("unknown input event, type=%d", C.AInputEvent_getType(e))
}
}
开发者ID:dylanpoe,项目名称:golang.org,代码行数:31,代码来源:loop_android.go
示例7: sendTouch
//export sendTouch
func sendTouch(touch, touchType uintptr, x, y float32) {
id := -1
for i, val := range touchIDs {
if val == touch {
id = i
break
}
}
if id == -1 {
for i, val := range touchIDs {
if val == 0 {
touchIDs[i] = touch
id = i
break
}
}
if id == -1 {
panic("out of touchIDs")
}
}
t := touch.Type(touchType)
if t == touch.TypeEnd {
touchIDs[id] = 0
}
eventsIn <- touch.Event{
Sequence: touch.Sequence(id),
Type: t,
Loc: geom.Point{
X: geom.Pt(x / pixelsPerPt),
Y: geom.Pt(y / pixelsPerPt),
},
}
}
开发者ID:SpruceHealth,项目名称:mobile,代码行数:36,代码来源:darwin_armx.go
示例8: windowDrawLoop
func windowDrawLoop(cb Callbacks, w *C.ANativeWindow, queue *C.AInputQueue) {
C.createEGLWindow(w)
// TODO: is the library or the app responsible for clearing the buffers?
gl.ClearColor(0, 0, 0, 1)
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
C.eglSwapBuffers(C.display, C.surface)
if errv := gl.GetError(); errv != gl.NO_ERROR {
log.Printf("GL initialization error: %s", errv)
}
geom.Width = geom.Pt(float32(C.windowWidth) / geom.PixelsPerPt)
geom.Height = geom.Pt(float32(C.windowHeight) / geom.PixelsPerPt)
for {
processEvents(cb, queue)
select {
case <-windowDestroyed:
return
default:
if cb.Draw != nil {
cb.Draw()
}
C.eglSwapBuffers(C.display, C.surface)
}
}
}
开发者ID:dylanpoe,项目名称:golang.org,代码行数:28,代码来源:loop_android.go
示例9: onPaint
func onPaint(glctx gl.Context, sz size.Event) {
glctx.ClearColor(236, 240, 241, 1)
glctx.Clear(gl.COLOR_BUFFER_BIT)
columnOffset := (sz.WidthPt / 2) - ((geom.Pt(gridColumnsCount) * tileSize) / 2)
rowOffset := (sz.HeightPt / 2) - ((geom.Pt(gridrowsCount) * tileSize) / 2)
for c := 0; c < gridColumnsCount; c++ {
for r := 0; r < gridrowsCount; r++ {
t := &grid[((c+1)*(r+1))-1]
t.columnOffset = columnOffset
t.rowOffset = rowOffset
t.x = geom.Pt(c) * tileSize
t.y = geom.Pt(r) * tileSize
t.Draw(sz)
}
}
}
开发者ID:plixul,项目名称:figura,代码行数:25,代码来源:main.go
示例10: sendTouch
//export sendTouch
func sendTouch(touch, change uintptr, x, y float32) {
id := -1
for i, val := range touchIDs {
if val == touch {
id = i
break
}
}
if id == -1 {
for i, val := range touchIDs {
if val == 0 {
touchIDs[i] = touch
id = i
break
}
}
if id == -1 {
panic("out of touchIDs")
}
}
c := event.Change(change)
if c == event.ChangeOff {
touchIDs[id] = 0
}
eventsIn <- event.Touch{
ID: event.TouchSequenceID(id),
Change: c,
Loc: geom.Point{
X: geom.Pt(x / pixelsPerPt),
Y: geom.Pt(y / pixelsPerPt),
},
}
}
开发者ID:handong890,项目名称:mobile,代码行数:36,代码来源:darwin_armx.go
示例11: main
func main() {
defer func() {
if err := recover(); err != nil {
log.Println(err)
}
}()
e := Engine{}
app.Main(func(a app.App) {
var c size.Event
for eve := range a.Events() {
switch eve := app.Filter(eve).(type) {
case lifecycle.Event:
switch eve.Crosses(lifecycle.StageVisible) {
case lifecycle.CrossOn:
e.Start()
case lifecycle.CrossOff:
e.Stop()
}
case size.Event:
c = eve
e.touchLoc = geom.Point{0, 0}
case paint.Event:
e.Draw(c)
a.EndPaint(eve)
case touch.Event:
e.touchLoc = geom.Point{geom.Pt(eve.X), geom.Pt(eve.Y)}
}
}
})
}
开发者ID:lovexiaov,项目名称:gomobileapp,代码行数:30,代码来源:main.go
示例12: windowDraw
func windowDraw(w *C.ANativeWindow, queue *C.AInputQueue, donec chan struct{}) (done bool) {
// Android can send a windowRedrawNeeded event any time, including
// in the middle of a paint cycle. The redraw event may have changed
// the size of the screen, so any partial painting is now invalidated.
// We must also not return to Android (via sending on windowRedrawDone)
// until a complete paint with the new configuration is complete.
//
// When a windowRedrawNeeded request comes in, we increment redrawGen
// (Gen is short for generation number), and do not make a paint cycle
// visible on <-endPaint unless paintGen agrees. If possible,
// windowRedrawDone is signalled, allowing onNativeWindowRedrawNeeded
// to return.
var redrawGen, paintGen uint32
for {
processEvents(queue)
select {
case <-donec:
return true
case cfg := <-windowConfigChange:
// TODO save orientation
pixelsPerPt = cfg.pixelsPerPt
case w := <-windowRedrawNeeded:
sendLifecycle(lifecycle.StageFocused)
widthPx := int(C.ANativeWindow_getWidth(w))
heightPx := int(C.ANativeWindow_getHeight(w))
eventsIn <- config.Event{
WidthPx: widthPx,
HeightPx: heightPx,
WidthPt: geom.Pt(float32(widthPx) / pixelsPerPt),
HeightPt: geom.Pt(float32(heightPx) / pixelsPerPt),
PixelsPerPt: pixelsPerPt,
}
if paintGen == 0 {
paintGen++
C.createEGLWindow(w)
eventsIn <- paint.Event{}
}
redrawGen++
case <-windowDestroyed:
sendLifecycle(lifecycle.StageAlive)
return false
case <-gl.WorkAvailable:
gl.DoWork()
case <-endPaint:
if paintGen == redrawGen {
// eglSwapBuffers blocks until vsync.
C.eglSwapBuffers(C.display, C.surface)
select {
case windowRedrawDone <- struct{}{}:
default:
}
}
paintGen = redrawGen
eventsIn <- paint.Event{}
}
}
}
开发者ID:sunqb,项目名称:mobile,代码行数:57,代码来源:loop_android.go
示例13: setGeom
//export setGeom
func setGeom(ppp float32, width, height int) {
pixelsPerPt = ppp
windowHeight = geom.Pt(float32(height) / pixelsPerPt)
eventsIn <- config.Event{
Width: geom.Pt(float32(width) / pixelsPerPt),
Height: windowHeight,
PixelsPerPt: pixelsPerPt,
}
}
开发者ID:tendermint,项目名称:mobile,代码行数:10,代码来源:darwin_amd64.go
示例14: sendTouch
func sendTouch(t touch.Type, x, y float32) {
eventsIn <- touch.Event{
Sequence: 0, // TODO: button??
Type: t,
Loc: geom.Point{
X: geom.Pt(x / pixelsPerPt),
Y: geom.Pt(y / pixelsPerPt),
},
}
}
开发者ID:zach-klippenstein,项目名称:mobile,代码行数:10,代码来源:x11.go
示例15: sendTouch
func sendTouch(c event.Change, x, y float32) {
eventsIn <- event.Touch{
ID: 0,
Change: c,
Loc: geom.Point{
X: geom.Pt(x / pixelsPerPt),
Y: windowHeight - geom.Pt(y/pixelsPerPt),
},
}
}
开发者ID:handong890,项目名称:mobile,代码行数:10,代码来源:darwin_amd64.go
示例16: onResize
//export onResize
func onResize(w, h int) {
// TODO(nigeltao): don't assume 72 DPI. DisplayWidth and DisplayWidthMM
// is probably the best place to start looking.
pixelsPerPt = 1
eventsIn <- config.Event{
Width: geom.Pt(w),
Height: geom.Pt(h),
PixelsPerPt: pixelsPerPt,
}
}
开发者ID:zach-klippenstein,项目名称:mobile,代码行数:11,代码来源:x11.go
示例17: sendTouch
func sendTouch(t touch.Type, x, y float32) {
eventsIn <- touch.Event{
Sequence: 0,
Type: t,
Loc: geom.Point{
X: geom.Pt(x / pixelsPerPt),
Y: windowHeight - geom.Pt(y/pixelsPerPt),
},
}
}
开发者ID:tendermint,项目名称:mobile,代码行数:10,代码来源:darwin_amd64.go
示例18: sendTouch
func sendTouch(c event.Change, x, y float32) {
eventsIn <- event.Touch{
ID: 0, // TODO: button??
Change: c,
Loc: geom.Point{
X: geom.Pt(x / pixelsPerPt),
Y: geom.Pt(y / pixelsPerPt),
},
}
}
开发者ID:handong890,项目名称:mobile,代码行数:10,代码来源:x11.go
示例19: setGeom
//export setGeom
func setGeom(pixelsPerPt float32, widthPx, heightPx int) {
windowHeightPx = float32(heightPx)
eventsIn <- size.Event{
WidthPx: widthPx,
HeightPx: heightPx,
WidthPt: geom.Pt(float32(widthPx) / pixelsPerPt),
HeightPt: geom.Pt(float32(heightPx) / pixelsPerPt),
PixelsPerPt: pixelsPerPt,
}
}
开发者ID:paulhankin,项目名称:mobile,代码行数:11,代码来源:darwin_amd64.go
示例20: sendTouch
func sendTouch(ty event.TouchType, x, y float32) {
events.Lock()
events.pending = append(events.pending, event.Touch{
Type: ty,
Loc: geom.Point{
X: geom.Pt(x / geom.PixelsPerPt),
Y: geom.Height - geom.Pt(y/geom.PixelsPerPt),
},
})
events.Unlock()
}
开发者ID:dylanpoe,项目名称:golang.org,代码行数:11,代码来源:darwin.go
注:本文中的golang.org/x/mobile/geom.Pt函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论