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

@@ -9,14 +9,14 @@ import "golang.org/x/image/font"
import "golang.org/x/image/font/basicfont"
import "tomo"
import "tomo/data"
import "tomo/artist"
import "tomo/artist/artutil"
import "tomo/artist/patterns"
import "art"
import "art/artutil"
import "art/patterns"
//go:embed assets/wintergreen.png
var defaultAtlasBytes []byte
var defaultAtlas artist.Canvas
var defaultTextures [17][9]artist.Pattern
var defaultAtlas art.Canvas
var defaultTextures [17][9]art.Pattern
//go:embed assets/wintergreen-icons-small.png
var defaultIconsSmallAtlasBytes []byte
var defaultIconsSmall [640]binaryIcon
@@ -24,15 +24,15 @@ var defaultIconsSmall [640]binaryIcon
var defaultIconsLargeAtlasBytes []byte
var defaultIconsLarge [640]binaryIcon
func atlasCell (col, row int, border artist.Inset) {
func atlasCell (col, row int, border art.Inset) {
bounds := image.Rect(0, 0, 16, 16).Add(image.Pt(col, row).Mul(16))
defaultTextures[col][row] = patterns.Border {
Canvas: artist.Cut(defaultAtlas, bounds),
Canvas: art.Cut(defaultAtlas, bounds),
Inset: border,
}
}
func atlasCol (col int, border artist.Inset) {
func atlasCol (col int, border art.Inset) {
for index, _ := range defaultTextures[col] {
atlasCell(col, index, border)
}
@@ -43,7 +43,7 @@ type binaryIcon struct {
stride int
}
func (icon binaryIcon) Draw (destination artist.Canvas, color color.RGBA, at image.Point) {
func (icon binaryIcon) Draw (destination art.Canvas, color color.RGBA, at image.Point) {
bounds := icon.Bounds().Add(at).Intersect(destination.Bounds())
point := image.Point { }
data, stride := destination.Buffer()
@@ -85,43 +85,43 @@ func binaryIconFrom (source image.Image, clip image.Rectangle) (icon binaryIcon)
func init () {
defaultAtlasImage, _, _ := image.Decode(bytes.NewReader(defaultAtlasBytes))
defaultAtlas = artist.FromImage(defaultAtlasImage)
defaultAtlas = art.FromImage(defaultAtlasImage)
// PatternDead
atlasCol(0, artist.Inset { })
atlasCol(0, art.Inset { })
// PatternRaised
atlasCol(1, artist.Inset { 6, 6, 6, 6 })
atlasCol(1, art.Inset { 6, 6, 6, 6 })
// PatternSunken
atlasCol(2, artist.Inset { 4, 4, 4, 4 })
atlasCol(2, art.Inset { 4, 4, 4, 4 })
// PatternPinboard
atlasCol(3, artist.Inset { 2, 2, 2, 2 })
atlasCol(3, art.Inset { 2, 2, 2, 2 })
// PatternButton
atlasCol(4, artist.Inset { 6, 6, 6, 6 })
atlasCol(4, art.Inset { 6, 6, 6, 6 })
// PatternInput
atlasCol(5, artist.Inset { 4, 4, 4, 4 })
atlasCol(5, art.Inset { 4, 4, 4, 4 })
// PatternGutter
atlasCol(6, artist.Inset { 7, 7, 7, 7 })
atlasCol(6, art.Inset { 7, 7, 7, 7 })
// PatternHandle
atlasCol(7, artist.Inset { 3, 3, 3, 3 })
atlasCol(7, art.Inset { 3, 3, 3, 3 })
// PatternLine
atlasCol(8, artist.Inset { 1, 1, 1, 1 })
atlasCol(8, art.Inset { 1, 1, 1, 1 })
// PatternMercury
atlasCol(13, artist.Inset { 2, 2, 2, 2 })
atlasCol(13, art.Inset { 2, 2, 2, 2 })
// PatternTableHead:
atlasCol(14, artist.Inset { 4, 4, 4, 4 })
atlasCol(14, art.Inset { 4, 4, 4, 4 })
// PatternTableCell:
atlasCol(15, artist.Inset { 4, 4, 4, 4 })
atlasCol(15, art.Inset { 4, 4, 4, 4 })
// PatternLamp:
atlasCol(16, artist.Inset { 4, 3, 4, 3 })
atlasCol(16, art.Inset { 4, 3, 4, 3 })
// PatternButton: basic.checkbox
atlasCol(9, artist.Inset { 3, 3, 3, 3 })
atlasCol(9, art.Inset { 3, 3, 3, 3 })
// PatternRaised: basic.listEntry
atlasCol(10, artist.Inset { 3, 3, 3, 3 })
atlasCol(10, art.Inset { 3, 3, 3, 3 })
// PatternRaised: fun.flatKey
atlasCol(11, artist.Inset { 3, 3, 5, 3 })
atlasCol(11, art.Inset { 3, 3, 5, 3 })
// PatternRaised: fun.sharpKey
atlasCol(12, artist.Inset { 3, 3, 4, 3 })
atlasCol(12, art.Inset { 3, 3, 4, 3 })
// set up small icons
defaultIconsSmallAtlasImage, _, _ := image.Decode (
@@ -164,7 +164,7 @@ func (Theme) FontFace (style tomo.FontStyle, size tomo.FontSize, c tomo.Case) fo
return basicfont.Face7x13
}
func (Theme) Icon (id tomo.Icon, size tomo.IconSize, c tomo.Case) artist.Icon {
func (Theme) Icon (id tomo.Icon, size tomo.IconSize, c tomo.Case) art.Icon {
if size == tomo.IconSizeLarge {
if id < 0 || int(id) >= len(defaultIconsLarge) {
return nil
@@ -180,12 +180,12 @@ func (Theme) Icon (id tomo.Icon, size tomo.IconSize, c tomo.Case) artist.Icon {
}
}
func (Theme) MimeIcon (data.Mime, tomo.IconSize, tomo.Case) artist.Icon {
func (Theme) MimeIcon (data.Mime, tomo.IconSize, tomo.Case) art.Icon {
// TODO
return nil
}
func (Theme) Pattern (id tomo.Pattern, state tomo.State, c tomo.Case) artist.Pattern {
func (Theme) Pattern (id tomo.Pattern, state tomo.State, c tomo.Case) art.Pattern {
offset := 0; switch {
case state.Disabled: offset = 1
case state.Pressed && state.On: offset = 4
@@ -254,31 +254,31 @@ func (Theme) Color (id tomo.Color, state tomo.State, c tomo.Case) color.RGBA {
} [id])
}
func (Theme) Padding (id tomo.Pattern, c tomo.Case) artist.Inset {
func (Theme) Padding (id tomo.Pattern, c tomo.Case) art.Inset {
switch id {
case tomo.PatternSunken:
if c.Match("tomo", "progressBar", "") {
return artist.I(2, 1, 1, 2)
return art.I(2, 1, 1, 2)
} else if c.Match("tomo", "list", "") {
return artist.I(2)
return art.I(2)
} else if c.Match("tomo", "flowList", "") {
return artist.I(2)
return art.I(2)
} else {
return artist.I(8)
return art.I(8)
}
case tomo.PatternPinboard:
if c.Match("tomo", "piano", "") {
return artist.I(2)
return art.I(2)
} else {
return artist.I(8)
return art.I(8)
}
case tomo.PatternTableCell: return artist.I(5)
case tomo.PatternTableHead: return artist.I(5)
case tomo.PatternGutter: return artist.I(0)
case tomo.PatternLine: return artist.I(1)
case tomo.PatternMercury: return artist.I(5)
case tomo.PatternLamp: return artist.I(5, 5, 5, 6)
default: return artist.I(8)
case tomo.PatternTableCell: return art.I(5)
case tomo.PatternTableHead: return art.I(5)
case tomo.PatternGutter: return art.I(0)
case tomo.PatternLine: return art.I(1)
case tomo.PatternMercury: return art.I(5)
case tomo.PatternLamp: return art.I(5, 5, 5, 6)
default: return art.I(8)
}
}

View File

@@ -2,7 +2,7 @@ package x
import "image"
import "tomo"
import "tomo/artist"
import "art"
import "tomo/ability"
type entity struct {
@@ -159,7 +159,7 @@ func (entity *entity) SetMinimumSize (width, height int) {
}
}
func (entity *entity) DrawBackground (destination artist.Canvas) {
func (entity *entity) DrawBackground (destination art.Canvas) {
if entity.parent != nil {
entity.parent.element.(ability.Container).DrawBackground(destination)
} else if entity.window != nil {

View File

@@ -1,7 +1,7 @@
package x
import "image"
import "tomo/artist"
import "art"
import "tomo/ability"
type entitySet map[*entity] struct { }
@@ -22,7 +22,7 @@ func (set entitySet) Add (entity *entity) {
type system struct {
child *entity
focused *entity
canvas artist.BasicCanvas
canvas art.BasicCanvas
invalidateIgnore bool
drawingInvalid entitySet
@@ -167,7 +167,7 @@ func (system *system) draw () {
for entity := range system.drawingInvalid {
if entity.clippedBounds.Empty() { continue }
entity.element.Draw (artist.Cut (
entity.element.Draw (art.Cut (
system.canvas,
entity.clippedBounds))
finalBounds = finalBounds.Union(entity.clippedBounds)

View File

@@ -13,7 +13,7 @@ import "github.com/jezek/xgbutil/mousebind"
import "github.com/jezek/xgbutil/xgraphics"
import "tomo"
import "tomo/data"
import "tomo/artist"
import "art"
type mainWindow struct { *window }
type menuWindow struct { *window }
@@ -414,7 +414,7 @@ func (window *window) pasteAndPush (region image.Rectangle) {
}
func (window *window) paste (region image.Rectangle) {
canvas := artist.Cut(window.canvas, region)
canvas := art.Cut(window.canvas, region)
data, stride := canvas.Buffer()
bounds := canvas.Bounds().Intersect(window.xCanvas.Bounds())