Replaced the chiseled box with the chiseled pattern
This commit is contained in:
		
							parent
							
								
									9540812a04
								
							
						
					
					
						commit
						e83dde2d21
					
				
							
								
								
									
										128
									
								
								artist/chisel.go
									
									
									
									
									
								
							
							
						
						
									
										128
									
								
								artist/chisel.go
									
									
									
									
									
								
							@ -1,116 +1,30 @@
 | 
				
			|||||||
package artist
 | 
					package artist
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import "image"
 | 
					 | 
				
			||||||
import "image/color"
 | 
					import "image/color"
 | 
				
			||||||
import "git.tebibyte.media/sashakoshka/tomo"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ShadingProfile contains shading information that can be used to draw chiseled
 | 
					// Chiseled is a pattern that has a highlight section and a shadow section.
 | 
				
			||||||
// objects.
 | 
					type Chiseled struct {
 | 
				
			||||||
type ShadingProfile struct {
 | 
						Highlight Pattern
 | 
				
			||||||
	Highlight     Pattern
 | 
						Shadow    Pattern
 | 
				
			||||||
	Shadow        Pattern
 | 
					 | 
				
			||||||
	Stroke        Pattern
 | 
					 | 
				
			||||||
	Fill          Pattern
 | 
					 | 
				
			||||||
	StrokeWeight  int
 | 
					 | 
				
			||||||
	ShadingWeight int
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Engraved reverses the shadown and highlight colors of the ShadingProfile to
 | 
					// AtWhen satisfies the Pattern interface.
 | 
				
			||||||
// produce a new ShadingProfile with an engraved appearance.
 | 
					func (chiseled Chiseled) AtWhen (x, y, width, height int) (c color.RGBA) {
 | 
				
			||||||
func (profile ShadingProfile) Engraved () (reversed ShadingProfile) {
 | 
						var highlighted bool
 | 
				
			||||||
	reversed = profile
 | 
						// FIXME: this doesn't work quite right, the
 | 
				
			||||||
	reversed.Highlight = profile.Shadow
 | 
						// slope of the line is somewhat off.
 | 
				
			||||||
	reversed.Shadow    = profile.Highlight
 | 
						bottomCorner :=
 | 
				
			||||||
	return
 | 
							float64(x) < float64(y) *
 | 
				
			||||||
}
 | 
							(float64(width) / float64(height))
 | 
				
			||||||
 | 
						if bottomCorner {
 | 
				
			||||||
// ChiseledRectangle draws a rectangle with a chiseled/embossed appearance,
 | 
							highlighted = float64(x) < float64(height) - float64(y)
 | 
				
			||||||
// according to the ShadingProfile passed to it.
 | 
						} else {
 | 
				
			||||||
func ChiseledRectangle (
 | 
							highlighted = float64(width) - float64(x) > float64(y)
 | 
				
			||||||
	destination tomo.Canvas,
 | 
					 | 
				
			||||||
	profile     ShadingProfile,
 | 
					 | 
				
			||||||
	bounds      image.Rectangle,
 | 
					 | 
				
			||||||
) (
 | 
					 | 
				
			||||||
	updatedRegion image.Rectangle,
 | 
					 | 
				
			||||||
) {
 | 
					 | 
				
			||||||
	// FIXME: this breaks when the bounds are smaller than the border or
 | 
					 | 
				
			||||||
	// shading weight
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	stroke    := profile.Stroke
 | 
					 | 
				
			||||||
	highlight := profile.Highlight
 | 
					 | 
				
			||||||
	shadow    := profile.Shadow
 | 
					 | 
				
			||||||
	fill      := profile.Fill
 | 
					 | 
				
			||||||
	strokeWeight  := profile.StrokeWeight
 | 
					 | 
				
			||||||
	shadingWeight := profile.ShadingWeight
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	data, stride := destination.Buffer()
 | 
					 | 
				
			||||||
	bounds = bounds.Canon()
 | 
					 | 
				
			||||||
	updatedRegion = bounds
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	strokeWeightVector  := image.Point { strokeWeight,  strokeWeight  }
 | 
					 | 
				
			||||||
	shadingWeightVector := image.Point { shadingWeight, shadingWeight }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	shadingBounds := bounds
 | 
					 | 
				
			||||||
	shadingBounds.Min = shadingBounds.Min.Add(strokeWeightVector)
 | 
					 | 
				
			||||||
	shadingBounds.Max = shadingBounds.Max.Sub(strokeWeightVector)
 | 
					 | 
				
			||||||
	shadingBounds = shadingBounds.Canon()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	fillBounds := shadingBounds
 | 
					 | 
				
			||||||
	fillBounds.Min = fillBounds.Min.Add(shadingWeightVector)
 | 
					 | 
				
			||||||
	fillBounds.Max = fillBounds.Max.Sub(shadingWeightVector)
 | 
					 | 
				
			||||||
	fillBounds = fillBounds.Canon()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	width  := float64(bounds.Dx())
 | 
					 | 
				
			||||||
	height := float64(bounds.Dy())
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	yy := 0
 | 
					 | 
				
			||||||
	for y := bounds.Min.Y; y < bounds.Max.Y; y ++ {
 | 
					 | 
				
			||||||
		xx := 0
 | 
					 | 
				
			||||||
		for x := bounds.Min.X; x < bounds.Max.X; x ++ {
 | 
					 | 
				
			||||||
			var pixel color.RGBA
 | 
					 | 
				
			||||||
			point := image.Point { x, y }
 | 
					 | 
				
			||||||
			switch {
 | 
					 | 
				
			||||||
			case point.In(fillBounds):
 | 
					 | 
				
			||||||
				pixel = fill.AtWhen (
 | 
					 | 
				
			||||||
					xx - strokeWeight - shadingWeight,
 | 
					 | 
				
			||||||
					yy - strokeWeight - shadingWeight,
 | 
					 | 
				
			||||||
					fillBounds.Dx(), fillBounds.Dy())
 | 
					 | 
				
			||||||
					
 | 
					 | 
				
			||||||
			case point.In(shadingBounds):
 | 
					 | 
				
			||||||
				var highlighted bool
 | 
					 | 
				
			||||||
				// FIXME: this doesn't work quite right, the
 | 
					 | 
				
			||||||
				// slope of the line is somewhat off.
 | 
					 | 
				
			||||||
				bottomCorner :=
 | 
					 | 
				
			||||||
					float64(xx) < float64(yy) *
 | 
					 | 
				
			||||||
					(width / height)
 | 
					 | 
				
			||||||
				if bottomCorner {
 | 
					 | 
				
			||||||
					highlighted =
 | 
					 | 
				
			||||||
						float64(xx) <
 | 
					 | 
				
			||||||
						height - float64(yy)
 | 
					 | 
				
			||||||
				} else {
 | 
					 | 
				
			||||||
					highlighted =
 | 
					 | 
				
			||||||
						width - float64(xx) >
 | 
					 | 
				
			||||||
						float64(yy)
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				shadingSource := shadow
 | 
					 | 
				
			||||||
				if highlighted {
 | 
					 | 
				
			||||||
					shadingSource = highlight
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				pixel = shadingSource.AtWhen (
 | 
					 | 
				
			||||||
					xx - strokeWeight,
 | 
					 | 
				
			||||||
					yy - strokeWeight,
 | 
					 | 
				
			||||||
					shadingBounds.Dx(),
 | 
					 | 
				
			||||||
					shadingBounds.Dy())
 | 
					 | 
				
			||||||
			default:
 | 
					 | 
				
			||||||
				pixel = stroke.AtWhen (
 | 
					 | 
				
			||||||
					xx, yy, bounds.Dx(), bounds.Dy())
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			data[x + y * stride] = pixel
 | 
					 | 
				
			||||||
			xx ++
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		yy ++
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return
 | 
						if highlighted {
 | 
				
			||||||
 | 
							return chiseled.Highlight.AtWhen(x, y, width, height)
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							return chiseled.Shadow.AtWhen(x, y, width, height)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@ package artist
 | 
				
			|||||||
import "image"
 | 
					import "image"
 | 
				
			||||||
import "image/color"
 | 
					import "image/color"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Border represents a border that can be fed to MultiBorder.
 | 
				
			||||||
type Border struct {
 | 
					type Border struct {
 | 
				
			||||||
	Weight int
 | 
						Weight int
 | 
				
			||||||
	Stroke Pattern
 | 
						Stroke Pattern
 | 
				
			||||||
@ -10,16 +11,22 @@ type Border struct {
 | 
				
			|||||||
	dx, dy int
 | 
						dx, dy int
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// MultiBorder is a pattern that allows multiple borders of different lengths to
 | 
				
			||||||
 | 
					// be inset within one another. The final border is treated as a fill color, and
 | 
				
			||||||
 | 
					// its weight does not matter.
 | 
				
			||||||
type MultiBorder struct {
 | 
					type MultiBorder struct {
 | 
				
			||||||
	borders []Border
 | 
						borders []Border
 | 
				
			||||||
	lastWidth, lastHeight int
 | 
						lastWidth, lastHeight int
 | 
				
			||||||
	maxBorder int
 | 
						maxBorder int
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// NewMultiBorder creates a new MultiBorder pattern from the given list of
 | 
				
			||||||
 | 
					// borders.
 | 
				
			||||||
func NewMultiBorder (borders ...Border) (multi *MultiBorder) {
 | 
					func NewMultiBorder (borders ...Border) (multi *MultiBorder) {
 | 
				
			||||||
	return &MultiBorder { borders: borders }
 | 
						return &MultiBorder { borders: borders }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// AtWhen satisfies the Pattern interface.
 | 
				
			||||||
func (multi *MultiBorder) AtWhen (x, y, width, height int) (c color.RGBA) {
 | 
					func (multi *MultiBorder) AtWhen (x, y, width, height int) (c color.RGBA) {
 | 
				
			||||||
	if multi.lastWidth != width || multi.lastHeight != height {
 | 
						if multi.lastWidth != width || multi.lastHeight != height {
 | 
				
			||||||
		multi.recalculate(width, height)
 | 
							multi.recalculate(width, height)
 | 
				
			||||||
 | 
				
			|||||||
@ -150,12 +150,12 @@ func (element *Button) SetText (text string) {
 | 
				
			|||||||
func (element *Button) draw () {
 | 
					func (element *Button) draw () {
 | 
				
			||||||
	bounds := element.core.Bounds()
 | 
						bounds := element.core.Bounds()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	artist.ChiseledRectangle (
 | 
						artist.FillRectangle (
 | 
				
			||||||
		element.core,
 | 
							element.core,
 | 
				
			||||||
		theme.RaisedProfile (
 | 
							theme.ButtonPattern (
 | 
				
			||||||
			element.pressed,
 | 
					 | 
				
			||||||
			element.enabled,
 | 
								element.enabled,
 | 
				
			||||||
			element.Selected()),
 | 
								element.Selected(),
 | 
				
			||||||
 | 
								element.pressed),
 | 
				
			||||||
		bounds)
 | 
							bounds)
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	innerBounds := bounds
 | 
						innerBounds := bounds
 | 
				
			||||||
@ -179,10 +179,6 @@ func (element *Button) draw () {
 | 
				
			|||||||
		offset = offset.Add(theme.SinkOffsetVector())
 | 
							offset = offset.Add(theme.SinkOffsetVector())
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	foreground := theme.ForegroundImage()
 | 
						foreground := theme.ForegroundPattern(element.enabled)
 | 
				
			||||||
	if !element.enabled {
 | 
					 | 
				
			||||||
		foreground = theme.DisabledForegroundImage()
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	element.drawer.Draw(element.core, foreground, offset)
 | 
						element.drawer.Draw(element.core, foreground, offset)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -320,7 +320,7 @@ func (element *Container) draw () {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	artist.FillRectangle (
 | 
						artist.FillRectangle (
 | 
				
			||||||
		element.core,
 | 
							element.core,
 | 
				
			||||||
		theme.BackgroundImage(),
 | 
							theme.BackgroundPattern(),
 | 
				
			||||||
		bounds)
 | 
							bounds)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, entry := range element.children {
 | 
						for _, entry := range element.children {
 | 
				
			||||||
 | 
				
			|||||||
@ -95,12 +95,12 @@ func (element *Label) draw () {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	artist.FillRectangle (
 | 
						artist.FillRectangle (
 | 
				
			||||||
		element.core,
 | 
							element.core,
 | 
				
			||||||
		theme.BackgroundImage(),
 | 
							theme.BackgroundPattern(),
 | 
				
			||||||
		bounds)
 | 
							bounds)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	textBounds := element.drawer.LayoutBounds()
 | 
						textBounds := element.drawer.LayoutBounds()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	foreground := theme.ForegroundImage()
 | 
						foreground := theme.ForegroundPattern(true)
 | 
				
			||||||
	element.drawer.Draw (element.core, foreground, image.Point {
 | 
						element.drawer.Draw (element.core, foreground, image.Point {
 | 
				
			||||||
		X: 0 - textBounds.Min.X,
 | 
							X: 0 - textBounds.Min.X,
 | 
				
			||||||
		Y: 0 - textBounds.Min.Y,
 | 
							Y: 0 - textBounds.Min.Y,
 | 
				
			||||||
 | 
				
			|||||||
@ -44,14 +44,14 @@ func (element *AnalogClock) SetTime (newTime time.Time) {
 | 
				
			|||||||
func (element *AnalogClock) draw () {
 | 
					func (element *AnalogClock) draw () {
 | 
				
			||||||
	bounds := element.core.Bounds()
 | 
						bounds := element.core.Bounds()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	artist.ChiseledRectangle (
 | 
						artist.FillRectangle (
 | 
				
			||||||
		element.core,
 | 
							element.core,
 | 
				
			||||||
		theme.BackgroundProfile(true),
 | 
							theme.SunkenPattern(),
 | 
				
			||||||
		bounds)
 | 
							bounds)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for hour := 0; hour < 12; hour ++ {
 | 
						for hour := 0; hour < 12; hour ++ {
 | 
				
			||||||
		element.radialLine (
 | 
							element.radialLine (
 | 
				
			||||||
			theme.ForegroundImage(),
 | 
								theme.ForegroundPattern(true),
 | 
				
			||||||
			0.8, 0.9, float64(hour) / 6 * math.Pi)
 | 
								0.8, 0.9, float64(hour) / 6 * math.Pi)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -60,13 +60,13 @@ func (element *AnalogClock) draw () {
 | 
				
			|||||||
	hour   := float64(element.time.Hour())   + minute / 60
 | 
						hour   := float64(element.time.Hour())   + minute / 60
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	element.radialLine (
 | 
						element.radialLine (
 | 
				
			||||||
		theme.ForegroundImage(),
 | 
							theme.ForegroundPattern(true),
 | 
				
			||||||
		0, 0.5, (hour - 3) / 6 * math.Pi)
 | 
							0, 0.5, (hour - 3) / 6 * math.Pi)
 | 
				
			||||||
	element.radialLine (
 | 
						element.radialLine (
 | 
				
			||||||
		theme.ForegroundImage(),
 | 
							theme.ForegroundPattern(true),
 | 
				
			||||||
		0, 0.7, (minute - 15) / 30 * math.Pi)
 | 
							0, 0.7, (minute - 15) / 30 * math.Pi)
 | 
				
			||||||
	element.radialLine (
 | 
						element.radialLine (
 | 
				
			||||||
		theme.AccentImage(),
 | 
							theme.AccentPattern(),
 | 
				
			||||||
		0, 0.7, (second - 15) / 30 * math.Pi)
 | 
							0, 0.7, (second - 15) / 30 * math.Pi)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -35,7 +35,7 @@ func (element *Mouse) Handle (event tomo.Event) {
 | 
				
			|||||||
			resizeEvent.Height)
 | 
								resizeEvent.Height)
 | 
				
			||||||
		artist.FillRectangle (
 | 
							artist.FillRectangle (
 | 
				
			||||||
			element.core,
 | 
								element.core,
 | 
				
			||||||
			theme.AccentImage(),
 | 
								theme.AccentPattern(),
 | 
				
			||||||
			element.Bounds())
 | 
								element.Bounds())
 | 
				
			||||||
		artist.StrokeRectangle (
 | 
							artist.StrokeRectangle (
 | 
				
			||||||
			element.core,
 | 
								element.core,
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										228
									
								
								theme/theme.go
									
									
									
									
									
								
							
							
						
						
									
										228
									
								
								theme/theme.go
									
									
									
									
									
								
							@ -9,179 +9,93 @@ import "git.tebibyte.media/sashakoshka/tomo/defaultfont"
 | 
				
			|||||||
// none of these colors are final! TODO: generate these values from a theme
 | 
					// none of these colors are final! TODO: generate these values from a theme
 | 
				
			||||||
// file at startup.
 | 
					// file at startup.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var foregroundImage  = artist.NewUniform(color.Gray16 { 0x0000})
 | 
					func hex (color uint32) (c color.RGBA) {
 | 
				
			||||||
var disabledForegroundImage = artist.NewUniform(color.Gray16 { 0x5555})
 | 
						c.A = uint8(color)
 | 
				
			||||||
var accentImage      = artist.NewUniform(color.RGBA { 0x40, 0x80, 0x90, 0xFF})
 | 
						c.B = uint8(color >>  8)
 | 
				
			||||||
var highlightImage   = artist.NewUniform(color.Gray16 { 0xEEEE })
 | 
						c.G = uint8(color >> 16)
 | 
				
			||||||
var shadowImage      = artist.NewUniform(color.Gray16 { 0x3333 })
 | 
						c.R = uint8(color >> 24)
 | 
				
			||||||
var weakShadeImage   = artist.NewUniform(color.Gray16 { 0x7777 })
 | 
						return
 | 
				
			||||||
var strokeImage      = artist.NewUniform(color.Gray16 { 0x0000 })
 | 
					 | 
				
			||||||
var weakStrokeImage  = artist.NewUniform(color.Gray16 { 0x3333 })
 | 
					 | 
				
			||||||
var insetShadowImage = artist.NewUniform(color.Gray16 { 0x7777 })
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
var backgroundImage = artist.NewUniform(color.Gray16 { 0xAAAA})
 | 
					 | 
				
			||||||
var backgroundProfile = artist.ShadingProfile {
 | 
					 | 
				
			||||||
	Highlight:     highlightImage,
 | 
					 | 
				
			||||||
	Shadow:        shadowImage,
 | 
					 | 
				
			||||||
	Stroke:        strokeImage,
 | 
					 | 
				
			||||||
	Fill:          backgroundImage,
 | 
					 | 
				
			||||||
	StrokeWeight:  1,
 | 
					 | 
				
			||||||
	ShadingWeight: 1,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
var engravedBackgroundProfile = backgroundProfile.Engraved()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
var raisedImage = artist.NewUniform(color.RGBA { 0x8D, 0x98, 0x94, 0xFF})
 | 
					 | 
				
			||||||
var raisedProfile = artist.ShadingProfile {
 | 
					 | 
				
			||||||
	Highlight:     highlightImage,
 | 
					 | 
				
			||||||
	Shadow:        shadowImage,
 | 
					 | 
				
			||||||
	Stroke:        strokeImage,
 | 
					 | 
				
			||||||
	Fill:          raisedImage,
 | 
					 | 
				
			||||||
	StrokeWeight:  1,
 | 
					 | 
				
			||||||
	ShadingWeight: 1,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
var selectedRaisedProfile = artist.ShadingProfile {
 | 
					 | 
				
			||||||
	Highlight:     highlightImage,
 | 
					 | 
				
			||||||
	Shadow:        shadowImage,
 | 
					 | 
				
			||||||
	Stroke:        accentImage,
 | 
					 | 
				
			||||||
	Fill:          raisedImage,
 | 
					 | 
				
			||||||
	StrokeWeight:  1,
 | 
					 | 
				
			||||||
	ShadingWeight: 1,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
var engravedRaisedProfile = artist.ShadingProfile {
 | 
					 | 
				
			||||||
	Highlight:     weakShadeImage,
 | 
					 | 
				
			||||||
	Shadow:        raisedImage,
 | 
					 | 
				
			||||||
	Stroke:        strokeImage,
 | 
					 | 
				
			||||||
	Fill:          raisedImage,
 | 
					 | 
				
			||||||
	StrokeWeight:  1,
 | 
					 | 
				
			||||||
	ShadingWeight: 1,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
var selectedEngravedRaisedProfile = artist.ShadingProfile {
 | 
					 | 
				
			||||||
	Highlight:     insetShadowImage,
 | 
					 | 
				
			||||||
	Shadow:        raisedImage,
 | 
					 | 
				
			||||||
	Stroke:        accentImage,
 | 
					 | 
				
			||||||
	Fill:          raisedImage,
 | 
					 | 
				
			||||||
	StrokeWeight:  1,
 | 
					 | 
				
			||||||
	ShadingWeight: 1,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
var disabledRaisedProfile = artist.ShadingProfile {
 | 
					 | 
				
			||||||
	Highlight:     weakShadeImage,
 | 
					 | 
				
			||||||
	Shadow:        weakShadeImage,
 | 
					 | 
				
			||||||
	Stroke:        weakStrokeImage,
 | 
					 | 
				
			||||||
	Fill:          backgroundImage,
 | 
					 | 
				
			||||||
	StrokeWeight:  1,
 | 
					 | 
				
			||||||
	ShadingWeight: 0,
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var inputImage = artist.NewUniform(color.Gray16 { 0xFFFF })
 | 
					var accentPattern         = artist.NewUniform(hex(0x408090FF))
 | 
				
			||||||
var inputProfile = artist.ShadingProfile {
 | 
					var backgroundPattern     = artist.NewUniform(color.Gray16 { 0xAAAA })
 | 
				
			||||||
	Highlight:     insetShadowImage,
 | 
					var foregroundPattern     = artist.NewUniform(color.Gray16 { 0x0000 })
 | 
				
			||||||
	Shadow:        inputImage,
 | 
					var weakForegroundPattern = artist.NewUniform(color.Gray16 { 0x4444 })
 | 
				
			||||||
	Stroke:        strokeImage,
 | 
					var strokePattern         = artist.NewUniform(color.Gray16 { 0x0000 })
 | 
				
			||||||
	Fill:          inputImage,
 | 
					 | 
				
			||||||
	StrokeWeight:  1,
 | 
					 | 
				
			||||||
	ShadingWeight: 1,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
var selectedInputProfile = artist.ShadingProfile {
 | 
					 | 
				
			||||||
	Highlight:     insetShadowImage,
 | 
					 | 
				
			||||||
	Shadow:        inputImage,
 | 
					 | 
				
			||||||
	Stroke:        accentImage,
 | 
					 | 
				
			||||||
	Fill:          inputImage,
 | 
					 | 
				
			||||||
	StrokeWeight:  1,
 | 
					 | 
				
			||||||
	ShadingWeight: 1,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
var disabledInputProfile = artist.ShadingProfile {
 | 
					 | 
				
			||||||
	Highlight:     weakShadeImage,
 | 
					 | 
				
			||||||
	Shadow:        backgroundImage,
 | 
					 | 
				
			||||||
	Stroke:        accentImage,
 | 
					 | 
				
			||||||
	Fill:          backgroundImage,
 | 
					 | 
				
			||||||
	StrokeWeight:  1,
 | 
					 | 
				
			||||||
	ShadingWeight: 0,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// BackgroundProfile returns the shading profile to be used for backgrounds.
 | 
					var buttonPattern = artist.NewMultiBorder (
 | 
				
			||||||
func BackgroundProfile (engraved bool) artist.ShadingProfile {
 | 
						artist.Border { Weight: 1, Stroke: strokePattern },
 | 
				
			||||||
	if engraved {
 | 
						artist.Border {
 | 
				
			||||||
		return engravedBackgroundProfile
 | 
							Weight: 1,
 | 
				
			||||||
 | 
							Stroke: artist.Chiseled {
 | 
				
			||||||
 | 
								Highlight: artist.NewUniform(hex(0xCCD5D2FF)),
 | 
				
			||||||
 | 
								Shadow:    artist.NewUniform(hex(0x4B5B59FF)),
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						artist.Border { Stroke: artist.NewUniform(hex(0x8D9894FF)) })
 | 
				
			||||||
 | 
					var selectedButtonPattern = artist.NewMultiBorder (
 | 
				
			||||||
 | 
						artist.Border { Weight: 1, Stroke: strokePattern },
 | 
				
			||||||
 | 
						artist.Border {
 | 
				
			||||||
 | 
							Weight: 1,
 | 
				
			||||||
 | 
							Stroke: artist.Chiseled {
 | 
				
			||||||
 | 
								Highlight: artist.NewUniform(hex(0xCCD5D2FF)),
 | 
				
			||||||
 | 
								Shadow:    artist.NewUniform(hex(0x4B5B59FF)),
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						artist.Border { Weight: 1, Stroke: accentPattern },
 | 
				
			||||||
 | 
						artist.Border { Stroke: artist.NewUniform(hex(0x8D9894FF)) })
 | 
				
			||||||
 | 
					var pressedButtonPattern = artist.NewMultiBorder (
 | 
				
			||||||
 | 
						artist.Border { Weight: 1, Stroke: strokePattern },
 | 
				
			||||||
 | 
						artist.Border {
 | 
				
			||||||
 | 
							Weight: 1,
 | 
				
			||||||
 | 
							Stroke: artist.Chiseled {
 | 
				
			||||||
 | 
								Highlight: artist.NewUniform(hex(0x4B5B59FF)),
 | 
				
			||||||
 | 
								Shadow:    artist.NewUniform(hex(0x8D9894FF)),
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						artist.Border { Stroke: artist.NewUniform(hex(0x8D9894FF)) })
 | 
				
			||||||
 | 
					var disabledButtonPattern = artist.NewMultiBorder (
 | 
				
			||||||
 | 
						artist.Border { Weight: 1, Stroke: weakForegroundPattern },
 | 
				
			||||||
 | 
						artist.Border { Stroke: backgroundPattern })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var sunkenPattern = artist.NewMultiBorder (
 | 
				
			||||||
 | 
						artist.Border { Weight: 1, Stroke: strokePattern },
 | 
				
			||||||
 | 
						artist.Border {
 | 
				
			||||||
 | 
							Weight: 1,
 | 
				
			||||||
 | 
							Stroke: artist.Chiseled {
 | 
				
			||||||
 | 
								Highlight: artist.NewUniform(hex(0x373C3AFF)),
 | 
				
			||||||
 | 
								Shadow:    artist.NewUniform(hex(0xDBDBDBFF)),
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						artist.Border { Stroke: backgroundPattern })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func AccentPattern () (artist.Pattern) { return accentPattern }
 | 
				
			||||||
 | 
					func BackgroundPattern () (artist.Pattern) { return backgroundPattern }
 | 
				
			||||||
 | 
					func SunkenPattern () (artist.Pattern) { return sunkenPattern}
 | 
				
			||||||
 | 
					func ForegroundPattern (enabled bool) (artist.Pattern) {
 | 
				
			||||||
 | 
						if enabled {
 | 
				
			||||||
 | 
							return foregroundPattern
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		return backgroundProfile
 | 
							return weakForegroundPattern
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					func ButtonPattern (enabled, selected, pressed bool) (artist.Pattern) {
 | 
				
			||||||
// RaisedProfile returns the shading profile to be used for raised objects such
 | 
					 | 
				
			||||||
// as buttons.
 | 
					 | 
				
			||||||
func RaisedProfile (
 | 
					 | 
				
			||||||
	engraved bool,
 | 
					 | 
				
			||||||
	enabled  bool,
 | 
					 | 
				
			||||||
	selected bool,
 | 
					 | 
				
			||||||
) (
 | 
					 | 
				
			||||||
	artist.ShadingProfile,
 | 
					 | 
				
			||||||
) {
 | 
					 | 
				
			||||||
	if enabled {
 | 
						if enabled {
 | 
				
			||||||
		if engraved {
 | 
							if pressed {
 | 
				
			||||||
			if selected {
 | 
								return pressedButtonPattern
 | 
				
			||||||
				return selectedEngravedRaisedProfile
 | 
					 | 
				
			||||||
			} else {
 | 
					 | 
				
			||||||
				return engravedRaisedProfile
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			if selected {
 | 
								if selected {
 | 
				
			||||||
				return selectedRaisedProfile
 | 
									return selectedButtonPattern
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				return raisedProfile
 | 
									return buttonPattern
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		return disabledRaisedProfile
 | 
							return disabledButtonPattern
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// InputProfile returns the shading profile to be used for input fields.
 | 
					// TODO: load fonts from an actual source instead of using defaultfont
 | 
				
			||||||
func InputProfile (enabled bool, selected bool) artist.ShadingProfile {
 | 
					 | 
				
			||||||
	if enabled {
 | 
					 | 
				
			||||||
		if selected {
 | 
					 | 
				
			||||||
			return selectedInputProfile
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			return inputProfile
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		return disabledInputProfile
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// BackgroundImage returns the texture/color used for the fill of
 | 
					 | 
				
			||||||
// BackgroundProfile.
 | 
					 | 
				
			||||||
func BackgroundImage () artist.Pattern {
 | 
					 | 
				
			||||||
	return backgroundImage
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// RaisedImage returns the texture/color used for the fill of RaisedProfile.
 | 
					 | 
				
			||||||
func RaisedImage () artist.Pattern {
 | 
					 | 
				
			||||||
	return raisedImage
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// InputImage returns the texture/color used for the fill of InputProfile.
 | 
					 | 
				
			||||||
func InputImage () artist.Pattern {
 | 
					 | 
				
			||||||
	return inputImage
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// ForegroundImage returns the texture/color text and monochromatic icons should
 | 
					 | 
				
			||||||
// be drawn with.
 | 
					 | 
				
			||||||
func ForegroundImage () artist.Pattern {
 | 
					 | 
				
			||||||
	return foregroundImage
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// DisabledForegroundImage returns the texture/color text and monochromatic
 | 
					 | 
				
			||||||
// icons should be drawn with if they are disabled.
 | 
					 | 
				
			||||||
func DisabledForegroundImage () artist.Pattern {
 | 
					 | 
				
			||||||
	return disabledForegroundImage
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// AccentImage returns the accent texture/color.
 | 
					 | 
				
			||||||
func AccentImage () artist.Pattern {
 | 
					 | 
				
			||||||
	return accentImage
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// TODO: load fonts from an actual source instead of using basicfont
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// FontFaceRegular returns the font face to be used for normal text.
 | 
					// FontFaceRegular returns the font face to be used for normal text.
 | 
				
			||||||
func FontFaceRegular () font.Face {
 | 
					func FontFaceRegular () font.Face {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user