diff --git a/artist/patterns/texture.go b/artist/patterns/texture.go index 897417e..dd575b0 100644 --- a/artist/patterns/texture.go +++ b/artist/patterns/texture.go @@ -20,17 +20,30 @@ func (pattern Texture) Draw (destination canvas.Canvas, clip image.Rectangle) { srcData, srcStride := pattern.Buffer() srcBounds := pattern.Bounds() - point := image.Point { } - for point.Y = bounds.Min.Y; point.Y < bounds.Max.Y; point.Y ++ { - for point.X = bounds.Min.X; point.X < bounds.Max.X; point.X ++ { - srcPoint := point.Sub(realBounds.Min).Add(srcBounds.Min) - - dstIndex := point.X + point.Y * dstStride - srcIndex := - wrap(srcPoint.X, srcBounds.Min.X, srcBounds.Max.X) + - wrap(srcPoint.Y, srcBounds.Min.Y, srcBounds.Max.Y) * srcStride - dstData[dstIndex] = srcData[srcIndex] - }} + dstPoint := image.Point { } + srcPoint := bounds.Min.Sub(realBounds.Min).Add(srcBounds.Min) + srcPoint.X = wrap(srcPoint.X, srcBounds.Min.X, srcBounds.Max.X) + srcPoint.Y = wrap(srcPoint.Y, srcBounds.Min.Y, srcBounds.Max.Y) + + for dstPoint.Y = bounds.Min.Y; dstPoint.Y < bounds.Max.Y; dstPoint.Y ++ { + for dstPoint.X = bounds.Min.X; dstPoint.X < bounds.Max.X; dstPoint.X ++ { + dstIndex := dstPoint.X + dstPoint.Y * dstStride + srcIndex := + srcPoint.X + + srcPoint.Y * srcStride + dstData[dstIndex] = srcData[srcIndex] + + srcPoint.X ++ + if srcPoint.X >= srcBounds.Max.X { + srcPoint.X = srcBounds.Min.X + } + } + + srcPoint.Y ++ + if srcPoint.Y >= srcBounds.Max.Y { + srcPoint.Y = srcBounds.Min.Y + } + } } func wrap (value, min, max int) int { diff --git a/examples/button/main.go b/examples/button/main.go index 7e79a74..ab1b9b4 100644 --- a/examples/button/main.go +++ b/examples/button/main.go @@ -3,6 +3,8 @@ package main import "git.tebibyte.media/sashakoshka/tomo" import "git.tebibyte.media/sashakoshka/tomo/elements/basic" import _ "git.tebibyte.media/sashakoshka/tomo/backends/x" +import _ "net/http/pprof" +import "net/http" func main () { tomo.Run(run) @@ -26,4 +28,9 @@ func run () { window.Adopt(button) window.OnClose(tomo.Stop) window.Show() + + // just some stuff for profiling, this is not needed for tomo + go func () { + http.ListenAndServe("localhost:9090", nil) + } () }