本文整理汇总了Golang中exp/draw.Draw函数的典型用法代码示例。如果您正苦于以下问题:Golang Draw函数的具体用法?Golang Draw怎么用?Golang Draw使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Draw函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: drawsq
func drawsq(b draw.Image, p draw.Point, ptx int) {
var r draw.Rectangle
r.Min = p
r.Max.X = r.Min.X + pcsz
r.Max.Y = r.Min.Y + pcsz
draw.Draw(b, r, draw.Black, nil, draw.ZP)
draw.Draw(b, r.Inset(1), txpix[ptx], nil, draw.ZP)
}
开发者ID:edisonwsk,项目名称:golang-on-cygwin,代码行数:8,代码来源:xs.go
示例2: drawsq
func drawsq(b draw.Image, p image.Point, ptx int) {
var r image.Rectangle
r.Min = p
r.Max.X = r.Min.X + pcsz
r.Max.Y = r.Min.Y + pcsz
draw.Draw(b, r, image.Black, image.ZP)
draw.Draw(b, r.Inset(1), txpix[ptx], image.ZP)
}
开发者ID:GNA-SERVICES-INC,项目名称:MoNGate,代码行数:8,代码来源:xs.go
示例3: main
func main() {
urls := make(chan string, 4)
imgReady := make(chan *image.Image, 4)
go imagePuller(urls, imgReady)
go urlGen(urls)
xdisp, err := x11.NewWindow()
if err != nil {
log.Exit("X11 error: ", err)
}
screen := xdisp.Screen()
//2010/11/29 16:23:17 one tile is sized (0,0)-(256,256)
//2010/11/29 16:23:17 the screen is sized (0,0)-(800,600)
// log.Print("one tile is sized ", img.Bounds())
// log.Print("the screen is sized ", screen.Bounds())
tileHeight := 256
tileWidth := 256
numTiles := screen.Bounds().Dx()/tileWidth + 2
tileStrip := image.NewRGBA(numTiles*tileWidth, tileHeight)
// pre-load the tile strip
for i := 0; i < numTiles; i++ {
iptr := <-imgReady
img := *iptr
draw.Draw(tileStrip, image.Rect(i*tileWidth, 0, i*tileWidth+tileWidth, tileHeight), img, image.ZP)
}
topBlack := (screen.Bounds().Dy() - tileHeight) / 2
for {
for x := 0; x < tileWidth; x += 15 {
then := time.Nanoseconds()
draw.Draw(screen, image.Rect(0, topBlack, screen.Bounds().Dx(), topBlack+tileHeight), tileStrip, image.Pt(x, 0))
now := time.Nanoseconds()
frameTime := now - then
// a flush is just a write on a channel, so it takes negligible time
xdisp.FlushImage()
toSleep := 0.1*1e9 - frameTime
// log.Print("Took ", frameTime, " ns to draw, will sleep ", toSleep, " ns")
time.Sleep(toSleep)
processEvent(xdisp.EventChan())
}
// shift tiles in tileStrip and put in new last one
draw.Draw(tileStrip, image.Rect(0, 0, (numTiles-1)*tileWidth, tileHeight), tileStrip, image.Pt(tileWidth, 0))
iptr := <-imgReady
img := *iptr
draw.Draw(tileStrip, image.Rect((numTiles-1)*tileWidth, 0, numTiles*tileWidth, tileHeight), img, image.ZP)
}
}
开发者ID:ThunderPuppy,项目名称:tinygo,代码行数:55,代码来源:mapscroll.go
示例4: horiz
func horiz() bool {
var lev [MAXN]int
h := 0
for i := 0; i < NY; i++ {
for j := 0; board[i][j] != 0; j++ {
if j == NX-1 {
lev[h] = i
h++
break
}
}
}
if h == 0 {
return false
}
r := rboard
newscreen = false
for j := 0; j < h; j++ {
r.Min.Y = rboard.Min.Y + lev[j]*pcsz
r.Max.Y = r.Min.Y + pcsz
draw.Draw(screen, r, draw.White, whitemask, draw.ZP)
display.FlushImage()
}
PlaySound(whoosh)
for i := 0; i < 3; i++ {
pause(250)
if newscreen {
drawboard()
break
}
for j := 0; j < h; j++ {
r.Min.Y = rboard.Min.Y + lev[j]*pcsz
r.Max.Y = r.Min.Y + pcsz
draw.Draw(screen, r, draw.White, whitemask, draw.ZP)
}
display.FlushImage()
}
r = rboard
for j := 0; j < h; j++ {
i := NY - lev[j] - 1
score(250 + 10*i*i)
r.Min.Y = rboard.Min.Y
r.Max.Y = rboard.Min.Y + lev[j]*pcsz
draw.Draw(screen, r.Add(draw.Pt(0, pcsz)), screen, nil, r.Min)
r.Max.Y = rboard.Min.Y + pcsz
draw.Draw(screen, r, draw.White, nil, draw.ZP)
for k := lev[j] - 1; k >= 0; k-- {
board[k+1] = board[k]
}
board[0] = [NX]byte{}
}
display.FlushImage()
return true
}
开发者ID:edisonwsk,项目名称:golang-on-cygwin,代码行数:54,代码来源:xs.go
示例5: drawboard
func drawboard() {
draw.Border(screen, rboard.Inset(-2), 2, draw.Black, draw.ZP)
draw.Draw(screen, draw.Rect(rboard.Min.X, rboard.Min.Y-2, rboard.Max.X, rboard.Min.Y),
draw.White, nil, draw.ZP)
for i := 0; i < NY; i++ {
for j := 0; j < NX; j++ {
if board[i][j] != 0 {
drawsq(screen, draw.Pt(rboard.Min.X+j*pcsz, rboard.Min.Y+i*pcsz), int(board[i][j]-16))
}
}
}
score(0)
if suspended {
draw.Draw(screen, screenr, draw.White, whitemask, draw.ZP)
}
}
开发者ID:edisonwsk,项目名称:golang-on-cygwin,代码行数:16,代码来源:xs.go
示例6: undrawpiece
func undrawpiece() {
var mask image.Image
if collider(pos, br.Max) {
mask = bbmask
}
draw.Draw(screen, br.Add(pos), draw.White, mask, bbr.Min)
}
开发者ID:edisonwsk,项目名称:golang-on-cygwin,代码行数:7,代码来源:xs.go
示例7: rgba
func rgba(m image.Image) *image.RGBA {
if r, ok := m.(*image.RGBA); ok {
return r
}
b := m.Bounds()
r := image.NewRGBA(b.Dx(), b.Dy())
draw.Draw(r, b, m, image.ZP)
return r
}
开发者ID:egonelbre,项目名称:sivq,代码行数:9,代码来源:utils.go
示例8: setpiece
func setpiece(p *Piece) {
draw.Draw(bb, bbr, image.White, image.ZP)
draw.Draw(bbmask, bbr, image.Transparent, image.ZP)
br = image.Rect(0, 0, 0, 0)
br2 = br
piece = p
if p == nil {
return
}
var op image.Point
var r image.Rectangle
r.Min = bbr.Min
for i, pt := range p.d {
r.Min.X += pt.X * pcsz
r.Min.Y += pt.Y * pcsz
r.Max.X = r.Min.X + pcsz
r.Max.Y = r.Min.Y + pcsz
if i == 0 {
draw.Draw(bb, r, image.Black, image.ZP)
draw.Draw(bb, r.Inset(1), txpix[piece.tx], image.ZP)
draw.Draw(bbmask, r, image.Opaque, image.ZP)
op = r.Min
} else {
draw.Draw(bb, r, bb, op)
draw.Draw(bbmask, r, bbmask, op)
}
if br.Max.X < r.Max.X {
br.Max.X = r.Max.X
}
if br.Max.Y < r.Max.Y {
br.Max.Y = r.Max.Y
}
}
br.Max = br.Max.Sub(bbr.Min)
delta := image.Pt(0, DY)
br2.Max = br.Max.Add(delta)
r = br.Add(bb2r.Min)
r2 := br2.Add(bb2r.Min)
draw.Draw(bb2, r2, image.White, image.ZP)
draw.Draw(bb2, r.Add(delta), bb, bbr.Min)
draw.Draw(bb2mask, r2, image.Transparent, image.ZP)
draw.DrawMask(bb2mask, r, image.Opaque, bbr.Min, bbmask, image.ZP, draw.Over)
draw.DrawMask(bb2mask, r.Add(delta), image.Opaque, bbr.Min, bbmask, image.ZP, draw.Over)
}
开发者ID:GNA-SERVICES-INC,项目名称:MoNGate,代码行数:44,代码来源:xs.go
示例9: movepiece
func movepiece() bool {
var mask image.Image
if collide(draw.Pt(pos.X, pos.Y+pcsz), piece) {
return false
}
if collider(pos, br2.Max) {
mask = bb2mask
}
draw.Draw(screen, br2.Add(pos), bb2, mask, bb2r.Min)
pos.Y += DY
display.FlushImage()
return true
}
开发者ID:edisonwsk,项目名称:golang-on-cygwin,代码行数:13,代码来源:xs.go
示例10: redraw
func redraw(new bool) {
// if new && getwindow(display, Refmesg) < 0 {
// sysfatal("can't reattach to window");
// }
r := draw.Rect(0, 0, screen.Width(), screen.Height())
pos.X = (pos.X - rboard.Min.X) / pcsz
pos.Y = (pos.Y - rboard.Min.Y) / pcsz
dx := r.Max.X - r.Min.X
dy := r.Max.Y - r.Min.Y - 2*32
DY = dx / NX
if DY > dy/NY {
DY = dy / NY
}
DY /= 8
if DY > 4 {
DY = 4
}
pcsz = DY * 8
DMOUSE = pcsz / 3
if pcsz < 8 {
log.Exitf("screen too small: %d", pcsz)
}
rboard = screenr
rboard.Min.X += (dx - pcsz*NX) / 2
rboard.Min.Y += (dy-pcsz*NY)/2 + 32
rboard.Max.X = rboard.Min.X + NX*pcsz
rboard.Max.Y = rboard.Min.Y + NY*pcsz
pscore.X = rboard.Min.X + 8
pscore.Y = rboard.Min.Y - 32
// scoresz = stringsize(font, "000000");
pos.X = pos.X*pcsz + rboard.Min.X
pos.Y = pos.Y*pcsz + rboard.Min.Y
bbr = draw.Rect(0, 0, N*pcsz, N*pcsz)
bb = image.NewRGBA(bbr.Max.X, bbr.Max.Y)
bbmask = image.NewRGBA(bbr.Max.X, bbr.Max.Y) // actually just a bitmap
bb2r = draw.Rect(0, 0, N*pcsz, N*pcsz+DY)
bb2 = image.NewRGBA(bb2r.Dx(), bb2r.Dy())
bb2mask = image.NewRGBA(bb2r.Dx(), bb2r.Dy()) // actually just a bitmap
draw.Draw(screen, screenr, draw.White, nil, draw.ZP)
drawboard()
setpiece(piece)
if piece != nil {
drawpiece()
}
lastmx = movemouse()
newscreen = true
display.FlushImage()
}
开发者ID:edisonwsk,项目名称:golang-on-cygwin,代码行数:48,代码来源:xs.go
示例11: NewTile
func NewTile(r draw.Rectangle, calc Fractal, img *image.RGBA, wait bool) *Tile {
t := new(Tile)
t.r = r
t.nrows = 0
if img == nil {
img = image.NewRGBA(image.Rect(0, 0, r.Dx(), r.Dy()))
}
t.calc = calc
t.image = img
if wait {
t.calculate(nil, nil)
t.nrows = img.Height()
} else {
// choose some vaguely appropriate colour
col := calc.At(centre(r))
draw.Draw(t.image, draw.Rect(0, 0, r.Dx(), r.Dy()), image.Uniform{col}, draw.ZP)
}
return t
}
开发者ID:zenoss,项目名称:rog-go,代码行数:19,代码来源:mandel.go
示例12: main
func main() {
//ctxt, err := svga.NewScreen()
//if ctxt == nil {
// log.Exitf("no screen: %v", err)
//}
//screen := ctxt.Screen()
//img := screen.(*image.RGBA)
img := image.NewRGBA(640, 480)
draw.Draw(img, image.Rect(10, 10, 100, 100), image.White, image.ZP)
cr, cg, cb, ca := image.White.RGBA()
println("cr ", cr)
println("cg ", cg)
println("cb ", cb)
println("ca ", ca)
//ctxt.FlushImage()
print("done.")
}
开发者ID:gdey,项目名称:tinygo,代码行数:20,代码来源:demo.go
示例13: app
func app(inContext draw.Context)
{
vl_screen := inContext.Screen();
screenr := draw.Rect(0, 0, vl_screen.Width(), vl_screen.Height());
draw.Draw(vl_screen, screenr, draw.White, nil, draw.ZP);
squareSize := 30;
var cell *SMazeCell = new(SMazeCell);
cell.draw(inContext, squareSize);
inContext.FlushImage();
fmt.Printf("Press the any key to exit.\n");
for
{
select
{
case r := <- inContext.KeyboardChan():
switch r
{
case 'q', 'Q', 0x04, 0x7F, 32 :
fmt.Printf("Exiting because of keyboard event %d\n", r);
os.Exit(0);
default :
fmt.Printf("Exiting because of keyboard event %d\n", r);
}
case <- inContext.MouseChan():
// No-op.
case <- inContext.ResizeChan():
// No-op.
case <- inContext.QuitChan():
fmt.Printf("Exiting because of QuitChan\n");
return;
}
}
}
开发者ID:belkiss,项目名称:GoMaze,代码行数:38,代码来源:main.go
示例14: Draw
func (cp *ControlPoint) Draw(dst draw.Image, clipr image.Rectangle) {
r := clipr.Intersect(cp.Bbox())
draw.Draw(dst, r, cp.col, image.ZP)
}
开发者ID:juanman2,项目名称:dot-emacs,代码行数:4,代码来源:shape.go
示例15: drawpiece
func drawpiece() {
draw.Draw(screen, br.Add(pos), bb, bbmask, bbr.Min)
if suspended {
draw.Draw(screen, br.Add(pos), draw.White, whitemask, draw.ZP)
}
}
开发者ID:edisonwsk,项目名称:golang-on-cygwin,代码行数:6,代码来源:xs.go
示例16: randomizeWindow
func randomizeWindow() {
s := window.Screen()
colorScaler := 0xFFFF / div / 2
//Overlay
totalSide := div * wholes
st := 600 / totalSide
boundary := st * div * wholes
for i := range pic.Pix {
var setting uint16
x, y := i%picStride, i/picStride
if x > boundary || y > boundary {
pic.Pix[i].Y = 0
} else {
x, y = x/st, y/st
if z := x * y % div; z == 0 {
setting = 0xFFFF
} else {
if nonDivOff {
setting = 0x0000
} else {
setting = uint16(z * colorScaler)
}
}
}
pic.Pix[i].Y = setting
/*if x := ((i%pic.Stride * (i / pic.Stride)) % div); x == 0 {
pic.Pix[i].Y = 0xFFFF
} else {
if nonDivOff {
pic.Pix[i].Y = 0
} else{
pic.Pix[i].Y = uint16(x * colorScaler)
}
}*/
//pic.Set(i % pic.Stride, i / pic.Stride, image.Gray16Color{0xFFFF})
}
draw.Draw(s, s.Bounds(), pic, image.ZP)
/* for i := 0; i < bounds.Dy(); i++ {
for j := 0; j < bounds.Dx(); j++ {
var c image.Gray16Color
if x:= (j * i)%div; x == 0 {
c = image.Gray16Color{0xFFFF}
} else {
if nonDivOff {
c = image.Gray16Color{0}
} else {
c = image.Gray16Color{uint16(x*(0xFFFF/div))}
}
}
//image.GrayColor{uint8(rnd.Intn(256))}
s.Set(bounds.Min.X + j,
bounds.Min.Y + i,
c)
}
} */
window.FlushImage()
}
开发者ID:Fumon,项目名称:NeatMathViz,代码行数:61,代码来源:drw.go
示例17: draw
func (inpMazeCell *SMazeCell) draw(inContext draw.Context, inSquareSize int)
{
vl_screen := inContext.Screen();
upXLeft, upYLeft := 100, 100;
squareSize := inSquareSize;
fullCell := draw.Rect(upXLeft, upYLeft, squareSize + upXLeft, squareSize + upYLeft);
draw.Draw(vl_screen, fullCell, draw.Black, nil, draw.ZP);
// inset set the color of the inside
draw.Draw(vl_screen, fullCell.Inset(1), draw.White, nil, draw.ZP);
//hide a wall with a rectangle... POOR SOLUTION !!
if inpMazeCell.northOpen
{
// up wall
hiderup := draw.Rect(upXLeft, upYLeft,
upXLeft + squareSize, upYLeft + 1);
draw.Draw(vl_screen, hiderup, draw.White, nil, draw.ZP);
}
else
{
// do not hide
}
if inpMazeCell.westOpen
{
// right wall
hiderright := draw.Rect(upXLeft + squareSize - 1, upYLeft,
upXLeft + squareSize, upYLeft + squareSize);
draw.Draw(vl_screen, hiderright, draw.White, nil, draw.ZP);
}
else
{
// do not hide
}
if inpMazeCell.southOpen
{
// down wall
hiderdown := draw.Rect(upXLeft, upYLeft + squareSize - 1,
upXLeft + squareSize, upYLeft + squareSize);
draw.Draw(vl_screen, hiderdown, draw.White, nil, draw.ZP);
}
else
{
// do not hide
}
if inpMazeCell.eastOpen
{
// left wall
hiderleft := draw.Rect(upXLeft, upYLeft,
upXLeft + 1, upYLeft + squareSize);
draw.Draw(vl_screen, hiderleft, draw.White, nil, draw.ZP);
}
else
{
// do not hide
}
}
开发者ID:belkiss,项目名称:GoMaze,代码行数:62,代码来源:main.go
注:本文中的exp/draw.Draw函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论