types.go 724 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package types
  2. type Sized interface {
  3. Width() int
  4. Height() int
  5. }
  6. type Positioned interface {
  7. Top() int
  8. Left() int
  9. }
  10. type Color interface {
  11. }
  12. type Point struct {
  13. X int
  14. Y int
  15. }
  16. func (p Point) Left() int {
  17. return p.X
  18. }
  19. func (p Point) Top() int {
  20. return p.Y
  21. }
  22. type Box struct {
  23. Point
  24. W int
  25. H int
  26. }
  27. func (re Box) Width() int {
  28. return re.W
  29. }
  30. func (re Box) Height() int {
  31. return re.H
  32. }
  33. type Bitmap interface {
  34. Sized
  35. Close()
  36. }
  37. type Font interface {
  38. TextWidth(text string) int
  39. LineHeight() int
  40. Ascent() int
  41. Descent() int
  42. Close()
  43. }
  44. type Display interface {
  45. Sized
  46. }
  47. func Bounds(x,y, w, h int) Box {
  48. return Box{Point{x, y}, w, h}
  49. }