program.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package colorlight
  2. type ProgramVsn struct {
  3. Programs Programs `json:"Programs"`
  4. }
  5. func (o *ProgramVsn) SetInformation(Width, Height string) {
  6. o.Programs.Program.Information.Width = Width
  7. o.Programs.Program.Information.Height = Height
  8. }
  9. func (o *ProgramVsn) AddPage(page *Page) {
  10. o.Programs.Program.Pages = append(o.Programs.Program.Pages, *page)
  11. }
  12. type Programs struct {
  13. Program Program `json:"Program"`
  14. }
  15. type Program struct {
  16. Information Information `json:"Information"`
  17. Pages []Page `json:"Pages"`
  18. }
  19. type Information struct {
  20. Width string `json:"Width"`
  21. Height string `json:"Height"`
  22. }
  23. type Page struct {
  24. AppointDuration string `json:"AppointDuration"`
  25. LoopType string `json:"LoopType"`
  26. BgColor string `json:"BgColor"`
  27. BgFile FileSource `json:"BgFile"`
  28. Regions []Region `json:"Regions"`
  29. }
  30. func (o *Page) SetData(AppointDuration, LoopType, BgColor, FilePath string) {
  31. o.AppointDuration = AppointDuration
  32. o.LoopType = LoopType
  33. o.BgColor = BgColor
  34. o.BgFile.IsRelative = "1"
  35. o.BgFile.FilePath = FilePath
  36. }
  37. func (o *Page) AddRegion(region *Region) {
  38. o.Regions = append(o.Regions, *region)
  39. }
  40. type FileSource struct {
  41. FilePath string `json:"FilePath"` //"./program1.files/abc.jpg", the " program1" is the vsn file name (program1.vsn). i.e., if you have a program named program1.vsn, then the file path should be ./program1.files/.
  42. IsRelative string `json:"IsRelative"` //Must be 1
  43. }
  44. type Rect struct {
  45. X string `json:"X"`
  46. Y string `json:"Y"`
  47. Width string `json:"Width"`
  48. Height string `json:"Height"`
  49. BorderWidth string `json:"BorderWidth"`
  50. BorderColor string `json:"BorderColor"`
  51. }
  52. func (o *Rect) SetData(X, Y, Width, Height, BorderWidth, BorderColor string) {
  53. o.X = X
  54. o.Y = Y
  55. o.Width = Width
  56. o.Height = Height
  57. o.BorderWidth = BorderWidth
  58. o.BorderColor = BorderColor
  59. }