Drawing.mmc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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: PressableDiffuse3x3
  117. INPUT: FixedPoint, width
  118. INPUT: FixedPoint, height
  119. INPUT: FixedPoint, red
  120. INPUT: FixedPoint, green
  121. INPUT: FixedPoint, blue
  122. INPUT: FixedPoint, pressed
  123. INPUT: FixedPoint, focused
  124. INPUT: FixedPoint, hovered
  125. INPUT: FixedPoint, sourceLeft
  126. INPUT: FixedPoint, sourceTop
  127. INPUT: FixedPoint, sourceWidth
  128. INPUT: FixedPoint, sourceHeight
  129. INPUT: FixedPoint, pressOffsetX
  130. INPUT: FixedPoint, pressOffsetY
  131. INPUT: FixedPoint, preserved
  132. INPUT: ImageRgbaU8, atlas
  133. OUTPUT: ImageRgbaU8, colorImage
  134. # Select image using the pressed state.
  135. MUL: sourceOffsetX<FixedPoint>, pressed, pressOffsetX
  136. MUL: sourceOffsetY<FixedPoint>, pressed, pressOffsetY
  137. ADD: adjustedSourceLeft<FixedPoint>, sourceLeft, sourceOffsetX
  138. ADD: adjustedSourceTop<FixedPoint>, sourceTop, sourceOffsetY
  139. MUL: hoverChange<FixedPoint>, hovered, 0.1
  140. MUL: focusChange<FixedPoint>, focused, -0.2
  141. ADD: intensity<FixedPoint>, 1.0, hoverChange
  142. ADD: intensity, intensity, focusChange
  143. Mul: red, red, intensity
  144. Mul: green, green, intensity
  145. Mul: blue, blue, intensity
  146. # Rescale the source region to fit width and height, while applying the diffuse color and adding white shine.
  147. CALL: Diffuse3x3, colorImage, width, height, red, green, blue, adjustedSourceLeft, adjustedSourceTop, sourceWidth, sourceHeight, preserved, atlas
  148. END:
  149. BEGIN: DiffuseSpecular3x3
  150. INPUT: FixedPoint, width
  151. INPUT: FixedPoint, height
  152. INPUT: FixedPoint, red
  153. INPUT: FixedPoint, green
  154. INPUT: FixedPoint, blue
  155. INPUT: FixedPoint, sourceLeft
  156. INPUT: FixedPoint, sourceTop
  157. INPUT: FixedPoint, sourceWidth
  158. INPUT: FixedPoint, sourceHeight
  159. INPUT: FixedPoint, preserved
  160. INPUT: ImageRgbaU8, atlas
  161. OUTPUT: ImageRgbaU8, colorImage
  162. # Scale by 1 / 255 so that 255 represents full intensity in atlas.
  163. MUL: normRed<FixedPoint>, red, 0.00392156862745
  164. MUL: normGreen<FixedPoint>, green, 0.00392156862745
  165. MUL: normBlue<FixedPoint>, blue, 0.00392156862745
  166. # Resize source region from the atlas.
  167. CALL: Resize3x3, rescaledImage<ImageRgbaU8>, width, height, preserved, atlas, sourceLeft, sourceTop, sourceWidth, sourceHeight
  168. GET_RED: diffuseMap<ImageU8>, rescaledImage
  169. GET_GREEN: specularMap<ImageU8>, rescaledImage
  170. GET_ALPHA: visibilityMap<ImageU8>, rescaledImage
  171. MUL: redImage<ImageU8>, diffuseMap, normRed
  172. MUL: greenImage<ImageU8>, diffuseMap, normGreen
  173. MUL: blueImage<ImageU8>, diffuseMap, normBlue
  174. ADD: redImage, redImage, specularMap
  175. ADD: greenImage, greenImage, specularMap
  176. ADD: blueImage, blueImage, specularMap
  177. PACK_RGBA: colorImage, redImage, greenImage, blueImage, visibilityMap
  178. END:
  179. BEGIN: PressableDiffuseSpecular3x3
  180. INPUT: FixedPoint, width
  181. INPUT: FixedPoint, height
  182. INPUT: FixedPoint, red
  183. INPUT: FixedPoint, green
  184. INPUT: FixedPoint, blue
  185. INPUT: FixedPoint, pressed
  186. INPUT: FixedPoint, focused
  187. INPUT: FixedPoint, hovered
  188. INPUT: FixedPoint, sourceLeft
  189. INPUT: FixedPoint, sourceTop
  190. INPUT: FixedPoint, sourceWidth
  191. INPUT: FixedPoint, sourceHeight
  192. INPUT: FixedPoint, pressOffsetX
  193. INPUT: FixedPoint, pressOffsetY
  194. INPUT: FixedPoint, preserved
  195. INPUT: ImageRgbaU8, atlas
  196. OUTPUT: ImageRgbaU8, colorImage
  197. # Select image using the pressed state.
  198. MUL: sourceOffsetX<FixedPoint>, pressed, pressOffsetX
  199. MUL: sourceOffsetY<FixedPoint>, pressed, pressOffsetY
  200. ADD: adjustedSourceLeft<FixedPoint>, sourceLeft, sourceOffsetX
  201. ADD: adjustedSourceTop<FixedPoint>, sourceTop, sourceOffsetY
  202. MUL: hoverChange<FixedPoint>, hovered, 0.1
  203. MUL: focusChange<FixedPoint>, focused, -0.2
  204. ADD: intensity<FixedPoint>, 1.0, hoverChange
  205. ADD: intensity, intensity, focusChange
  206. Mul: red, red, intensity
  207. Mul: green, green, intensity
  208. Mul: blue, blue, intensity
  209. # Rescale the source region to fit width and height, while applying the diffuse color and adding white shine.
  210. CALL: DiffuseSpecular3x3, colorImage, width, height, red, green, blue, adjustedSourceLeft, adjustedSourceTop, sourceWidth, sourceHeight, preserved, atlas
  211. END:
  212. BEGIN: DiffuseSpecular1x1
  213. INPUT: FixedPoint, width
  214. INPUT: FixedPoint, height
  215. INPUT: FixedPoint, red
  216. INPUT: FixedPoint, green
  217. INPUT: FixedPoint, blue
  218. INPUT: FixedPoint, sourceLeft
  219. INPUT: FixedPoint, sourceTop
  220. INPUT: FixedPoint, sourceWidth
  221. INPUT: FixedPoint, sourceHeight
  222. INPUT: FixedPoint, preserved
  223. INPUT: ImageRgbaU8, atlas
  224. OUTPUT: ImageRgbaU8, colorImage
  225. # Scale by 1 / 255 so that 255 represents full intensity in atlas.
  226. MUL: normRed<FixedPoint>, red, 0.00392156862745
  227. MUL: normGreen<FixedPoint>, green, 0.00392156862745
  228. MUL: normBlue<FixedPoint>, blue, 0.00392156862745
  229. # Resize source region from the atlas.
  230. RESIZE_BILINEAR: rescaledImage<ImageRgbaU8>, width, height, atlas, sourceLeft, sourceTop, sourceWidth, sourceHeight
  231. GET_RED: diffuseMap<ImageU8>, rescaledImage
  232. GET_GREEN: specularMap<ImageU8>, rescaledImage
  233. GET_ALPHA: visibilityMap<ImageU8>, rescaledImage
  234. MUL: redImage<ImageU8>, diffuseMap, normRed
  235. MUL: greenImage<ImageU8>, diffuseMap, normGreen
  236. MUL: blueImage<ImageU8>, diffuseMap, normBlue
  237. ADD: redImage, redImage, specularMap
  238. ADD: greenImage, greenImage, specularMap
  239. ADD: blueImage, blueImage, specularMap
  240. PACK_RGBA: colorImage, redImage, greenImage, blueImage, visibilityMap
  241. END:
  242. BEGIN: PressableDiffuseSpecular1x1
  243. INPUT: FixedPoint, width
  244. INPUT: FixedPoint, height
  245. INPUT: FixedPoint, red
  246. INPUT: FixedPoint, green
  247. INPUT: FixedPoint, blue
  248. INPUT: FixedPoint, pressed
  249. INPUT: FixedPoint, focused
  250. INPUT: FixedPoint, hovered
  251. INPUT: FixedPoint, sourceLeft
  252. INPUT: FixedPoint, sourceTop
  253. INPUT: FixedPoint, sourceWidth
  254. INPUT: FixedPoint, sourceHeight
  255. INPUT: FixedPoint, pressOffsetX
  256. INPUT: FixedPoint, pressOffsetY
  257. INPUT: FixedPoint, preserved
  258. INPUT: ImageRgbaU8, atlas
  259. OUTPUT: ImageRgbaU8, colorImage
  260. # Select image using the pressed state.
  261. MUL: sourceOffsetX<FixedPoint>, pressed, pressOffsetX
  262. MUL: sourceOffsetY<FixedPoint>, pressed, pressOffsetY
  263. ADD: adjustedSourceLeft<FixedPoint>, sourceLeft, sourceOffsetX
  264. ADD: adjustedSourceTop<FixedPoint>, sourceTop, sourceOffsetY
  265. MUL: hoverChange<FixedPoint>, hovered, 0.1
  266. MUL: focusChange<FixedPoint>, focused, -0.2
  267. ADD: intensity<FixedPoint>, 1.0, hoverChange
  268. ADD: intensity, intensity, focusChange
  269. Mul: red, red, intensity
  270. Mul: green, green, intensity
  271. Mul: blue, blue, intensity
  272. # Rescale the source region to fit width and height, while applying the diffuse color and adding white shine.
  273. CALL: DiffuseSpecular1x1, colorImage, width, height, red, green, blue, adjustedSourceLeft, adjustedSourceTop, sourceWidth, sourceHeight, preserved, atlas
  274. END:
  275. BEGIN: ListBox
  276. INPUT: FixedPoint, width
  277. INPUT: FixedPoint, height
  278. INPUT: FixedPoint, red
  279. INPUT: FixedPoint, green
  280. INPUT: FixedPoint, blue
  281. INPUT: FixedPoint, sourceLeft
  282. INPUT: FixedPoint, sourceTop
  283. INPUT: FixedPoint, sourceWidth
  284. INPUT: FixedPoint, sourceHeight
  285. INPUT: FixedPoint, preserved
  286. INPUT: ImageRgbaU8, atlas
  287. OUTPUT: ImageRgbaU8, colorImage
  288. # Rescale the source region to fit width and height, while applying the diffuse color.
  289. CALL: Diffuse3x3, colorImage, width, height, red, green, blue, sourceLeft, sourceTop, sourceWidth, sourceHeight, preserved, atlas
  290. END:
  291. BEGIN: VerticalScrollList
  292. INPUT: FixedPoint, width
  293. INPUT: FixedPoint, height
  294. INPUT: FixedPoint, red
  295. INPUT: FixedPoint, green
  296. INPUT: FixedPoint, blue
  297. OUTPUT: ImageRgbaU8, colorImage
  298. CREATE: visImage<ImageU8>, width, height
  299. CREATE: lumaImage<ImageU8>, width, height
  300. FADE_LINEAR: visImage, 0, 0, 128, width, 0, 0
  301. PACK_RGBA: colorImage, 0, 0, 0, visImage
  302. END:
  303. BEGIN: HorizontalScrollList
  304. INPUT: FixedPoint, width
  305. INPUT: FixedPoint, height
  306. INPUT: FixedPoint, red
  307. INPUT: FixedPoint, green
  308. INPUT: FixedPoint, blue
  309. OUTPUT: ImageRgbaU8, colorImage
  310. CREATE: visImage<ImageU8>, width, height
  311. CREATE: lumaImage<ImageU8>, width, height
  312. FADE_LINEAR: visImage, 0, 0, 128, 0, height, 0
  313. PACK_RGBA: colorImage, 0, 0, 0, visImage
  314. END: