1 Star 0 Fork 12

BOBYou/gocaptcha

forked from hanguofeng/gocaptcha 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
imagefilterstrike.go 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
hanguofeng 提交于 2014-01-27 18:28 . support load config in captcha
// Copyright 2013 hanguofeng. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package gocaptcha
import (
"math"
"strconv"
)
//ImageFilter is the interface of image filter
type ImageFilterStrike struct {
ImageFilterBase
}
//Proc the image
func (filter *ImageFilterStrike) Proc(cimage *CImage) {
var num int
var err error
v, ok := filter.config.GetItem("Num")
if ok {
num, err = strconv.Atoi(v)
if nil != err {
num = 1
}
} else {
num = 1
}
maxx := cimage.Bounds().Max.X
maxy := cimage.Bounds().Max.Y
y := rnd(maxy/2, maxy-maxy/2)
amplitude := rndf(10, 15)
period := rndf(80, 100)
dx := 2.0 * math.Pi / period
for x := 0; x < maxx; x++ {
xo := amplitude * math.Cos(float64(y)*dx)
yo := amplitude * math.Sin(float64(x)*dx)
for yn := 0; yn < num; yn++ {
r := rnd(0, 2)
cimage.drawCircle(x+int(xo), y+int(yo)+(yn*(num+1)), r/2, 1)
}
}
}
func (filter *ImageFilterStrike) GetId() string {
return "ImageFilterStrike"
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/BOBYou/gocaptcha.git
git@gitee.com:BOBYou/gocaptcha.git
BOBYou
gocaptcha
gocaptcha
master

搜索帮助