AAAAART!
This commit is contained in:
parent
50e9c3b1c9
commit
e3369ab3d4
@ -15,14 +15,13 @@ import "git.tebibyte.media/sashakoshka/tomo/elements/core"
|
|||||||
type Artist struct {
|
type Artist struct {
|
||||||
*core.Core
|
*core.Core
|
||||||
core core.CoreControl
|
core core.CoreControl
|
||||||
cellBounds image.Rectangle
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewArtist creates a new artist test element.
|
// NewArtist creates a new artist test element.
|
||||||
func NewArtist () (element *Artist) {
|
func NewArtist () (element *Artist) {
|
||||||
element = &Artist { }
|
element = &Artist { }
|
||||||
element.Core, element.core = core.NewCore(element.draw)
|
element.Core, element.core = core.NewCore(element.draw)
|
||||||
element.core.SetMinimumSize(480, 600)
|
element.core.SetMinimumSize(240, 360)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,9 +29,6 @@ func (element *Artist) draw () {
|
|||||||
bounds := element.Bounds()
|
bounds := element.Bounds()
|
||||||
artist.FillRectangle(element.core, artist.NewUniform(hex(0)), bounds)
|
artist.FillRectangle(element.core, artist.NewUniform(hex(0)), bounds)
|
||||||
|
|
||||||
element.cellBounds.Max.X = bounds.Min.X + bounds.Dx() / 5
|
|
||||||
element.cellBounds.Max.Y = bounds.Min.Y + (bounds.Dy() - 48) / 8
|
|
||||||
|
|
||||||
drawStart := time.Now()
|
drawStart := time.Now()
|
||||||
|
|
||||||
// 0, 0
|
// 0, 0
|
||||||
@ -158,16 +154,6 @@ func (element *Artist) draw () {
|
|||||||
element.cellAt(x, 4))
|
element.cellAt(x, 4))
|
||||||
}
|
}
|
||||||
|
|
||||||
// how long did that take to render?
|
|
||||||
drawTime := time.Since(drawStart)
|
|
||||||
textDrawer := textdraw.Drawer { }
|
|
||||||
textDrawer.SetFace(defaultfont.FaceRegular)
|
|
||||||
textDrawer.SetText ([]rune (fmt.Sprintf (
|
|
||||||
"%dms\n%dus",
|
|
||||||
drawTime.Milliseconds(),
|
|
||||||
drawTime.Microseconds())))
|
|
||||||
textDrawer.Draw(element.core, uhex(0xFFFFFFFF), image.Pt(8, bounds.Max.Y - 24))
|
|
||||||
|
|
||||||
// 0, 5
|
// 0, 5
|
||||||
artist.FillRectangle (
|
artist.FillRectangle (
|
||||||
element.core,
|
element.core,
|
||||||
@ -292,6 +278,18 @@ func (element *Artist) draw () {
|
|||||||
},
|
},
|
||||||
element.cellAt(3, 7),
|
element.cellAt(3, 7),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// how long did that take to render?
|
||||||
|
drawTime := time.Since(drawStart)
|
||||||
|
textDrawer := textdraw.Drawer { }
|
||||||
|
textDrawer.SetFace(defaultfont.FaceRegular)
|
||||||
|
textDrawer.SetText ([]rune (fmt.Sprintf (
|
||||||
|
"%dms\n%dus",
|
||||||
|
drawTime.Milliseconds(),
|
||||||
|
drawTime.Microseconds())))
|
||||||
|
textDrawer.Draw (
|
||||||
|
element.core, uhex(0xFFFFFFFF),
|
||||||
|
image.Pt(bounds.Min.X + 8, bounds.Max.Y - 24))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *Artist) lines (weight int, bounds image.Rectangle) {
|
func (element *Artist) lines (weight int, bounds image.Rectangle) {
|
||||||
@ -329,9 +327,14 @@ func (element *Artist) lines (weight int, bounds image.Rectangle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (element *Artist) cellAt (x, y int) (image.Rectangle) {
|
func (element *Artist) cellAt (x, y int) (image.Rectangle) {
|
||||||
return element.cellBounds.Add (image.Pt (
|
bounds := element.Bounds()
|
||||||
x * element.cellBounds.Dx(),
|
cellBounds := image.Rectangle { }
|
||||||
y * element.cellBounds.Dy()))
|
cellBounds.Min = bounds.Min
|
||||||
|
cellBounds.Max.X = bounds.Min.X + bounds.Dx() / 5
|
||||||
|
cellBounds.Max.Y = bounds.Min.Y + (bounds.Dy() - 48) / 8
|
||||||
|
return cellBounds.Add (image.Pt (
|
||||||
|
x * cellBounds.Dx(),
|
||||||
|
y * cellBounds.Dy()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func hex (n uint32) (c color.RGBA) {
|
func hex (n uint32) (c color.RGBA) {
|
||||||
|
@ -45,12 +45,14 @@ func run () {
|
|||||||
form.Adopt(basicElements.NewCheckbox("Skin", true), false)
|
form.Adopt(basicElements.NewCheckbox("Skin", true), false)
|
||||||
form.Adopt(basicElements.NewCheckbox("Blood", false), false)
|
form.Adopt(basicElements.NewCheckbox("Blood", false), false)
|
||||||
form.Adopt(basicElements.NewCheckbox("Bone", false), false)
|
form.Adopt(basicElements.NewCheckbox("Bone", false), false)
|
||||||
|
art := testing.NewArtist()
|
||||||
|
|
||||||
list := basicElements.NewList (
|
list := basicElements.NewList (
|
||||||
basicElements.NewListEntry("button", func () { turnPage(button) }),
|
basicElements.NewListEntry("button", func () { turnPage(button) }),
|
||||||
basicElements.NewListEntry("mouse", func () { turnPage(mouse) }),
|
basicElements.NewListEntry("mouse", func () { turnPage(mouse) }),
|
||||||
basicElements.NewListEntry("input", func () { turnPage(input) }),
|
basicElements.NewListEntry("input", func () { turnPage(input) }),
|
||||||
basicElements.NewListEntry("form", func () { turnPage(form) }))
|
basicElements.NewListEntry("form", func () { turnPage(form) }),
|
||||||
|
basicElements.NewListEntry("art", func () { turnPage(art) }))
|
||||||
list.OnNoEntrySelected(func () { turnPage (intro) })
|
list.OnNoEntrySelected(func () { turnPage (intro) })
|
||||||
list.Collapse(96, 0)
|
list.Collapse(96, 0)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user