...

Source file src/code.rocketnine.space/tslocum/etk/style.go

Documentation: code.rocketnine.space/tslocum/etk

     1  package etk
     2  
     3  import (
     4  	"image/color"
     5  	"log"
     6  
     7  	"github.com/hajimehoshi/ebiten/v2/examples/resources/fonts"
     8  	"golang.org/x/image/font"
     9  	"golang.org/x/image/font/opentype"
    10  )
    11  
    12  var transparent = color.RGBA{0, 0, 0, 0}
    13  
    14  func defaultFont() font.Face {
    15  	tt, err := opentype.Parse(fonts.MPlus1pRegular_ttf)
    16  	if err != nil {
    17  		log.Fatal(err)
    18  	}
    19  	const dpi = 72
    20  	defaultFont, err := opentype.NewFace(tt, &opentype.FaceOptions{
    21  		Size:    32,
    22  		DPI:     dpi,
    23  		Hinting: font.HintingFull,
    24  	})
    25  	if err != nil {
    26  		log.Fatal(err)
    27  	}
    28  	return defaultFont
    29  }
    30  
    31  type Attributes struct {
    32  	TextFont font.Face
    33  
    34  	TextColorLight color.Color
    35  	TextColorDark  color.Color
    36  
    37  	TextBgColor color.Color
    38  
    39  	BorderColor color.Color
    40  
    41  	InputBgColor color.Color
    42  
    43  	ButtonTextColor       color.Color
    44  	ButtonBgColor         color.Color
    45  	ButtonBgColorDisabled color.Color
    46  }
    47  
    48  var Style = &Attributes{
    49  	TextFont: defaultFont(),
    50  
    51  	TextColorLight: color.RGBA{255, 255, 255, 255},
    52  	TextColorDark:  color.RGBA{0, 0, 0, 255},
    53  
    54  	TextBgColor: transparent,
    55  
    56  	BorderColor: color.RGBA{0, 0, 0, 255},
    57  
    58  	InputBgColor: color.RGBA{0, 128, 0, 255},
    59  
    60  	ButtonBgColor:         color.RGBA{255, 255, 255, 255},
    61  	ButtonBgColorDisabled: color.RGBA{110, 110, 110, 255},
    62  }
    63  

View as plain text