Moved artist (now art) into another repo

This commit is contained in:
2023-05-03 20:17:48 -04:00
parent 54ea1c283f
commit 501eb34922
36 changed files with 191 additions and 186 deletions

View File

@@ -5,20 +5,20 @@ import "time"
import "image"
import "image/color"
import "tomo"
import "tomo/artist"
import "tomo/shatter"
import "art"
import "art/shatter"
import "tomo/textdraw"
import "tomo/artist/shapes"
import "tomo/artist/artutil"
import "tomo/artist/patterns"
import "art/shapes"
import "art/artutil"
import "art/patterns"
// Artist is an element that displays shapes and patterns drawn by the artist
// Artist is an element that displays shapes and patterns drawn by the art
// package in order to test it.
type Artist struct {
entity tomo.Entity
}
// NewArtist creates a new artist test element.
// NewArtist creates a new art test element.
func NewArtist () (element *Artist) {
element = &Artist { }
element.entity = tomo.GetBackend().NewEntity(element)
@@ -30,7 +30,7 @@ func (element *Artist) Entity () tomo.Entity {
return element.entity
}
func (element *Artist) Draw (destination artist.Canvas) {
func (element *Artist) Draw (destination art.Canvas) {
bounds := element.entity.Bounds()
patterns.Uhex(0x000000FF).Draw(destination, bounds)
@@ -81,7 +81,7 @@ func (element *Artist) Draw (destination artist.Canvas) {
}
tiles := shatter.Shatter(c41.Bounds(), rocks...)
for index, tile := range tiles {
[]artist.Pattern {
[]art.Pattern {
patterns.Uhex(0xFF0000FF),
patterns.Uhex(0x00FF00FF),
patterns.Uhex(0xFF00FFFF),
@@ -115,26 +115,26 @@ func (element *Artist) Draw (destination artist.Canvas) {
c03 := element.cellAt(destination, 0, 3)
patterns.Border {
Canvas: element.thingy(c42),
Inset: artist.Inset { 8, 8, 8, 8 },
Inset: art.Inset { 8, 8, 8, 8 },
}.Draw(c03, c03.Bounds())
// 1, 3
c13 := element.cellAt(destination, 1, 3)
patterns.Border {
Canvas: element.thingy(c42),
Inset: artist.Inset { 8, 8, 8, 8 },
Inset: art.Inset { 8, 8, 8, 8 },
}.Draw(c13, c13.Bounds().Inset(10))
// 2, 3
c23 := element.cellAt(destination, 2, 3)
patterns.Border {
Canvas: element.thingy(c42),
Inset: artist.Inset { 8, 8, 8, 8 },
Inset: art.Inset { 8, 8, 8, 8 },
}.Draw(c23, c23.Bounds())
patterns.Border {
Canvas: element.thingy(c42),
Inset: artist.Inset { 8, 8, 8, 8 },
}.Draw(artist.Cut(c23, c23.Bounds().Inset(16)), c23.Bounds())
Inset: art.Inset { 8, 8, 8, 8 },
}.Draw(art.Cut(c23, c23.Bounds().Inset(16)), c23.Bounds())
// how long did that take to render?
drawTime := time.Since(drawStart)
@@ -142,7 +142,7 @@ func (element *Artist) Draw (destination artist.Canvas) {
textDrawer.SetFace(element.entity.Theme().FontFace (
tomo.FontStyleRegular,
tomo.FontSizeNormal,
tomo.C("tomo", "artist")))
tomo.C("tomo", "art")))
textDrawer.SetText ([]rune (fmt.Sprintf (
"%dms\n%dus",
drawTime.Milliseconds(),
@@ -152,7 +152,7 @@ func (element *Artist) Draw (destination artist.Canvas) {
image.Pt(bounds.Min.X + 8, bounds.Max.Y - 24))
}
func (element *Artist) colorLines (destination artist.Canvas, weight int, bounds image.Rectangle) {
func (element *Artist) colorLines (destination art.Canvas, weight int, bounds image.Rectangle) {
bounds = bounds.Inset(4)
c := artutil.Hex(0xFFFFFFFF)
shapes.ColorLine(destination, c, weight, bounds.Min, bounds.Max)
@@ -186,18 +186,18 @@ func (element *Artist) colorLines (destination artist.Canvas, weight int, bounds
image.Pt(bounds.Min.X + bounds.Dx() / 2, bounds.Max.Y))
}
func (element *Artist) cellAt (destination artist.Canvas, x, y int) (artist.Canvas) {
func (element *Artist) cellAt (destination art.Canvas, x, y int) (art.Canvas) {
bounds := element.entity.Bounds()
cellBounds := image.Rectangle { }
cellBounds.Min = bounds.Min
cellBounds.Max.X = bounds.Min.X + bounds.Dx() / 5
cellBounds.Max.Y = bounds.Min.Y + (bounds.Dy() - 48) / 4
return artist.Cut (destination, cellBounds.Add (image.Pt (
return art.Cut (destination, cellBounds.Add (image.Pt (
x * cellBounds.Dx(),
y * cellBounds.Dy())))
}
func (element *Artist) thingy (destination artist.Canvas) (result artist.Canvas) {
func (element *Artist) thingy (destination art.Canvas) (result art.Canvas) {
bounds := destination.Bounds()
bounds = image.Rect(0, 0, 32, 32).Add(bounds.Min)
shapes.FillColorRectangle(destination, artutil.Hex(0x440000FF), bounds)
@@ -205,5 +205,5 @@ func (element *Artist) thingy (destination artist.Canvas) (result artist.Canvas)
shapes.StrokeColorRectangle(destination, artutil.Hex(0x004400FF), bounds.Inset(4), 1)
shapes.FillColorRectangle(destination, artutil.Hex(0x004444FF), bounds.Inset(12))
shapes.StrokeColorRectangle(destination, artutil.Hex(0x888888FF), bounds.Inset(8), 1)
return artist.Cut(destination, bounds)
return art.Cut(destination, bounds)
}

View File

@@ -3,9 +3,9 @@ package testing
import "image"
import "tomo"
import "tomo/input"
import "tomo/artist"
import "tomo/artist/shapes"
import "tomo/artist/artutil"
import "art"
import "art/shapes"
import "art/artutil"
var mouseCase = tomo.C("tomo", "mouse")
@@ -29,7 +29,7 @@ func (element *Mouse) Entity () tomo.Entity {
return element.entity
}
func (element *Mouse) Draw (destination artist.Canvas) {
func (element *Mouse) Draw (destination art.Canvas) {
bounds := element.entity.Bounds()
accent := element.entity.Theme().Color (
tomo.ColorAccent,