feat: hazakura colorscheme + basic interface

This commit is contained in:
Muhammad Nauman Raza 2023-07-23 00:34:44 +01:00
parent 0b3803c8ad
commit 044f2022e7

View file

@ -18,32 +18,73 @@ import (
"github.com/hajimehoshi/ebiten/v2"
)
// Create the `Game` struct
type Game struct {
ui ebitenui.UI
}
func uiInit() ebitenui.UI {
// The `hazakura` colorscheme
hazakura := make(map[string]color.RGBA)
// The monotone colors
hazakura["dark_black"] = color.RGBA{0x0f, 0x0f, 0x0d, 0xff}
hazakura["black"] = color.RGBA{0x15, 0x15, 0x17, 0xff}
hazakura["dark_gray"] = color.RGBA{0x24, 0x24, 0x26, 0xff}
hazakura["gray"] = color.RGBA{0x27, 0x27, 0x2b, 0xff}
hazakura["light_gray"] = color.RGBA{0x45, 0x44, 0x49, 0xff}
hazakura["overlay"] = color.RGBA{0x5c, 0x5c, 0x61, 0xff}
hazakura["highlight"] = color.RGBA{0xd9, 0x0, 0xd7, 0xff}
hazakura["subwhite"] = color.RGBA{0xec, 0xe5, 0xea, 0xff}
// Actual* colors
hazakura["red"] = color.RGBA{0xf0, 0x69, 0x69, 0xff}
hazakura["magenta"] = color.RGBA{0xe8, 0x87, 0xbb, 0xff}
hazakura["purple"] = color.RGBA{0xa2, 0x92, 0xe8, 0xff}
hazakura["blue"] = color.RGBA{0x78, 0xb9, 0xc4, 0xff}
hazakura["cyan"] = color.RGBA{0x7e, 0xe6, 0xae, 0xff}
hazakura["green"] = color.RGBA{0x91, 0xd6, 0x5c, 0xff}
hazakura["yellow"] = color.RGBA{0xd9, 0xd5, 0x64, 0xff}
// Get the window width/height
window_width, window_height := ebiten.WindowSize()
// Define the root container
root := widget.NewContainer(
// Define the plain color to be used as a default background
widget.ContainerOpts.BackgroundImage(image.NewNineSliceColor(hazakura["dark_black"])),
)
// Define the left bar container
leftBar := widget.NewContainer(
widget.ContainerOpts.BackgroundImage(image.NewNineSliceColor(hazakura["gray"])),
)
// Set the position and size of the left bar
leftBar.SetLocation(img.Rect(0, 0, int(float64(window_width)/3.5), window_height))
// Add the left bar to the root container
root.AddChild(leftBar)
// Construct the UI
ui := ebitenui.UI{
Container: widget.NewContainer(widget.ContainerOpts.Layout(widget.NewAnchorLayout())),
Container: root,
}
leftBar := widget.NewContainer(widget.ContainerOpts.BackgroundImage(image.NewNineSliceColor(color.White)))
leftBar.SetLocation(img.Rect(0, 0, 1, 1))
ui.Container.AddChild(leftBar)
return ui
}
// Update implements Game
func (g *Game) Update() error {
g.ui.Update()
return nil
}
// Draw implements Game
func (g *Game) Draw(screen *ebiten.Image) {
g.ui.Draw(screen)
}
// Layout implements Game
func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
return 320, 240
return outsideWidth, outsideHeight
}
func main() {