Drawing.mmc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. # Helper function that can't be used as a theme.
  2. BEGIN: Resize3x3
  3. INPUT: FixedPoint, targetWidth
  4. INPUT: FixedPoint, targetHeight
  5. INPUT: FixedPoint, sourceBorder
  6. INPUT: ImageRgbaU8, sourceImage
  7. INPUT: FixedPoint, sourceLeft
  8. INPUT: FixedPoint, sourceTop
  9. INPUT: FixedPoint, sourceWidth
  10. INPUT: FixedPoint, sourceHeight
  11. OUTPUT: ImageRgbaU8, targetImage
  12. CREATE: targetImage, targetWidth, targetHeight
  13. # Limit targetBorder
  14. MIN: targetBorder<FixedPoint>, targetWidth, targetHeight
  15. MUL: targetBorder, targetBorder, 0.3
  16. MIN: targetBorder, targetBorder, sourceBorder
  17. # Calculat dimensions
  18. ADD: sourceRight<FixedPoint>, sourceLeft, sourceWidth
  19. ADD: sourceBottom<FixedPoint>, sourceTop, sourceHeight
  20. ADD: sb2<FixedPoint>, sourceBorder, sourceBorder
  21. SUB: sbiw<FixedPoint>, sourceWidth, sb2
  22. SUB: sbih<FixedPoint>, sourceHeight, sb2
  23. #ADD: sbl<FixedPoint>, sourceLeft, sourceBorder
  24. #ADD: sbt<FixedPoint>, sourceTop, sourceBorder
  25. SUB: sbow<FixedPoint>, sourceRight, sourceBorder
  26. SUB: sboh<FixedPoint>, sourceBottom, sourceBorder
  27. ADD: pl<FixedPoint>, sourceLeft, sourceBorder
  28. ADD: pt<FixedPoint>, sourceTop, sourceBorder
  29. ADD: tb2<FixedPoint>, targetBorder, targetBorder
  30. SUB: tbiw<FixedPoint>, targetWidth, tb2
  31. SUB: tbih<FixedPoint>, targetHeight, tb2
  32. SUB: tbow<FixedPoint>, targetWidth, targetBorder
  33. SUB: tboh<FixedPoint>, targetHeight, targetBorder
  34. # Upper
  35. RESIZE_BILINEAR: scaled<ImageRgbaU8>, targetBorder, targetBorder, sourceImage, sourceLeft, sourceTop, sourceBorder, sourceBorder
  36. COPY: targetImage, 0, 0, scaled
  37. RESIZE_BILINEAR: scaled, tbiw, targetBorder, sourceImage, pl, sourceTop, sbiw, sourceBorder
  38. COPY: targetImage, targetBorder, 0, scaled
  39. RESIZE_BILINEAR: scaled, targetBorder, targetBorder, sourceImage, sbow, sourceTop, sourceBorder, sourceBorder
  40. COPY: targetImage, tbow, 0, scaled
  41. # Middle
  42. RESIZE_BILINEAR: scaled, targetBorder, tbih, sourceImage, sourceLeft, pt, sourceBorder, sbih
  43. COPY: targetImage, 0, targetBorder, scaled
  44. RESIZE_BILINEAR: scaled, tbiw, tbih, sourceImage, pl, pt, sbiw, sbih
  45. COPY: targetImage, targetBorder, targetBorder, scaled
  46. RESIZE_BILINEAR: scaled, targetBorder, tbih, sourceImage, sbow, pt, sourceBorder, sbih
  47. COPY: targetImage, tbow, targetBorder, scaled
  48. # Lower
  49. RESIZE_BILINEAR: scaled, targetBorder, targetBorder, sourceImage, sourceLeft, sboh, sourceBorder, sourceBorder
  50. COPY: targetImage, 0, tboh, scaled
  51. RESIZE_BILINEAR: scaled, tbiw, targetBorder, sourceImage, pl, sboh, sbiw, sourceBorder
  52. COPY: targetImage, targetBorder, tboh, scaled
  53. RESIZE_BILINEAR: scaled, targetBorder, targetBorder, sourceImage, sbow, sboh, sourceBorder, sourceBorder
  54. COPY: targetImage, tbow, tboh, scaled
  55. END:
  56. BEGIN: Diffuse3x3
  57. INPUT: FixedPoint, width
  58. INPUT: FixedPoint, height
  59. INPUT: FixedPoint, red
  60. INPUT: FixedPoint, green
  61. INPUT: FixedPoint, blue
  62. INPUT: FixedPoint, sourceLeft
  63. INPUT: FixedPoint, sourceTop
  64. INPUT: FixedPoint, sourceWidth
  65. INPUT: FixedPoint, sourceHeight
  66. INPUT: FixedPoint, preserved
  67. INPUT: ImageRgbaU8, atlas
  68. OUTPUT: ImageRgbaU8, colorImage
  69. # Scale by 1 / 255 so that 255 represents full intensity in atlas.
  70. MUL: normRed<FixedPoint>, red, 0.00392156862745
  71. MUL: normGreen<FixedPoint>, green, 0.00392156862745
  72. MUL: normBlue<FixedPoint>, blue, 0.00392156862745
  73. # Resize source region from the atlas.
  74. CALL: Resize3x3, rescaledImage<ImageRgbaU8>, width, height, preserved, atlas, sourceLeft, sourceTop, sourceWidth, sourceHeight
  75. GET_RED: diffuseMap<ImageU8>, rescaledImage
  76. GET_ALPHA: visibilityMap<ImageU8>, rescaledImage
  77. MUL: redImage<ImageU8>, diffuseMap, normRed
  78. MUL: greenImage<ImageU8>, diffuseMap, normGreen
  79. MUL: blueImage<ImageU8>, diffuseMap, normBlue
  80. PACK_RGBA: colorImage, redImage, greenImage, blueImage, visibilityMap
  81. END:
  82. BEGIN: FocusableDiffuse3x3
  83. INPUT: FixedPoint, width
  84. INPUT: FixedPoint, height
  85. INPUT: FixedPoint, red
  86. INPUT: FixedPoint, green
  87. INPUT: FixedPoint, blue
  88. INPUT: FixedPoint, sourceLeft
  89. INPUT: FixedPoint, sourceTop
  90. INPUT: FixedPoint, sourceWidth
  91. INPUT: FixedPoint, sourceHeight
  92. INPUT: FixedPoint, focusOffsetX
  93. INPUT: FixedPoint, focusOffsetY
  94. INPUT: FixedPoint, focused
  95. INPUT: FixedPoint, preserved
  96. INPUT: ImageRgbaU8, atlas
  97. OUTPUT: ImageRgbaU8, colorImage
  98. # Select image using the focused state.
  99. MUL: sourceOffsetX<FixedPoint>, focused, focusOffsetX
  100. MUL: sourceOffsetY<FixedPoint>, focused, focusOffsetY
  101. ADD: adjustedSourceLeft<FixedPoint>, sourceLeft, sourceOffsetX
  102. ADD: adjustedSourceTop<FixedPoint>, sourceTop, sourceOffsetY
  103. # Scale by 1 / 255 so that 255 represents full intensity in atlas.
  104. MUL: normRed<FixedPoint>, red, 0.00392156862745
  105. MUL: normGreen<FixedPoint>, green, 0.00392156862745
  106. MUL: normBlue<FixedPoint>, blue, 0.00392156862745
  107. # Resize source region from the atlas.
  108. CALL: Resize3x3, rescaledImage<ImageRgbaU8>, width, height, preserved, atlas, adjustedSourceLeft, adjustedSourceTop, sourceWidth, sourceHeight
  109. GET_RED: diffuseMap<ImageU8>, rescaledImage
  110. GET_ALPHA: visibilityMap<ImageU8>, rescaledImage
  111. MUL: redImage<ImageU8>, diffuseMap, normRed
  112. MUL: greenImage<ImageU8>, diffuseMap, normGreen
  113. MUL: blueImage<ImageU8>, diffuseMap, normBlue
  114. PACK_RGBA: colorImage, redImage, greenImage, blueImage, visibilityMap
  115. END:
  116. BEGIN: DiffuseSpecular3x3
  117. INPUT: FixedPoint, width
  118. INPUT: FixedPoint, height
  119. INPUT: FixedPoint, red
  120. INPUT: FixedPoint, green
  121. INPUT: FixedPoint, blue
  122. INPUT: FixedPoint, sourceLeft
  123. INPUT: FixedPoint, sourceTop
  124. INPUT: FixedPoint, sourceWidth
  125. INPUT: FixedPoint, sourceHeight
  126. INPUT: FixedPoint, preserved
  127. INPUT: ImageRgbaU8, atlas
  128. OUTPUT: ImageRgbaU8, colorImage
  129. # Scale by 1 / 255 so that 255 represents full intensity in atlas.
  130. MUL: normRed<FixedPoint>, red, 0.00392156862745
  131. MUL: normGreen<FixedPoint>, green, 0.00392156862745
  132. MUL: normBlue<FixedPoint>, blue, 0.00392156862745
  133. # Resize source region from the atlas.
  134. CALL: Resize3x3, rescaledImage<ImageRgbaU8>, width, height, preserved, atlas, sourceLeft, sourceTop, sourceWidth, sourceHeight
  135. GET_RED: diffuseMap<ImageU8>, rescaledImage
  136. GET_GREEN: specularMap<ImageU8>, rescaledImage
  137. GET_ALPHA: visibilityMap<ImageU8>, rescaledImage
  138. MUL: redImage<ImageU8>, diffuseMap, normRed
  139. MUL: greenImage<ImageU8>, diffuseMap, normGreen
  140. MUL: blueImage<ImageU8>, diffuseMap, normBlue
  141. ADD: redImage, redImage, specularMap
  142. ADD: greenImage, greenImage, specularMap
  143. ADD: blueImage, blueImage, specularMap
  144. PACK_RGBA: colorImage, redImage, greenImage, blueImage, visibilityMap
  145. END:
  146. BEGIN: PressableDiffuseSpecular3x3
  147. INPUT: FixedPoint, width
  148. INPUT: FixedPoint, height
  149. INPUT: FixedPoint, red
  150. INPUT: FixedPoint, green
  151. INPUT: FixedPoint, blue
  152. INPUT: FixedPoint, pressed
  153. INPUT: FixedPoint, sourceLeft
  154. INPUT: FixedPoint, sourceTop
  155. INPUT: FixedPoint, sourceWidth
  156. INPUT: FixedPoint, sourceHeight
  157. INPUT: FixedPoint, pressOffsetX
  158. INPUT: FixedPoint, pressOffsetY
  159. INPUT: FixedPoint, preserved
  160. INPUT: ImageRgbaU8, atlas
  161. OUTPUT: ImageRgbaU8, colorImage
  162. # Select image using the pressed state.
  163. MUL: sourceOffsetX<FixedPoint>, pressed, pressOffsetX
  164. MUL: sourceOffsetY<FixedPoint>, pressed, pressOffsetY
  165. ADD: adjustedSourceLeft<FixedPoint>, sourceLeft, sourceOffsetX
  166. ADD: adjustedSourceTop<FixedPoint>, sourceTop, sourceOffsetY
  167. # Rescale the source region to fit width and height, while applying the diffuse color and adding white shine.
  168. CALL: DiffuseSpecular3x3, colorImage, width, height, red, green, blue, adjustedSourceLeft, adjustedSourceTop, sourceWidth, sourceHeight, preserved, atlas
  169. END:
  170. BEGIN: DiffuseSpecular1x1
  171. INPUT: FixedPoint, width
  172. INPUT: FixedPoint, height
  173. INPUT: FixedPoint, red
  174. INPUT: FixedPoint, green
  175. INPUT: FixedPoint, blue
  176. INPUT: FixedPoint, sourceLeft
  177. INPUT: FixedPoint, sourceTop
  178. INPUT: FixedPoint, sourceWidth
  179. INPUT: FixedPoint, sourceHeight
  180. INPUT: FixedPoint, preserved
  181. INPUT: ImageRgbaU8, atlas
  182. OUTPUT: ImageRgbaU8, colorImage
  183. # Scale by 1 / 255 so that 255 represents full intensity in atlas.
  184. MUL: normRed<FixedPoint>, red, 0.00392156862745
  185. MUL: normGreen<FixedPoint>, green, 0.00392156862745
  186. MUL: normBlue<FixedPoint>, blue, 0.00392156862745
  187. # Resize source region from the atlas.
  188. RESIZE_BILINEAR: rescaledImage<ImageRgbaU8>, width, height, atlas, sourceLeft, sourceTop, sourceWidth, sourceHeight
  189. GET_RED: diffuseMap<ImageU8>, rescaledImage
  190. GET_GREEN: specularMap<ImageU8>, rescaledImage
  191. GET_ALPHA: visibilityMap<ImageU8>, rescaledImage
  192. MUL: redImage<ImageU8>, diffuseMap, normRed
  193. MUL: greenImage<ImageU8>, diffuseMap, normGreen
  194. MUL: blueImage<ImageU8>, diffuseMap, normBlue
  195. ADD: redImage, redImage, specularMap
  196. ADD: greenImage, greenImage, specularMap
  197. ADD: blueImage, blueImage, specularMap
  198. PACK_RGBA: colorImage, redImage, greenImage, blueImage, visibilityMap
  199. END:
  200. BEGIN: PressableDiffuseSpecular1x1
  201. INPUT: FixedPoint, width
  202. INPUT: FixedPoint, height
  203. INPUT: FixedPoint, red
  204. INPUT: FixedPoint, green
  205. INPUT: FixedPoint, blue
  206. INPUT: FixedPoint, pressed
  207. INPUT: FixedPoint, sourceLeft
  208. INPUT: FixedPoint, sourceTop
  209. INPUT: FixedPoint, sourceWidth
  210. INPUT: FixedPoint, sourceHeight
  211. INPUT: FixedPoint, pressOffsetX
  212. INPUT: FixedPoint, pressOffsetY
  213. INPUT: FixedPoint, preserved
  214. INPUT: ImageRgbaU8, atlas
  215. OUTPUT: ImageRgbaU8, colorImage
  216. # Select image using the pressed state.
  217. MUL: sourceOffsetX<FixedPoint>, pressed, pressOffsetX
  218. MUL: sourceOffsetY<FixedPoint>, pressed, pressOffsetY
  219. ADD: adjustedSourceLeft<FixedPoint>, sourceLeft, sourceOffsetX
  220. ADD: adjustedSourceTop<FixedPoint>, sourceTop, sourceOffsetY
  221. # Rescale the source region to fit width and height, while applying the diffuse color and adding white shine.
  222. CALL: DiffuseSpecular1x1, colorImage, width, height, red, green, blue, adjustedSourceLeft, adjustedSourceTop, sourceWidth, sourceHeight, preserved, atlas
  223. END:
  224. BEGIN: ListBox
  225. INPUT: FixedPoint, width
  226. INPUT: FixedPoint, height
  227. INPUT: FixedPoint, red
  228. INPUT: FixedPoint, green
  229. INPUT: FixedPoint, blue
  230. INPUT: FixedPoint, sourceLeft
  231. INPUT: FixedPoint, sourceTop
  232. INPUT: FixedPoint, sourceWidth
  233. INPUT: FixedPoint, sourceHeight
  234. INPUT: FixedPoint, preserved
  235. INPUT: ImageRgbaU8, atlas
  236. OUTPUT: ImageRgbaU8, colorImage
  237. # Rescale the source region to fit width and height, while applying the diffuse color.
  238. CALL: Diffuse3x3, colorImage, width, height, red, green, blue, sourceLeft, sourceTop, sourceWidth, sourceHeight, preserved, atlas
  239. END:
  240. BEGIN: VerticalScrollList
  241. INPUT: FixedPoint, width
  242. INPUT: FixedPoint, height
  243. INPUT: FixedPoint, red
  244. INPUT: FixedPoint, green
  245. INPUT: FixedPoint, blue
  246. OUTPUT: ImageRgbaU8, colorImage
  247. CREATE: visImage<ImageU8>, width, height
  248. CREATE: lumaImage<ImageU8>, width, height
  249. FADE_LINEAR: visImage, 0, 0, 128, width, 0, 0
  250. PACK_RGBA: colorImage, 0, 0, 0, visImage
  251. END:
  252. BEGIN: HorizontalScrollList
  253. INPUT: FixedPoint, width
  254. INPUT: FixedPoint, height
  255. INPUT: FixedPoint, red
  256. INPUT: FixedPoint, green
  257. INPUT: FixedPoint, blue
  258. OUTPUT: ImageRgbaU8, colorImage
  259. CREATE: visImage<ImageU8>, width, height
  260. CREATE: lumaImage<ImageU8>, width, height
  261. FADE_LINEAR: visImage, 0, 0, 128, 0, height, 0
  262. PACK_RGBA: colorImage, 0, 0, 0, visImage
  263. END: