Go GIF 动画
来源:互联网 发布:淘宝怎么上架莆田鞋 编辑:程序博客网 时间:2024/05/24 16:15
代码:
package mainimport ( "image" "image/gif" "image/color" "os" "math" "io")var palette = []color.Color{color.Black,color.RGBA{0,255,0,255}}const ( blackIndex = 0 greenIndex = 1)func main() { drawSin(os.Stdout)}func drawSin(out io.Writer) { const ( nframes = 80 //帧数 resolution = 0.0001 //分辨率 size = 300 //画布大小 delay = 10 //延迟 ) anim := gif.GIF{LoopCount: nframes} x := 0.0 for i := 0; i < nframes; i++ { rect := image.Rect(0,0,size,size) img := image.NewPaletted(rect,palette) for t := 0.0; t < size; t += resolution { y := size / 2 *math.Sin(t + x); img.SetColorIndex(int(t + 0.5),int(size / 2 + y),greenIndex) } x += 3 * resolution anim.Delay = append(anim.Delay,delay) anim.Image = append(anim.Image,img) } gif.EncodeAll(out,&anim)}
效果:
阅读全文
1 0
- Go GIF 动画
- gif动画
- gif 动画
- gif动画
- GDI+显示GIF动画
- GIF动画验证码
- GIF动画验证码
- GDI+显示GIF动画
- GDI+显示GIF动画
- GDI+显示GIF动画
- 播放GIF动画
- GDI+显示GIF动画
- 显示GIF动画
- GDI+显示GIF动画
- Delphi2007 显示GIF 动画
- GDI+显示GIF动画
- GIF动画显示类
- CRichEditCtrl显示GIF动画
- 71A. Way Too Long Words
- CZJ-Superman HNUST 1880
- Windows Server上安装部署Zabbix agent(最新版)
- JSON
- Java中的低耦合高内聚法则
- Go GIF 动画
- 51nod-1284 2 3 5 7的倍数 (容斥原理)
- ZCMU2016: 不存在的树 (2017浙江中医药校赛) (树链剖分)
- AXI 的乱序操作
- 使用 Spring Boot Admin 来监控你的服务
- 史上最简单的SpringCloud教程 | 第七篇: 高可用的分布式配置中心(Spring Cloud Config)
- 超级简单的标签页
- win10 蓝屏问题及解决
- 统计量及抽样分布(统计学复习)