1 Star 0 Fork 43

Shirdon / go验证码合集包

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
imagefilterstrike.go 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
shirdon 提交于 2019-07-07 16:16 . commit
//++++++++++++++++++++++++++++++++++++++++
//Fighting for great,share generate value!
//Build the best soft by golang,let's go!
//++++++++++++++++++++++++++++++++++++++++
//Author:ShirDon <http://www.shirdon.com>
//Email:hcbsts@163.com; 823923263@qq.com
//++++++++++++++++++++++++++++++++++++++++
package captchas_with_go
import (
"math"
"strconv"
)
const IMAGE_FILTER_STRIKE = "ImageFilterStrike"
//ImageFilter is the interface of image filter
type ImageFilterStrike struct {
ImageFilterBase
}
func imageFilterStrikeCreator(config FilterConfigGroup) ImageFilter {
filter := ImageFilterStrike{}
filter.SetConfig(config)
return &filter
}
//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 IMAGE_FILTER_STRIKE
}
Go
1
https://gitee.com/shirdon/captchas_with_go.git
git@gitee.com:shirdon/captchas_with_go.git
shirdon
captchas_with_go
go验证码合集包
master

搜索帮助