Moved artist (now art) into another repo
This commit is contained in:
@@ -2,8 +2,8 @@ package elements
|
||||
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/artist"
|
||||
import "tomo/shatter"
|
||||
import "art"
|
||||
import "art/shatter"
|
||||
|
||||
var boxCase = tomo.C("tomo", "box")
|
||||
|
||||
@@ -61,7 +61,7 @@ func NewVBox (space Space, children ...tomo.Element) (element *Box) {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *Box) Draw (destination artist.Canvas) {
|
||||
func (element *Box) Draw (destination art.Canvas) {
|
||||
rocks := make([]image.Rectangle, element.entity.CountChildren())
|
||||
for index := 0; index < element.entity.CountChildren(); index ++ {
|
||||
rocks[index] = element.entity.Child(index).Entity().Bounds()
|
||||
@@ -69,7 +69,7 @@ func (element *Box) Draw (destination artist.Canvas) {
|
||||
|
||||
tiles := shatter.Shatter(element.entity.Bounds(), rocks...)
|
||||
for _, tile := range tiles {
|
||||
element.entity.DrawBackground(artist.Cut(destination, tile))
|
||||
element.entity.DrawBackground(art.Cut(destination, tile))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ func (element *Box) AdoptExpand (children ...tomo.Element) {
|
||||
|
||||
// DrawBackground draws this element's background pattern to the specified
|
||||
// destination canvas.
|
||||
func (element *Box) DrawBackground (destination artist.Canvas) {
|
||||
func (element *Box) DrawBackground (destination art.Canvas) {
|
||||
element.entity.DrawBackground(destination)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package elements
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/input"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
import "tomo/textdraw"
|
||||
|
||||
var buttonCase = tomo.C("tomo", "button")
|
||||
@@ -42,7 +42,7 @@ func (element *Button) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *Button) Draw (destination artist.Canvas) {
|
||||
func (element *Button) Draw (destination art.Canvas) {
|
||||
state := element.state()
|
||||
bounds := element.entity.Bounds()
|
||||
pattern := element.entity.Theme().Pattern(tomo.PatternButton, state, buttonCase)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package elements
|
||||
|
||||
import "tomo"
|
||||
import "tomo/artist"
|
||||
import "tomo/artist/artutil"
|
||||
import "art"
|
||||
import "art/artutil"
|
||||
|
||||
var cellCase = tomo.C("tomo", "cell")
|
||||
|
||||
@@ -32,7 +32,7 @@ func (element *Cell) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *Cell) Draw (destination artist.Canvas) {
|
||||
func (element *Cell) Draw (destination art.Canvas) {
|
||||
bounds := element.entity.Bounds()
|
||||
pattern := element.entity.Theme().Pattern(tomo.PatternTableCell, element.state(), cellCase)
|
||||
if element.child == nil {
|
||||
@@ -56,7 +56,7 @@ func (element *Cell) Layout () {
|
||||
|
||||
// DrawBackground draws this element's background pattern to the specified
|
||||
// destination canvas.
|
||||
func (element *Cell) DrawBackground (destination artist.Canvas) {
|
||||
func (element *Cell) DrawBackground (destination art.Canvas) {
|
||||
element.entity.Theme().Pattern(tomo.PatternTableCell, element.state(), cellCase).
|
||||
Draw(destination, element.entity.Bounds())
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package elements
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/input"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
import "tomo/textdraw"
|
||||
|
||||
var checkboxCase = tomo.C("tomo", "checkbox")
|
||||
@@ -39,7 +39,7 @@ func (element *Checkbox) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *Checkbox) Draw (destination artist.Canvas) {
|
||||
func (element *Checkbox) Draw (destination art.Canvas) {
|
||||
bounds := element.entity.Bounds()
|
||||
boxBounds := image.Rect(0, 0, bounds.Dy(), bounds.Dy()).Add(bounds.Min)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package elements
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/input"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
import "tomo/ability"
|
||||
import "tomo/textdraw"
|
||||
|
||||
@@ -53,7 +53,7 @@ func (element *ComboBox) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *ComboBox) Draw (destination artist.Canvas) {
|
||||
func (element *ComboBox) Draw (destination art.Canvas) {
|
||||
state := element.state()
|
||||
bounds := element.entity.Bounds()
|
||||
pattern := element.entity.Theme().Pattern(tomo.PatternButton, state, comboBoxCase)
|
||||
|
||||
@@ -4,9 +4,9 @@ import "image"
|
||||
import "path/filepath"
|
||||
import "tomo"
|
||||
import "tomo/input"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
import "tomo/ability"
|
||||
import "tomo/shatter"
|
||||
import "art/shatter"
|
||||
|
||||
// TODO: base on flow implementation of list. also be able to switch to a table
|
||||
// variant for a more information dense view.
|
||||
@@ -52,7 +52,7 @@ func NewDirectory (
|
||||
return
|
||||
}
|
||||
|
||||
func (element *Directory) Draw (destination artist.Canvas) {
|
||||
func (element *Directory) Draw (destination art.Canvas) {
|
||||
rocks := make([]image.Rectangle, element.entity.CountChildren())
|
||||
for index := 0; index < element.entity.CountChildren(); index ++ {
|
||||
rocks[index] = element.entity.Child(index).Entity().Bounds()
|
||||
@@ -60,7 +60,7 @@ func (element *Directory) Draw (destination artist.Canvas) {
|
||||
|
||||
tiles := shatter.Shatter(element.entity.Bounds(), rocks...)
|
||||
for _, tile := range tiles {
|
||||
element.DrawBackground(artist.Cut(destination, tile))
|
||||
element.DrawBackground(art.Cut(destination, tile))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ func (element *Directory) ScrollAxes () (horizontal, vertical bool) {
|
||||
return false, true
|
||||
}
|
||||
|
||||
func (element *Directory) DrawBackground (destination artist.Canvas) {
|
||||
func (element *Directory) DrawBackground (destination art.Canvas) {
|
||||
element.entity.Theme().Pattern(tomo.PatternPinboard, tomo.State { }, directoryCase).
|
||||
Draw(destination, element.entity.Bounds())
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ package elements
|
||||
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
import "tomo/ability"
|
||||
import "tomo/shatter"
|
||||
import "art/shatter"
|
||||
|
||||
var documentCase = tomo.C("tomo", "document")
|
||||
|
||||
@@ -33,7 +33,7 @@ func NewDocument (children ...tomo.Element) (element *Document) {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *Document) Draw (destination artist.Canvas) {
|
||||
func (element *Document) Draw (destination art.Canvas) {
|
||||
rocks := make([]image.Rectangle, element.entity.CountChildren())
|
||||
for index := 0; index < element.entity.CountChildren(); index ++ {
|
||||
rocks[index] = element.entity.Child(index).Entity().Bounds()
|
||||
@@ -41,7 +41,7 @@ func (element *Document) Draw (destination artist.Canvas) {
|
||||
|
||||
tiles := shatter.Shatter(element.entity.Bounds(), rocks...)
|
||||
for _, tile := range tiles {
|
||||
element.entity.DrawBackground(artist.Cut(destination, tile))
|
||||
element.entity.DrawBackground(art.Cut(destination, tile))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ func (element *Document) HandleChildFlexibleHeightChange (child ability.Flexible
|
||||
|
||||
// DrawBackground draws this element's background pattern to the specified
|
||||
// destination canvas.
|
||||
func (element *Document) DrawBackground (destination artist.Canvas) {
|
||||
func (element *Document) DrawBackground (destination art.Canvas) {
|
||||
element.entity.DrawBackground(destination)
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import "io/fs"
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/input"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
|
||||
var fileCase = tomo.C("files", "file")
|
||||
|
||||
@@ -45,7 +45,7 @@ func (element *File) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *File) Draw (destination artist.Canvas) {
|
||||
func (element *File) Draw (destination art.Canvas) {
|
||||
// background
|
||||
state := element.state()
|
||||
bounds := element.entity.Bounds()
|
||||
@@ -199,7 +199,7 @@ func (element *File) state () tomo.State {
|
||||
}
|
||||
}
|
||||
|
||||
func (element *File) icon () artist.Icon {
|
||||
func (element *File) icon () art.Icon {
|
||||
return element.entity.Theme().Icon(element.iconID, tomo.IconSizeLarge, fileCase)
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import "math"
|
||||
import "image"
|
||||
import "image/color"
|
||||
import "tomo"
|
||||
import "tomo/artist"
|
||||
import "tomo/artist/shapes"
|
||||
import "art"
|
||||
import "art/shapes"
|
||||
|
||||
var clockCase = tomo.C("tomo", "clock")
|
||||
|
||||
@@ -30,7 +30,7 @@ func (element *AnalogClock) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *AnalogClock) Draw (destination artist.Canvas) {
|
||||
func (element *AnalogClock) Draw (destination art.Canvas) {
|
||||
bounds := element.entity.Bounds()
|
||||
|
||||
state := tomo.State { }
|
||||
@@ -71,7 +71,7 @@ func (element *AnalogClock) HandleThemeChange () {
|
||||
}
|
||||
|
||||
func (element *AnalogClock) radialLine (
|
||||
destination artist.Canvas,
|
||||
destination art.Canvas,
|
||||
source color.RGBA,
|
||||
inner float64,
|
||||
outer float64,
|
||||
|
||||
@@ -3,8 +3,8 @@ package fun
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/input"
|
||||
import "tomo/artist"
|
||||
import "tomo/artist/artutil"
|
||||
import "art"
|
||||
import "art/artutil"
|
||||
import "tomo/elements/fun/music"
|
||||
|
||||
var pianoCase = tomo.C("tomo", "piano")
|
||||
@@ -57,7 +57,7 @@ func (element *Piano) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *Piano) Draw (destination artist.Canvas) {
|
||||
func (element *Piano) Draw (destination art.Canvas) {
|
||||
element.recalculate()
|
||||
|
||||
state := tomo.State {
|
||||
@@ -304,7 +304,7 @@ func (element *Piano) recalculate () {
|
||||
}
|
||||
|
||||
func (element *Piano) drawFlat (
|
||||
destination artist.Canvas,
|
||||
destination art.Canvas,
|
||||
bounds image.Rectangle,
|
||||
pressed bool,
|
||||
state tomo.State,
|
||||
@@ -315,7 +315,7 @@ func (element *Piano) drawFlat (
|
||||
}
|
||||
|
||||
func (element *Piano) drawSharp (
|
||||
destination artist.Canvas,
|
||||
destination art.Canvas,
|
||||
bounds image.Rectangle,
|
||||
pressed bool,
|
||||
state tomo.State,
|
||||
|
||||
@@ -2,7 +2,7 @@ package elements
|
||||
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
|
||||
var iconCase = tomo.C("tomo", "icon")
|
||||
|
||||
@@ -44,7 +44,7 @@ func (element *Icon) HandleThemeChange () {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *Icon) Draw (destination artist.Canvas) {
|
||||
func (element *Icon) Draw (destination art.Canvas) {
|
||||
if element.entity == nil { return }
|
||||
|
||||
bounds := element.entity.Bounds()
|
||||
@@ -65,7 +65,7 @@ func (element *Icon) Draw (destination artist.Canvas) {
|
||||
}
|
||||
}
|
||||
|
||||
func (element *Icon) icon () artist.Icon {
|
||||
func (element *Icon) icon () art.Icon {
|
||||
return element.entity.Theme().Icon(element.id, element.size, iconCase)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,20 +2,20 @@ package elements
|
||||
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/artist"
|
||||
import "tomo/artist/patterns"
|
||||
import "art"
|
||||
import "art/patterns"
|
||||
|
||||
// TODO: this element is lame need to make it better
|
||||
|
||||
// Image is an element capable of displaying an image.
|
||||
type Image struct {
|
||||
entity tomo.Entity
|
||||
buffer artist.Canvas
|
||||
buffer art.Canvas
|
||||
}
|
||||
|
||||
// NewImage creates a new image element.
|
||||
func NewImage (image image.Image) (element *Image) {
|
||||
element = &Image { buffer: artist.FromImage(image) }
|
||||
element = &Image { buffer: art.FromImage(image) }
|
||||
element.entity = tomo.GetBackend().NewEntity(element)
|
||||
bounds := element.buffer.Bounds()
|
||||
element.entity.SetMinimumSize(bounds.Dx(), bounds.Dy())
|
||||
@@ -28,7 +28,7 @@ func (element *Image) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *Image) Draw (destination artist.Canvas) {
|
||||
func (element *Image) Draw (destination art.Canvas) {
|
||||
if element.entity == nil { return }
|
||||
(patterns.Texture { Canvas: element.buffer }).
|
||||
Draw(destination, element.entity.Bounds())
|
||||
|
||||
@@ -5,7 +5,7 @@ import "golang.org/x/image/math/fixed"
|
||||
import "tomo"
|
||||
import "tomo/data"
|
||||
import "tomo/input"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
import "tomo/textdraw"
|
||||
|
||||
var labelCase = tomo.C("tomo", "label")
|
||||
@@ -48,7 +48,7 @@ func (element *Label) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *Label) Draw (destination artist.Canvas) {
|
||||
func (element *Label) Draw (destination art.Canvas) {
|
||||
bounds := element.entity.Bounds()
|
||||
|
||||
if element.wrap {
|
||||
|
||||
@@ -3,9 +3,9 @@ package elements
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/input"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
import "tomo/ability"
|
||||
import "tomo/artist/artutil"
|
||||
import "art/artutil"
|
||||
|
||||
type list struct {
|
||||
container
|
||||
@@ -61,7 +61,7 @@ func (element *list) init (children ...tomo.Element) {
|
||||
element.Adopt(children...)
|
||||
}
|
||||
|
||||
func (element *list) Draw (destination artist.Canvas) {
|
||||
func (element *list) Draw (destination art.Canvas) {
|
||||
rocks := make([]image.Rectangle, element.entity.CountChildren())
|
||||
for index := 0; index < element.entity.CountChildren(); index ++ {
|
||||
rocks[index] = element.entity.Child(index).Entity().Bounds()
|
||||
@@ -274,7 +274,7 @@ func (element *list) HandleKeyDown (key input.Key, modifiers input.Modifiers) {
|
||||
|
||||
func (element *list) HandleKeyUp(key input.Key, modifiers input.Modifiers) { }
|
||||
|
||||
func (element *list) DrawBackground (destination artist.Canvas) {
|
||||
func (element *list) DrawBackground (destination art.Canvas) {
|
||||
element.entity.DrawBackground(destination)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package elements
|
||||
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
|
||||
var progressBarCase = tomo.C("tomo", "progressBar")
|
||||
|
||||
@@ -29,7 +29,7 @@ func (element *ProgressBar) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *ProgressBar) Draw (destination artist.Canvas) {
|
||||
func (element *ProgressBar) Draw (destination art.Canvas) {
|
||||
bounds := element.entity.Bounds()
|
||||
|
||||
pattern := element.entity.Theme().Pattern(tomo.PatternSunken, tomo.State { }, progressBarCase)
|
||||
|
||||
@@ -3,7 +3,7 @@ package elements
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/input"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
import "tomo/ability"
|
||||
|
||||
var scrollCase = tomo.C("tomo", "scroll")
|
||||
@@ -76,7 +76,7 @@ func (element *Scroll) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *Scroll) Draw (destination artist.Canvas) {
|
||||
func (element *Scroll) Draw (destination art.Canvas) {
|
||||
if element.horizontal != nil && element.vertical != nil {
|
||||
bounds := element.entity.Bounds()
|
||||
bounds.Min = image.Pt (
|
||||
@@ -84,7 +84,7 @@ func (element *Scroll) Draw (destination artist.Canvas) {
|
||||
bounds.Max.Y - element.horizontal.Entity().Bounds().Dy())
|
||||
state := tomo.State { }
|
||||
deadArea := element.entity.Theme().Pattern(tomo.PatternDead, state, scrollCase)
|
||||
deadArea.Draw(artist.Cut(destination, bounds), bounds)
|
||||
deadArea.Draw(art.Cut(destination, bounds), bounds)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ func (element *Scroll) Layout () {
|
||||
|
||||
// DrawBackground draws this element's background pattern to the specified
|
||||
// destination canvas.
|
||||
func (element *Scroll) DrawBackground (destination artist.Canvas) {
|
||||
func (element *Scroll) DrawBackground (destination art.Canvas) {
|
||||
element.entity.DrawBackground(destination)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package elements
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/input"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
|
||||
// ScrollBar is an element similar to Slider, but it has special behavior that
|
||||
// makes it well suited for controlling the viewport position on one axis of a
|
||||
@@ -63,7 +63,7 @@ func (element *ScrollBar) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *ScrollBar) Draw (destination artist.Canvas) {
|
||||
func (element *ScrollBar) Draw (destination art.Canvas) {
|
||||
element.recalculate()
|
||||
|
||||
bounds := element.entity.Bounds()
|
||||
|
||||
@@ -3,7 +3,7 @@ package elements
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/input"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
|
||||
// Slider is a slider control with a floating point value between zero and one.
|
||||
type Slider struct {
|
||||
@@ -59,7 +59,7 @@ func (element *slider) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *slider) Draw (destination artist.Canvas) {
|
||||
func (element *slider) Draw (destination art.Canvas) {
|
||||
bounds := element.entity.Bounds()
|
||||
element.track = element.entity.Theme().Padding(tomo.PatternGutter, element.c).Apply(bounds)
|
||||
if element.vertical {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package elements
|
||||
|
||||
import "tomo"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
|
||||
var spacerCase = tomo.C("tomo", "spacer")
|
||||
|
||||
@@ -32,7 +32,7 @@ func (element *Spacer) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *Spacer) Draw (destination artist.Canvas) {
|
||||
func (element *Spacer) Draw (destination art.Canvas) {
|
||||
bounds := element.entity.Bounds()
|
||||
|
||||
if element.line {
|
||||
|
||||
@@ -3,7 +3,7 @@ package elements
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/input"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
import "tomo/textdraw"
|
||||
|
||||
var switchCase = tomo.C("tomo", "switch")
|
||||
@@ -44,7 +44,7 @@ func (element *Switch) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *Switch) Draw (destination artist.Canvas) {
|
||||
func (element *Switch) Draw (destination art.Canvas) {
|
||||
bounds := element.entity.Bounds()
|
||||
handleBounds := image.Rect(0, 0, bounds.Dy(), bounds.Dy()).Add(bounds.Min)
|
||||
gutterBounds := image.Rect(0, 0, bounds.Dy() * 2, bounds.Dy()).Add(bounds.Min)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -6,11 +6,11 @@ import "image"
|
||||
import "tomo"
|
||||
import "tomo/data"
|
||||
import "tomo/input"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
import "tomo/textdraw"
|
||||
import "tomo/textmanip"
|
||||
import "tomo/fixedutil"
|
||||
import "tomo/artist/shapes"
|
||||
import "art/shapes"
|
||||
|
||||
var textBoxCase = tomo.C("tomo", "textBox")
|
||||
|
||||
@@ -60,13 +60,13 @@ func (element *TextBox) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *TextBox) Draw (destination artist.Canvas) {
|
||||
func (element *TextBox) Draw (destination art.Canvas) {
|
||||
bounds := element.entity.Bounds()
|
||||
|
||||
state := element.state()
|
||||
pattern := element.entity.Theme().Pattern(tomo.PatternInput, state, textBoxCase)
|
||||
padding := element.entity.Theme().Padding(tomo.PatternInput, textBoxCase)
|
||||
innerCanvas := artist.Cut(destination, padding.Apply(bounds))
|
||||
innerCanvas := art.Cut(destination, padding.Apply(bounds))
|
||||
pattern.Draw(destination, bounds)
|
||||
offset := element.textOffset()
|
||||
|
||||
@@ -208,8 +208,8 @@ func (element *TextBox) textOffset () image.Point {
|
||||
innerBounds := padding.Apply(bounds)
|
||||
textHeight := element.valueDrawer.LineHeight().Round()
|
||||
return bounds.Min.Add (image.Pt (
|
||||
padding[artist.SideLeft] - element.scroll,
|
||||
padding[artist.SideTop] + (innerBounds.Dy() - textHeight) / 2))
|
||||
padding[art.SideLeft] - element.scroll,
|
||||
padding[art.SideTop] + (innerBounds.Dy() - textHeight) / 2))
|
||||
}
|
||||
|
||||
func (element *TextBox) atPosition (position image.Point) int {
|
||||
|
||||
@@ -3,7 +3,7 @@ package elements
|
||||
import "image"
|
||||
import "tomo"
|
||||
import "tomo/input"
|
||||
import "tomo/artist"
|
||||
import "art"
|
||||
import "tomo/textdraw"
|
||||
|
||||
var toggleButtonCase = tomo.C("tomo", "toggleButton")
|
||||
@@ -47,7 +47,7 @@ func (element *ToggleButton) Entity () tomo.Entity {
|
||||
}
|
||||
|
||||
// Draw causes the element to draw to the specified destination canvas.
|
||||
func (element *ToggleButton) Draw (destination artist.Canvas) {
|
||||
func (element *ToggleButton) Draw (destination art.Canvas) {
|
||||
state := element.state()
|
||||
bounds := element.entity.Bounds()
|
||||
pattern := element.entity.Theme().Pattern(tomo.PatternButton, state, toggleButtonCase)
|
||||
|
||||
Reference in New Issue
Block a user