diff --git a/artist/artutil/util.go b/artist/artutil/util.go index 2858dde..68d115c 100644 --- a/artist/artutil/util.go +++ b/artist/artutil/util.go @@ -5,18 +5,17 @@ package artutil import "image" import "image/color" import "git.tebibyte.media/sashakoshka/tomo/artist" -import "git.tebibyte.media/sashakoshka/tomo/canvas" import "git.tebibyte.media/sashakoshka/tomo/shatter" // Fill fills the destination canvas with the given pattern. -func Fill (destination canvas.Canvas, source artist.Pattern) (updated image.Rectangle) { +func Fill (destination artist.Canvas, source artist.Pattern) (updated image.Rectangle) { source.Draw(destination, destination.Bounds()) return destination.Bounds() } // DrawClip lets you draw several subsets of a pattern at once. func DrawClip ( - destination canvas.Canvas, + destination artist.Canvas, source artist.Pattern, bounds image.Rectangle, subsets ...image.Rectangle, @@ -24,7 +23,7 @@ func DrawClip ( updatedRegion image.Rectangle, ) { for _, subset := range subsets { - source.Draw(canvas.Cut(destination, subset), bounds) + source.Draw(artist.Cut(destination, subset), bounds) updatedRegion = updatedRegion.Union(subset) } return @@ -33,7 +32,7 @@ func DrawClip ( // DrawShatter is like an inverse of DrawClip, drawing nothing in the areas // specified by "rocks". func DrawShatter ( - destination canvas.Canvas, + destination artist.Canvas, source artist.Pattern, bounds image.Rectangle, rocks ...image.Rectangle, @@ -48,8 +47,8 @@ func DrawShatter ( // resulting canvas can be sourced from shape drawing functions. I beg of you // please do not call this every time you need to draw a shape with a pattern on // it because that is horrible and cruel to the computer. -func AllocateSample (source artist.Pattern, width, height int) canvas.Canvas { - allocated := canvas.NewBasicCanvas(width, height) +func AllocateSample (source artist.Pattern, width, height int) artist.Canvas { + allocated := artist.NewBasicCanvas(width, height) Fill(allocated, source) return allocated } diff --git a/artist/patterns/border.go b/artist/patterns/border.go index eafda13..b86962f 100644 --- a/artist/patterns/border.go +++ b/artist/patterns/border.go @@ -1,7 +1,6 @@ package patterns import "image" -import "git.tebibyte.media/sashakoshka/tomo/canvas" import "git.tebibyte.media/sashakoshka/tomo/artist" // Border is a pattern that behaves similarly to border-image in CSS. It divides @@ -31,20 +30,20 @@ import "git.tebibyte.media/sashakoshka/tomo/artist" // This pattern can be used to make a static image texture into something that // responds well to being resized. type Border struct { - canvas.Canvas + artist.Canvas artist.Inset } // Draw draws the border pattern onto the destination canvas within the given // bounds. -func (pattern Border) Draw (destination canvas.Canvas, bounds image.Rectangle) { +func (pattern Border) Draw (destination artist.Canvas, bounds image.Rectangle) { drawBounds := bounds.Canon().Intersect(destination.Bounds()) if drawBounds.Empty() { return } srcSections := nonasect(pattern.Bounds(), pattern.Inset) srcTextures := [9]Texture { } for index, section := range srcSections { - srcTextures[index].Canvas = canvas.Cut(pattern, section) + srcTextures[index].Canvas = artist.Cut(pattern, section) } dstSections := nonasect(bounds, pattern.Inset) diff --git a/artist/patterns/texture.go b/artist/patterns/texture.go index 395942b..72869a7 100644 --- a/artist/patterns/texture.go +++ b/artist/patterns/texture.go @@ -1,18 +1,18 @@ package patterns import "image" -import "git.tebibyte.media/sashakoshka/tomo/canvas" +import "git.tebibyte.media/sashakoshka/tomo/artist" // Texture is a pattern that tiles the content of a canvas both horizontally and // vertically. type Texture struct { - canvas.Canvas + artist.Canvas } // Draw tiles the pattern's canvas within the given bounds. The minimum // point of the pattern's canvas will be lined up with the minimum point of the // bounding rectangle. -func (pattern Texture) Draw (destination canvas.Canvas, bounds image.Rectangle) { +func (pattern Texture) Draw (destination artist.Canvas, bounds image.Rectangle) { dstBounds := bounds.Canon().Intersect(destination.Bounds()) if dstBounds.Empty() { return } diff --git a/artist/patterns/uniform.go b/artist/patterns/uniform.go index 173367a..06b9bbb 100644 --- a/artist/patterns/uniform.go +++ b/artist/patterns/uniform.go @@ -2,19 +2,19 @@ package patterns import "image" import "image/color" -import "git.tebibyte.media/sashakoshka/tomo/canvas" import "git.tebibyte.media/sashakoshka/tomo/artist" import "git.tebibyte.media/sashakoshka/tomo/artist/shapes" +import "git.tebibyte.media/sashakoshka/tomo/artist/artutil" // Uniform is a pattern that draws a solid color. type Uniform color.RGBA // Draw fills the bounding rectangle with the pattern's color. -func (pattern Uniform) Draw (destination canvas.Canvas, bounds image.Rectangle) { +func (pattern Uniform) Draw (destination artist.Canvas, bounds image.Rectangle) { shapes.FillColorRectangle(destination, color.RGBA(pattern), bounds) } // Uhex creates a new Uniform pattern from an RGBA integer value. func Uhex (color uint32) (uniform Uniform) { - return Uniform(artist.Hex(color)) + return Uniform(artutil.Hex(color)) } diff --git a/artist/shapes/ellipse.go b/artist/shapes/ellipse.go index c30041d..f5fae0d 100644 --- a/artist/shapes/ellipse.go +++ b/artist/shapes/ellipse.go @@ -3,7 +3,7 @@ package shapes import "math" import "image" import "image/color" -import "git.tebibyte.media/sashakoshka/tomo/canvas" +import "git.tebibyte.media/sashakoshka/tomo/artist" // TODO: redo fill ellipse, stroke ellipse, etc. so that it only takes in // destination and source, using the bounds of destination as the bounds of the @@ -11,8 +11,8 @@ import "git.tebibyte.media/sashakoshka/tomo/canvas" // of both canvases. func FillEllipse ( - destination canvas.Canvas, - source canvas.Canvas, + destination artist.Canvas, + source artist.Canvas, bounds image.Rectangle, ) ( updatedRegion image.Rectangle, @@ -42,8 +42,8 @@ func FillEllipse ( } func StrokeEllipse ( - destination canvas.Canvas, - source canvas.Canvas, + destination artist.Canvas, + source artist.Canvas, bounds image.Rectangle, weight int, ) { @@ -170,7 +170,7 @@ func (context ellipsePlottingContext) plotEllipse () { // FillColorEllipse fills an ellipse within the destination canvas with a solid // color. func FillColorEllipse ( - destination canvas.Canvas, + destination artist.Canvas, color color.RGBA, bounds image.Rectangle, ) ( @@ -196,7 +196,7 @@ func FillColorEllipse ( // StrokeColorEllipse is similar to FillColorEllipse, but it draws an inset // outline of an ellipse instead. func StrokeColorEllipse ( - destination canvas.Canvas, + destination artist.Canvas, color color.RGBA, bounds image.Rectangle, weight int, diff --git a/artist/shapes/line.go b/artist/shapes/line.go index 1d81f94..4593e4b 100644 --- a/artist/shapes/line.go +++ b/artist/shapes/line.go @@ -2,12 +2,12 @@ package shapes import "image" import "image/color" -import "git.tebibyte.media/sashakoshka/tomo/canvas" +import "git.tebibyte.media/sashakoshka/tomo/artist" // ColorLine draws a line from one point to another with the specified weight // and color. func ColorLine ( - destination canvas.Canvas, + destination artist.Canvas, color color.RGBA, weight int, min image.Point, diff --git a/artist/shapes/rectangle.go b/artist/shapes/rectangle.go index 968e00c..6282233 100644 --- a/artist/shapes/rectangle.go +++ b/artist/shapes/rectangle.go @@ -2,14 +2,14 @@ package shapes import "image" import "image/color" -import "git.tebibyte.media/sashakoshka/tomo/canvas" +import "git.tebibyte.media/sashakoshka/tomo/artist" import "git.tebibyte.media/sashakoshka/tomo/shatter" // TODO: return updatedRegion for all routines in this package func FillRectangle ( - destination canvas.Canvas, - source canvas.Canvas, + destination artist.Canvas, + source artist.Canvas, bounds image.Rectangle, ) ( updatedRegion image.Rectangle, @@ -38,8 +38,8 @@ func FillRectangle ( } func StrokeRectangle ( - destination canvas.Canvas, - source canvas.Canvas, + destination artist.Canvas, + source artist.Canvas, bounds image.Rectangle, weight int, ) ( @@ -55,8 +55,8 @@ func StrokeRectangle ( // FillRectangleShatter is like FillRectangle, but it does not draw in areas // specified in "rocks". func FillRectangleShatter ( - destination canvas.Canvas, - source canvas.Canvas, + destination artist.Canvas, + source artist.Canvas, bounds image.Rectangle, rocks ...image.Rectangle, ) ( @@ -65,7 +65,7 @@ func FillRectangleShatter ( tiles := shatter.Shatter(bounds, rocks...) for _, tile := range tiles { FillRectangle ( - canvas.Cut(destination, tile), + artist.Cut(destination, tile), source, tile) updatedRegion = updatedRegion.Union(tile) } @@ -75,7 +75,7 @@ func FillRectangleShatter ( // FillColorRectangle fills a rectangle within the destination canvas with a // solid color. func FillColorRectangle ( - destination canvas.Canvas, + destination artist.Canvas, color color.RGBA, bounds image.Rectangle, ) ( @@ -97,7 +97,7 @@ func FillColorRectangle ( // FillColorRectangleShatter is like FillColorRectangle, but it does not draw in // areas specified in "rocks". func FillColorRectangleShatter ( - destination canvas.Canvas, + destination artist.Canvas, color color.RGBA, bounds image.Rectangle, rocks ...image.Rectangle, @@ -115,7 +115,7 @@ func FillColorRectangleShatter ( // StrokeColorRectangle is similar to FillColorRectangle, but it draws an inset // outline of the given rectangle instead. func StrokeColorRectangle ( - destination canvas.Canvas, + destination artist.Canvas, color color.RGBA, bounds image.Rectangle, weight int, diff --git a/backends/all/all.go b/backends/all/all.go deleted file mode 100644 index fcb293b..0000000 --- a/backends/all/all.go +++ /dev/null @@ -1,4 +0,0 @@ -// Package all links most common backends. -package all - -import _ "git.tebibyte.media/sashakoshka/tomo/backends/x" diff --git a/backends/doc.go b/backends/doc.go deleted file mode 100644 index d32bd15..0000000 --- a/backends/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package backends contains sub-packages that register backends with tomo when -// linked into a program. -package backends diff --git a/backends/x/doc.go b/plugins/x/x/doc.go similarity index 100% rename from backends/x/doc.go rename to plugins/x/x/doc.go diff --git a/backends/x/encoding.go b/plugins/x/x/encoding.go similarity index 100% rename from backends/x/encoding.go rename to plugins/x/x/encoding.go diff --git a/backends/x/entity.go b/plugins/x/x/entity.go similarity index 99% rename from backends/x/entity.go rename to plugins/x/x/entity.go index b8a097b..f15794f 100644 --- a/backends/x/entity.go +++ b/plugins/x/x/entity.go @@ -2,7 +2,7 @@ package x import "image" import "git.tebibyte.media/sashakoshka/tomo" -import "git.tebibyte.media/sashakoshka/tomo/canvas" +import "git.tebibyte.media/sashakoshka/tomo/artist" type entity struct { window *window diff --git a/backends/x/event.go b/plugins/x/x/event.go similarity index 100% rename from backends/x/event.go rename to plugins/x/x/event.go diff --git a/backends/x/selection.go b/plugins/x/x/selection.go similarity index 100% rename from backends/x/selection.go rename to plugins/x/x/selection.go diff --git a/backends/x/selectionclaim.go b/plugins/x/x/selectionclaim.go similarity index 100% rename from backends/x/selectionclaim.go rename to plugins/x/x/selectionclaim.go diff --git a/backends/x/system.go b/plugins/x/x/system.go similarity index 98% rename from backends/x/system.go rename to plugins/x/x/system.go index fcc9e4a..6522108 100644 --- a/backends/x/system.go +++ b/plugins/x/x/system.go @@ -2,7 +2,7 @@ package x import "image" import "git.tebibyte.media/sashakoshka/tomo" -import "git.tebibyte.media/sashakoshka/tomo/canvas" +import "git.tebibyte.media/sashakoshka/tomo/artist" import "git.tebibyte.media/sashakoshka/tomo/default/theme" import "git.tebibyte.media/sashakoshka/tomo/default/config" diff --git a/backends/x/window.go b/plugins/x/x/window.go similarity index 99% rename from backends/x/window.go rename to plugins/x/x/window.go index ad39a79..0ca9271 100644 --- a/backends/x/window.go +++ b/plugins/x/x/window.go @@ -13,7 +13,7 @@ import "github.com/jezek/xgbutil/mousebind" import "github.com/jezek/xgbutil/xgraphics" import "git.tebibyte.media/sashakoshka/tomo" import "git.tebibyte.media/sashakoshka/tomo/data" -import "git.tebibyte.media/sashakoshka/tomo/canvas" +import "git.tebibyte.media/sashakoshka/tomo/artist" type mainWindow struct { *window } type menuWindow struct { *window } diff --git a/backends/x/x.go b/plugins/x/x/x.go similarity index 98% rename from backends/x/x.go rename to plugins/x/x/x.go index 7928f66..ee77e00 100644 --- a/backends/x/x.go +++ b/plugins/x/x/x.go @@ -121,7 +121,3 @@ func (backend *Backend) SetConfig (config tomo.Config) { func (backend *Backend) assert () { if backend == nil { panic("nil backend") } } - -func init () { - tomo.RegisterBackend(NewBackend) -}