本文整理匯總了Golang中exp/draw.Point類的典型用法代碼示例。如果您正苦於以下問題:Golang Point類的具體用法?Golang Point怎麽用?Golang Point使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Point類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Draw
func (t *Tiler) Draw(dst draw.Image, clipr draw.Rectangle) {
if t.current == nil {
panic("no current")
}
min := draw.Point{
roundDown(clipr.Min.X, t.tileSize),
roundDown(clipr.Min.Y, t.tileSize),
}
var p draw.Point
for p.Y = min.Y; p.Y < clipr.Max.Y; p.Y += t.tileSize {
for p.X = min.X; p.X < clipr.Max.X; p.X += t.tileSize {
tile := t.all.Get(p.X, p.Y, t.calc)
if tile == nil {
tile = NewTile(
draw.Rect(p.X, p.Y, p.X+t.tileSize, p.Y+t.tileSize),
t.calc,
nil,
false,
)
t.all.Set(p.X, p.Y, t.calc, tile)
t.current[tile] = true
tile.Go(t.updatec)
} else if !t.current[tile] {
tile.Go(t.updatec)
}
tile.Draw(dst, clipr)
}
}
}
示例2: canfit
func canfit(p *Piece) bool {
var dx = [...]int{0, -1, 1, -2, 2, -3, 3, 4, -4}
j := N + 1
if j >= 4 {
j = p.sz.X
if j < p.sz.Y {
j = p.sz.Y
}
j = 2*j - 1
}
for i := 0; i < j; i++ {
var z draw.Point
z.X = pos.X + dx[i]*pcsz
z.Y = pos.Y
if !collide(z, p) {
z.Y = pos.Y + pcsz - 1
if !collide(z, p) {
undrawpiece()
pos.X = z.X
return true
}
}
}
return false
}
示例3: warp
func warp(p draw.Point, x int) int {
if !suspended && piece != nil {
x = pos.X + piece.sz.X*pcsz/2
if p.Y < rboard.Min.Y {
p.Y = rboard.Min.Y
}
if p.Y >= rboard.Max.Y {
p.Y = rboard.Max.Y - 1
}
//moveto(mousectl, draw.Pt(x, p.Y));
}
return x
}
示例4: collide
func collide(pt draw.Point, p *Piece) bool {
pt.X = (pt.X - rboard.Min.X) / pcsz
pt.Y = (pt.Y - rboard.Min.Y) / pcsz
for _, q := range p.d {
pt.X += q.X
pt.Y += q.Y
if pt.X < 0 || pt.X >= NX || pt.Y < 0 || pt.Y >= NY {
return true
continue
}
if board[pt.Y][pt.X] != 0 {
return true
}
}
return false
}
示例5: julia
func (ctxt *context) julia(p draw.Point) {
if f := ctxt.f.Associated(p.Add(ctxt.mouseDelta())); f != nil {
ctxt.push(f)
}
}