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() ctx.RoundedRect(x+w-12, y+4, 8, h-8, 3) ctx.SetFillPaint(shadowPaint) // ctx.FillColor(ctx.RGBA(255,0,0,128)); ctx.Fill() scrollH := (h / stackh) * (h - 8) shadowPaint = nanovgo.BoxGradient(x+w-12-1, y+4+(h-8-scrollH)*u-1, 8, scrollH, 3, 4, nanovgo.RGBA(220, 220, 220, 255), nanovgo.RGBA(128, 128, 128, 255)) ctx.BeginPath() ctx.RoundedRect(x+w-12+1, y+4+1+(h-8-scrollH)*u, 8-2, scrollH-2, 2) ctx.SetFillPaint(shadowPaint) // ctx.FillColor(ctx.RGBA(0,0,0,128)); ctx.Fill() }