|
@@ -1,405 +0,0 @@
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-package identicon
|
|
|
|
-
|
|
|
|
-import (
|
|
|
|
- "image"
|
|
|
|
-)
|
|
|
|
-
|
|
|
|
-var (
|
|
|
|
-
|
|
|
|
- centerBlocks = []blockFunc{b0, b1, b2, b3}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- blocks = []blockFunc{b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16}
|
|
|
|
-)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-type blockFunc func(img *image.Paletted, x, y, size float64, angle int)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func drawBlock(img *image.Paletted, x, y, size float64, angle int, points []float64) {
|
|
|
|
- if angle > 0 {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- m := size/2 - 0.5
|
|
|
|
- rotate(points, x+m, y+m, angle)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for i := x; i < x+size; i++ {
|
|
|
|
- for j := y; j < y+size; j++ {
|
|
|
|
- if pointInPolygon(i, j, points) {
|
|
|
|
- img.SetColorIndex(int(i), int(j), 1)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b0(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b1(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- isize := int(size)
|
|
|
|
- ix := int(x)
|
|
|
|
- iy := int(y)
|
|
|
|
- for i := ix + 1; i < ix+isize; i++ {
|
|
|
|
- for j := iy + 1; j < iy+isize; j++ {
|
|
|
|
- img.SetColorIndex(i, j, 1)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b2(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- l := size / 4
|
|
|
|
- x = x + l
|
|
|
|
- y = y + l
|
|
|
|
-
|
|
|
|
- for i := x; i < x+2*l; i++ {
|
|
|
|
- for j := y; j < y+2*l; j++ {
|
|
|
|
- img.SetColorIndex(int(i), int(j), 1)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b3(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- m := size / 2
|
|
|
|
- points := []float64{}
|
|
|
|
-
|
|
|
|
- drawBlock(img, x, y, size, 0, append(points,
|
|
|
|
- x+m, y,
|
|
|
|
- x+size, y+m,
|
|
|
|
- x+m, y+size,
|
|
|
|
- x, y+m,
|
|
|
|
- x+m, y,
|
|
|
|
- ))
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b4(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- points := []float64{}
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points,
|
|
|
|
- x, y,
|
|
|
|
- x+size, y,
|
|
|
|
- x, y+size,
|
|
|
|
- x, y,
|
|
|
|
- ))
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b5(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- points := []float64{}
|
|
|
|
- m := size / 2
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points,
|
|
|
|
- x+m, y,
|
|
|
|
- x+size,
|
|
|
|
- y+size,
|
|
|
|
- x, y+size,
|
|
|
|
- x+m, y,
|
|
|
|
- ))
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b6(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- points := []float64{}
|
|
|
|
- m := size / 2
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points,
|
|
|
|
- x, y,
|
|
|
|
- x+m, y,
|
|
|
|
- x+m, y+size,
|
|
|
|
- x, y+size,
|
|
|
|
- x, y,
|
|
|
|
- ))
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b7(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- points := []float64{}
|
|
|
|
- m := size / 2
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points,
|
|
|
|
- x, y,
|
|
|
|
- x+size, y+m,
|
|
|
|
- x+size, y+size,
|
|
|
|
- x+m, y+size,
|
|
|
|
- x, y,
|
|
|
|
- ))
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b8(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- points := []float64{}
|
|
|
|
- m := size / 2
|
|
|
|
- mm := m / 2
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points,
|
|
|
|
- x+m, y,
|
|
|
|
- x+3*mm, y+m,
|
|
|
|
- x+mm, y+m,
|
|
|
|
- x+m, y,
|
|
|
|
- ))
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points[:0],
|
|
|
|
- x+mm, y+m,
|
|
|
|
- x+m, y+size,
|
|
|
|
- x, y+size,
|
|
|
|
- x+mm, y+m,
|
|
|
|
- ))
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points[:0],
|
|
|
|
- x+3*mm, y+m,
|
|
|
|
- x+size, y+size,
|
|
|
|
- x+m, y+size,
|
|
|
|
- x+3*mm, y+m,
|
|
|
|
- ))
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b9(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- points := []float64{}
|
|
|
|
- m := size / 2
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points,
|
|
|
|
- x, y,
|
|
|
|
- x+size, y+m,
|
|
|
|
- x+m, y+size,
|
|
|
|
- x, y,
|
|
|
|
- ))
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b10(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- points := []float64{}
|
|
|
|
- m := size / 2
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points,
|
|
|
|
- x+m, y,
|
|
|
|
- x+size, y,
|
|
|
|
- x+m, y+m,
|
|
|
|
- x+m, y,
|
|
|
|
- ))
|
|
|
|
-
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points[:0],
|
|
|
|
- x, y+m,
|
|
|
|
- x+m, y+m,
|
|
|
|
- x, y+size,
|
|
|
|
- x, y+m,
|
|
|
|
- ))
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b11(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- points := []float64{}
|
|
|
|
- m := size / 2
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points,
|
|
|
|
- x, y,
|
|
|
|
- x+m, y,
|
|
|
|
- x+m, y+m,
|
|
|
|
- x, y+m,
|
|
|
|
- x, y,
|
|
|
|
- ))
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b12(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- points := []float64{}
|
|
|
|
- m := size / 2
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points,
|
|
|
|
- x, y+m,
|
|
|
|
- x+size, y+m,
|
|
|
|
- x+m, y+size,
|
|
|
|
- x, y+m,
|
|
|
|
- ))
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b13(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- points := []float64{}
|
|
|
|
- m := size / 2
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points,
|
|
|
|
- x+m, y+m,
|
|
|
|
- x+size, y+size,
|
|
|
|
- x, y+size,
|
|
|
|
- x+m, y+m,
|
|
|
|
- ))
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b14(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- points := []float64{}
|
|
|
|
- m := size / 2
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points,
|
|
|
|
- x+m, y,
|
|
|
|
- x+m, y+m,
|
|
|
|
- x, y+m,
|
|
|
|
- x+m, y,
|
|
|
|
- ))
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b15(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- points := []float64{}
|
|
|
|
- m := size / 2
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points,
|
|
|
|
- x, y,
|
|
|
|
- x+m, y,
|
|
|
|
- x, y+m,
|
|
|
|
- x, y,
|
|
|
|
- ))
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-func b16(img *image.Paletted, x, y, size float64, angle int) {
|
|
|
|
- points := []float64{}
|
|
|
|
- m := size / 2
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points,
|
|
|
|
- x+m, y,
|
|
|
|
- x+size, y+m,
|
|
|
|
- x, y+m,
|
|
|
|
- x+m, y,
|
|
|
|
- ))
|
|
|
|
-
|
|
|
|
- drawBlock(img, x, y, size, angle, append(points[:0],
|
|
|
|
- x+m, y+m,
|
|
|
|
- x+size, y+size,
|
|
|
|
- x, y+size,
|
|
|
|
- x+m, y+m,
|
|
|
|
- ))
|
|
|
|
-}
|
|
|