THICC LINES
This commit is contained in:
parent
268e7981b5
commit
a87d806e54
@ -1,8 +1,11 @@
|
|||||||
package artist
|
package artist
|
||||||
|
|
||||||
import "image"
|
import "image"
|
||||||
|
import "image/color"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
|
|
||||||
|
// TODO: draw thick lines more efficiently
|
||||||
|
|
||||||
// Line draws a line from one point to another with the specified weight and
|
// Line draws a line from one point to another with the specified weight and
|
||||||
// pattern.
|
// pattern.
|
||||||
func Line (
|
func Line (
|
||||||
@ -14,7 +17,6 @@ func Line (
|
|||||||
) (
|
) (
|
||||||
updatedRegion image.Rectangle,
|
updatedRegion image.Rectangle,
|
||||||
) {
|
) {
|
||||||
// TODO: respect weight
|
|
||||||
|
|
||||||
updatedRegion = image.Rectangle { Min: min, Max: max }.Canon()
|
updatedRegion = image.Rectangle { Min: min, Max: max }.Canon()
|
||||||
updatedRegion.Max.X ++
|
updatedRegion.Max.X ++
|
||||||
@ -68,7 +70,8 @@ func lineLow (
|
|||||||
|
|
||||||
for x := min.X; x < max.X; x ++ {
|
for x := min.X; x < max.X; x ++ {
|
||||||
if !(image.Point { x, y }).In(bounds) { break }
|
if !(image.Point { x, y }).In(bounds) { break }
|
||||||
data[x + y * stride] = source.AtWhen(x, y, width, height)
|
squareAround(data, stride, source, x, y, width, height, weight)
|
||||||
|
// data[x + y * stride] = source.AtWhen(x, y, width, height)
|
||||||
if D > 0 {
|
if D > 0 {
|
||||||
y += yi
|
y += yi
|
||||||
D += 2 * (deltaY - deltaX)
|
D += 2 * (deltaY - deltaX)
|
||||||
@ -103,7 +106,8 @@ func lineHigh (
|
|||||||
|
|
||||||
for y := min.Y; y < max.Y; y ++ {
|
for y := min.Y; y < max.Y; y ++ {
|
||||||
if !(image.Point { x, y }).In(bounds) { break }
|
if !(image.Point { x, y }).In(bounds) { break }
|
||||||
data[x + y * stride] = source.AtWhen(x, y, width, height)
|
squareAround(data, stride, source, x, y, width, height, weight)
|
||||||
|
// data[x + y * stride] = source.AtWhen(x, y, width, height)
|
||||||
if D > 0 {
|
if D > 0 {
|
||||||
x += xi
|
x += xi
|
||||||
D += 2 * (deltaX - deltaY)
|
D += 2 * (deltaX - deltaY)
|
||||||
@ -118,3 +122,20 @@ func abs (in int) (out int) {
|
|||||||
out = in
|
out = in
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func squareAround (
|
||||||
|
data []color.RGBA,
|
||||||
|
stride int,
|
||||||
|
source Pattern,
|
||||||
|
x, y, patternWidth, patternHeight, diameter int,
|
||||||
|
) {
|
||||||
|
minY := y - diameter
|
||||||
|
minX := x - diameter
|
||||||
|
maxY := y + diameter
|
||||||
|
maxX := x + diameter
|
||||||
|
for y = minY; y < maxY; y ++ {
|
||||||
|
for x = minX; x < maxX; x ++ {
|
||||||
|
data[x + y * stride] =
|
||||||
|
source.AtWhen(x, y, patternWidth, patternHeight)
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
@ -63,7 +63,7 @@ func (element *Artist) Resize (width, height int) {
|
|||||||
},
|
},
|
||||||
element.cellAt(3, 0))
|
element.cellAt(3, 0))
|
||||||
|
|
||||||
// 0, 1 - 0, 3
|
// 0, 1 - 3, 1
|
||||||
for x := 0; x < 4; x ++ {
|
for x := 0; x < 4; x ++ {
|
||||||
artist.FillRectangle (
|
artist.FillRectangle (
|
||||||
element,
|
element,
|
||||||
@ -76,8 +76,9 @@ func (element *Artist) Resize (width, height int) {
|
|||||||
element.cellAt(x, 1))
|
element.cellAt(x, 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 0, 2 - 3, 2
|
||||||
for x := 0; x < 4; x ++ {
|
for x := 0; x < 4; x ++ {
|
||||||
element.lines(x, element.cellAt(x, 2))
|
element.lines(x + 1, element.cellAt(x, 2))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user