1 Star 0 Fork 12

Doer / gocaptcha

forked from hanguofeng / gocaptcha 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
imagefilternoiseline.go 801 Bytes
一键复制 编辑 原始数据 按行查看 历史
hanguofeng 提交于 2014-01-27 13:05 . add config support for filters
// 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 (
"strconv"
)
//ImageFilter is the interface of image filter
type ImageFilterNoiseLine struct {
ImageFilterBase
}
//Proc the image
func (filter *ImageFilterNoiseLine) 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 = 3
}
} else {
num = 3
}
for i := 0; i < num; i++ {
x := rnd(0, cimage.Bounds().Max.X)
cimage.drawHorizLine(int(float32(x)/1.5), x, rnd(0, cimage.Bounds().Max.Y), uint8(rnd(1, colorCount)))
}
}
func (filter *ImageFilterNoiseLine) GetId() string {
return "ImageFilterNoiseLine"
}
1
https://gitee.com/Doer/gocaptcha.git
git@gitee.com:Doer/gocaptcha.git
Doer
gocaptcha
gocaptcha
master

搜索帮助