rename WriteTo API to WriteImage

This commit is contained in:
Weilin Shi 2017-10-09 14:58:28 +08:00
parent 3e4b61d8c9
commit dbb96819ea
5 changed files with 11 additions and 7 deletions

View File

@ -65,7 +65,7 @@ type SetOption func(*Options)
// Data is the result of captcha generation.
// It has a `Text` field and a private `img` field that will
// be used in `WriteTo` receiver
// be used in `WriteImage` receiver
type Data struct {
// Text is captcha solution
Text string
@ -73,9 +73,9 @@ type Data struct {
img *image.NRGBA
}
// WriteTo encodes image data and writes to an io.Writer.
// WriteImage encodes image data and writes to an io.Writer.
// It returns possible error from PNG encoding
func (data *Data) WriteTo(w io.Writer) error {
func (data *Data) WriteImage(w io.Writer) error {
return png.Encode(w, data.img)
}

View File

@ -14,7 +14,7 @@ func TestNewCaptcha(t *testing.T) {
t.Fatal(err)
}
buf := new(bytes.Buffer)
data.WriteTo(buf)
data.WriteImage(buf)
}
func TestSmallCaptcha(t *testing.T) {

View File

@ -34,7 +34,7 @@ func captchaHandle(w http.ResponseWriter, _ *http.Request) {
fmt.Println(err.Error())
return
}
img.WriteTo(w)
img.WriteImage(w)
}
func mathHandle(w http.ResponseWriter, _ *http.Request) {
@ -44,5 +44,5 @@ func mathHandle(w http.ResponseWriter, _ *http.Request) {
fmt.Println(err.Error())
return
}
img.WriteTo(w)
img.WriteImage(w)
}

View File

@ -41,5 +41,5 @@ func captchaHandle(w http.ResponseWriter, _ *http.Request) {
fmt.Println(err.Error())
return
}
img.WriteTo(w)
img.WriteImage(w)
}

View File

@ -1,3 +1,7 @@
0.12.0 / 2017-10-07
===================
* Add FontDPI and FontScale options
0.11.0 / 2017-09-28
===================
* Add NewMathExpr API