From dbb96819ea162729085d63f66ed3734248a28ce0 Mon Sep 17 00:00:00 2001 From: Weilin Shi <934587911@qq.com> Date: Mon, 9 Oct 2017 14:58:28 +0800 Subject: [PATCH] rename WriteTo API to WriteImage --- captcha.go | 6 +++--- captcha_test.go | 2 +- example/basic/main.go | 4 ++-- example/load-font/main.go | 2 +- history.md | 4 ++++ 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/captcha.go b/captcha.go index 73ced5f..5cc6fdd 100644 --- a/captcha.go +++ b/captcha.go @@ -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) } diff --git a/captcha_test.go b/captcha_test.go index ea0e586..c95b71b 100644 --- a/captcha_test.go +++ b/captcha_test.go @@ -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) { diff --git a/example/basic/main.go b/example/basic/main.go index 4e4472c..ae252d8 100644 --- a/example/basic/main.go +++ b/example/basic/main.go @@ -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) } diff --git a/example/load-font/main.go b/example/load-font/main.go index c56af48..f50b8ed 100644 --- a/example/load-font/main.go +++ b/example/load-font/main.go @@ -41,5 +41,5 @@ func captchaHandle(w http.ResponseWriter, _ *http.Request) { fmt.Println(err.Error()) return } - img.WriteTo(w) + img.WriteImage(w) } diff --git a/history.md b/history.md index b987477..95574cc 100644 --- a/history.md +++ b/history.md @@ -1,3 +1,7 @@ +0.12.0 / 2017-10-07 +=================== +* Add FontDPI and FontScale options + 0.11.0 / 2017-09-28 =================== * Add NewMathExpr API