programregion.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package colorlight
  2. type Region struct {
  3. Layer string `json:"Layer"`
  4. Rect Rect `json:"Rect"`
  5. Items []interface{} `json:"Items"`
  6. }
  7. func (o *Region) SetData(layer string, rect *Rect) {
  8. o.Layer = layer
  9. o.Rect = *rect
  10. }
  11. func (o *Region) AddItemSingleLineText(
  12. Text, //文本内容
  13. TextColor, //文本显示颜色
  14. LfHeight, LfItalic, LfUnderline, LfFaceName, //文本显示字体
  15. IsScroll string, //文本是否滚动
  16. ) {
  17. item := ItemSingleLineText{
  18. Type: "4",
  19. TextColor: TextColor,
  20. LogFont: LogFont{
  21. LfHeight: LfHeight,
  22. LfWeight: "0",
  23. LfItalic: LfItalic,
  24. LfUnderline: LfUnderline,
  25. LfStrikeOut: "",
  26. LfFaceName: LfFaceName,
  27. },
  28. Text: Text,
  29. IsScroll: IsScroll,
  30. Speed: "60",
  31. IsScrollByTime: "0",
  32. IsHeadConnectTail: "0",
  33. RepeatCount: "1",
  34. PlayLenth: "",
  35. }
  36. o.Items = append(o.Items, item)
  37. }
  38. func (o *Region) AddItemMultiLineText(
  39. Text, //文本内容
  40. TextColor, //文本显示颜色
  41. LfHeight, LfItalic, LfUnderline, LfFaceName, //文本显示字体
  42. CenteralAlign, VerticalAlign, //对齐方式
  43. IsScroll string, //文本是否滚动
  44. ) {
  45. item := ItemMultiLineText{
  46. Type: "5",
  47. TextColor: TextColor,
  48. LogFont: LogFont{
  49. LfHeight: LfHeight,
  50. LfWeight: "0",
  51. LfItalic: LfItalic,
  52. LfUnderline: LfUnderline,
  53. LfStrikeOut: "",
  54. LfFaceName: LfFaceName,
  55. },
  56. CenteralAlign: CenteralAlign,
  57. VerticalAlign: VerticalAlign,
  58. Text: Text,
  59. IsScroll: IsScroll,
  60. Speed: "60",
  61. IsScrollByTime: "0",
  62. RepeatCount: "1",
  63. PlayLenth: "0",
  64. }
  65. o.Items = append(o.Items, item)
  66. }
  67. func (o *Region) AddItemPicture(filepath, duration, inEffectType string) {
  68. item := ItemPicture{
  69. Type: "2",
  70. FileSource: FileSource{
  71. FilePath: filepath,
  72. IsRelative: "1",
  73. },
  74. Duration: duration,
  75. InEffect: InEffect{
  76. Type: inEffectType,
  77. Time: "1000",
  78. },
  79. ReserveAS: "1",
  80. }
  81. o.Items = append(o.Items, item)
  82. }
  83. func (o *Region) AddItemVideo(filepath, Volume, duration string) {
  84. item := ItemVideo{
  85. Type: "3",
  86. Volume: Volume,
  87. Duration: duration,
  88. FileSource: FileSource{
  89. FilePath: filepath,
  90. IsRelative: "1",
  91. },
  92. ReserveAS: "1",
  93. }
  94. o.Items = append(o.Items, item)
  95. }
  96. func (o *Region) AddItemWebPage(url string, rect *Rect) {
  97. if rect == nil {
  98. rect = &o.Rect
  99. }
  100. item := ItemWebPage{
  101. Type: "27",
  102. Url: url,
  103. Rect: *rect,
  104. }
  105. o.Items = append(o.Items, item)
  106. }