From 95a015a66fa373bb4e400628c75f5a60a05b947e Mon Sep 17 00:00:00 2001 From: qeesung <1245712564@qq.com> Date: Tue, 23 Oct 2018 22:57:00 +0800 Subject: [PATCH] add Example --- ascii/ascii_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ascii/ascii_test.go b/ascii/ascii_test.go index c2e7161..a1b877b 100644 --- a/ascii/ascii_test.go +++ b/ascii/ascii_test.go @@ -109,3 +109,23 @@ func TestReverseSlice(t *testing.T) { assert.True(t, reflect.DeepEqual(reversedSlice, expectedReversedSlice), fmt.Sprintf("%+v reversed should equal to %+v", s, expectedReversedSlice)) } + + +// ExampleConvertPixelToASCII is a example convert pixel to ascii char +func ExampleConvertPixelToASCII() { + // Create the pixel + r, g, b, a := uint8(255), uint8(255), uint8(255), uint8(255) + pixel := color.RGBA{ + R: r, + G: g, + B: b, + A: a, + } + + // Create the convert options + defaultOptions := NewOptions() + defaultOptions.Colored = false + convertedChar := ConvertPixelToASCII(pixel, &defaultOptions) + fmt.Println(convertedChar) + // Output: @ +} \ No newline at end of file -- 2.45.2