/
g_inversedSurroundedDiagonalLine.go
executable file
·85 lines (68 loc) · 2.13 KB
/
g_inversedSurroundedDiagonalLine.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package generators
import (
"fmt"
"image"
"image/color"
"os"
"../tools"
)
func inversedSurroundedDiagonalLineAdditionalDraw(img *image.RGBA64, prevX, prevY, x, y, coef int, color *color.RGBA64) {
maxSurround := coef / 2
currentColor := *color
Line(img, prevX, prevY, x, y, baseColor)
if (x > prevX && y > prevY) || (x < prevX && y < prevY) {
for diff := 1; diff < maxSurround; diff++ {
currentColor = tools.ColorMean(
100*(diff)/maxSurround, color, &baseColor)
Line(img, prevX, prevY+diff, x-diff, y, currentColor)
Line(img, prevX+diff, prevY, x, y-diff, currentColor)
}
} else {
for diff := 1; diff < maxSurround; diff++ {
currentColor = tools.ColorMean(
100*(diff)/(maxSurround), color, &baseColor)
Line(img, prevX, prevY-diff, x-diff, y, currentColor)
Line(img, prevX+diff, prevY, x, y+diff, currentColor)
}
}
}
// InversedSurroundedDiagonalLine draws an image with diagonal lines
func InversedSurroundedDiagonalLine() {
if param1 == -1 {
fmt.Println("p1 must be set for IBDL")
os.Exit(-1)
}
if colors == nil {
fmt.Println("colors must be set for IBDL")
os.Exit(-1)
}
extendableDiagonalLine(param1, colors, inversedSurroundedDiagonalLineAdditionalDraw)
}
// BiSymInversedSurroundedDiagonalLine draws an image with diagonal lines and bi symetry
func BiSymInversedSurroundedDiagonalLine() {
if param1 == -1 {
fmt.Println("p1 must be set for IBDL2")
os.Exit(-1)
}
if colors == nil {
fmt.Println("colors must be set for IBDL2")
os.Exit(-1)
}
if param2 != 0 && param2 != 1 && param2 != 2 {
fmt.Println("p2 must be set for IBDL2 with 0 (horizontal), 1 (vertical) or 2 (diagonal)")
os.Exit(-1)
}
extendableBiSymDiagonalLine(param1, colors, param2, inversedSurroundedDiagonalLineAdditionalDraw)
}
// QuadSymInversedSurroundedDiagonalLine draws an image with diagonal lines and quad symetry
func QuadSymInversedSurroundedDiagonalLine() {
if param1 == -1 {
fmt.Println("p1 must be set for IBDL4")
os.Exit(-1)
}
if colors == nil {
fmt.Println("colors must be set for IBDL4")
os.Exit(-1)
}
extendableQuadSymDiagonalLine(param1, colors, inversedSurroundedDiagonalLineAdditionalDraw)
}