本文整理汇总了Golang中exp/draw.Rectangle类的典型用法代码示例。如果您正苦于以下问题:Golang Rectangle类的具体用法?Golang Rectangle怎么用?Golang Rectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Rectangle类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: NewMandelbrot
// NewMandelbrot returns a mandelbrot-set calculator
// that shows at least the area r within wr.
//
func NewMandelbrot(r crect, wr draw.Rectangle, julia bool, jpoint complex128, iterations int) *Mandelbrot {
btall := float64(wr.Dy()) / float64(wr.Dx())
atall := (imag(r.min) - imag(r.min)) / (real(r.max) - real(r.min))
if btall > atall {
// bitmap is taller than area, so expand area vertically
excess := (real(r.max)-real(r.min))*btall - (imag(r.max) - imag(r.min))
r.min -= cmplx(0, excess/2.0)
r.max += cmplx(0, excess/2.0)
} else {
// area is taller than bitmap, so expand area horizontally
excess := (imag(r.max)-imag(r.min))/btall - (real(r.max) - real(r.min))
r.min -= cmplx(excess/2.0, 0)
r.max += cmplx(excess/2.0, 0)
}
var m Mandelbrot
m.iterations = iterations
m.palette = makePalette(range0, iterations)
m.origin = r.min
m.julia = julia
m.jpoint = jpoint
m.cr = r
m.delta = cmplx(
(real(r.max)-real(r.min))/float64(wr.Dx()),
(imag(r.max)-imag(r.min))/float64(wr.Dy()),
)
m.r = wr
return &m
}
开发者ID:zenoss,项目名称:rog-go,代码行数:31,代码来源:mandel.go
示例3: setpiece
func setpiece(p *Piece) {
draw.Draw(bb, bbr, draw.White, nil, draw.ZP)
draw.Draw(bbmask, bbr, draw.Transparent, nil, draw.ZP)
br = draw.Rect(0, 0, 0, 0)
br2 = br
piece = p
if p == nil {
return
}
var op draw.Point
var r draw.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, draw.Black, nil, draw.ZP)
draw.Draw(bb, r.Inset(1), txpix[piece.tx], nil, draw.ZP)
draw.Draw(bbmask, r, draw.Opaque, nil, draw.ZP)
op = r.Min
} else {
draw.Draw(bb, r, bb, nil, op)
draw.Draw(bbmask, r, bbmask, nil, 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 := draw.Pt(0, DY)
br2.Max = br.Max.Add(delta)
r = br.Add(bb2r.Min)
r2 := br2.Add(bb2r.Min)
draw.Draw(bb2, r2, draw.White, nil, draw.ZP)
draw.Draw(bb2, r.Add(delta), bb, nil, bbr.Min)
draw.Draw(bb2mask, r2, draw.Transparent, nil, draw.ZP)
draw.Draw(bb2mask, r, draw.Opaque, bbmask, bbr.Min)
draw.Draw(bb2mask, r.Add(delta), draw.Opaque, bbmask, bbr.Min)
}
开发者ID:edisonwsk,项目名称:golang-on-cygwin,代码行数:44,代码来源:xs.go
示例4: 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
注:本文中的exp/draw.Rectangle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论