本文整理汇总了Golang中github.com/shibukawa/nanovgo.Context.Block方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Block方法的具体用法?Golang Context.Block怎么用?Golang Context.Block使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/shibukawa/nanovgo.Context
的用法示例。
在下文中一共展示了Context.Block方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: drawThumbnails
func drawThumbnails(ctx *nanovgo.Context, x, y, w, h float32, images []int, t float32) {
var cornerRadius float32 = 3.0
var thumb float32 = 60.0
var arry float32 = 30.5
stackh := float32(len(images)/2)*(thumb+10) + 10
u := (1 + cosF(t*0.5)) * 0.5
u2 := (1 - cosF(t*0.2)) * 0.5
ctx.Save()
defer ctx.Restore()
// Drop shadow
shadowPaint := nanovgo.BoxGradient(x, y+4, w, h, cornerRadius*2, 20, nanovgo.RGBA(0, 0, 0, 128), nanovgo.RGBA(0, 0, 0, 0))
ctx.BeginPath()
ctx.Rect(x-10, y-10, w+20, h+30)
ctx.RoundedRect(x, y, w, h, cornerRadius)
ctx.PathWinding(nanovgo.Hole)
ctx.SetFillPaint(shadowPaint)
ctx.Fill()
// Window
ctx.BeginPath()
ctx.RoundedRect(x, y, w, h, cornerRadius)
ctx.MoveTo(x-10, y+arry)
ctx.LineTo(x+1, y+arry-11)
ctx.LineTo(x+1, y+arry+11)
ctx.SetFillColor(nanovgo.RGBA(200, 200, 200, 255))
ctx.Fill()
ctx.Block(func() {
ctx.Scissor(x, y, w, h)
ctx.Translate(0, -(stackh-h)*u)
dv := 1.0 / float32(len(images)-1)
for i, imageID := range images {
tx := x + 10.0
ty := y + 10.0
tx += float32(i%2) * (thumb + 10.0)
ty += float32(i/2) * (thumb + 10.0)
imgW, imgH, _ := ctx.ImageSize(imageID)
var iw, ih, ix, iy float32
if imgW < imgH {
iw = thumb
ih = iw * float32(imgH) / float32(imgW)
ix = 0
iy = -(ih - thumb) * 0.5
} else {
ih = thumb
iw = ih * float32(imgW) / float32(imgH)
ix = -(iw - thumb) * 0.5
iy = 0
}
v := float32(i) * dv
a := clampF((u2-v)/dv, 0, 1)
if a < 1.0 {
drawSpinner(ctx, tx+thumb/2, ty+thumb/2, thumb*0.25, t)
}
imgPaint := nanovgo.ImagePattern(tx+ix, ty+iy, iw, ih, 0.0/180.0*nanovgo.PI, imageID, a)
ctx.BeginPath()
ctx.RoundedRect(tx, ty, thumb, thumb, 5)
ctx.SetFillPaint(imgPaint)
ctx.Fill()
shadowPaint := nanovgo.BoxGradient(tx-1, ty, thumb+2, thumb+2, 5, 3, nanovgo.RGBA(0, 0, 0, 128), nanovgo.RGBA(0, 0, 0, 0))
ctx.BeginPath()
ctx.Rect(tx-5, ty-5, thumb+10, thumb+10)
ctx.RoundedRect(tx, ty, thumb, thumb, 6)
ctx.PathWinding(nanovgo.Hole)
ctx.SetFillPaint(shadowPaint)
ctx.Fill()
ctx.BeginPath()
ctx.RoundedRect(tx+0.5, ty+0.5, thumb-1, thumb-1, 4-0.5)
ctx.SetStrokeWidth(1.0)
ctx.SetStrokeColor(nanovgo.RGBA(255, 255, 255, 192))
ctx.Stroke()
}
})
// Hide fades
fadePaint := nanovgo.LinearGradient(x, y, x, y+6, nanovgo.RGBA(200, 200, 200, 255), nanovgo.RGBA(200, 200, 200, 0))
ctx.BeginPath()
ctx.Rect(x+4, y, w-8, 6)
ctx.SetFillPaint(fadePaint)
ctx.Fill()
fadePaint = nanovgo.LinearGradient(x, y+h, x, y+h-6, nanovgo.RGBA(200, 200, 200, 255), nanovgo.RGBA(200, 200, 200, 0))
ctx.BeginPath()
ctx.Rect(x+4, y+h-6, w-8, 6)
ctx.SetFillPaint(fadePaint)
ctx.Fill()
// Scroll bar
shadowPaint = nanovgo.BoxGradient(x+w-12+1, y+4+1, 8, h-8, 3, 4, nanovgo.RGBA(0, 0, 0, 32), nanovgo.RGBA(0, 0, 0, 92))
ctx.BeginPath()
//.........这里部分代码省略.........