@shopify/react-native-skia 2.0.6 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/android/CMakeLists.txt +20 -1
  2. package/cpp/api/JsiSkApi.h +3 -0
  3. package/cpp/api/JsiSkImageFilterFactory.h +478 -39
  4. package/cpp/api/JsiSkPath.h +2 -1
  5. package/cpp/api/JsiSkPathFactory.h +1 -1
  6. package/cpp/api/JsiSkSkottie.h +590 -0
  7. package/cpp/api/JsiSkottieFactory.h +65 -0
  8. package/cpp/api/recorder/Command.h +1 -0
  9. package/cpp/api/recorder/Convertor.h +16 -0
  10. package/cpp/api/recorder/Drawings.h +23 -0
  11. package/cpp/api/recorder/JsiRecorder.h +6 -0
  12. package/cpp/api/recorder/RNRecorder.h +9 -0
  13. package/cpp/api/third_party/SkottieUtils.cpp +333 -0
  14. package/cpp/api/third_party/SkottieUtils.h +172 -0
  15. package/cpp/skia/modules/jsonreader/SkJSONReader.cpp +980 -0
  16. package/cpp/skia/modules/jsonreader/SkJSONReader.h +389 -0
  17. package/cpp/skia/modules/skottie/include/ExternalLayer.h +56 -0
  18. package/cpp/skia/modules/skottie/include/Skottie.h +313 -0
  19. package/cpp/skia/modules/skottie/include/SkottieProperty.h +190 -0
  20. package/cpp/skia/modules/skottie/include/SlotManager.h +113 -0
  21. package/cpp/skia/modules/skottie/include/TextShaper.h +200 -0
  22. package/cpp/skia/modules/skottie/src/SkottieValue.h +56 -0
  23. package/cpp/skia/modules/skottie/src/animator/Animator.h +89 -0
  24. package/cpp/skia/modules/skottie/src/text/Font.h +82 -0
  25. package/cpp/skia/modules/skottie/src/text/TextAdapter.h +155 -0
  26. package/cpp/skia/modules/skottie/src/text/TextAnimator.h +121 -0
  27. package/cpp/skia/modules/skottie/src/text/TextValue.h +28 -0
  28. package/cpp/skia/modules/sksg/include/SkSGClipEffect.h +61 -0
  29. package/cpp/skia/modules/sksg/include/SkSGColorFilter.h +135 -0
  30. package/cpp/skia/modules/sksg/include/SkSGDraw.h +57 -0
  31. package/cpp/skia/modules/sksg/include/SkSGEffectNode.h +50 -0
  32. package/cpp/skia/modules/sksg/include/SkSGGeometryEffect.h +181 -0
  33. package/cpp/skia/modules/sksg/include/SkSGGeometryNode.h +54 -0
  34. package/cpp/skia/modules/sksg/include/SkSGGradient.h +108 -0
  35. package/cpp/skia/modules/sksg/include/SkSGGroup.h +65 -0
  36. package/cpp/skia/modules/sksg/include/SkSGImage.h +59 -0
  37. package/cpp/skia/modules/sksg/include/SkSGInvalidationController.h +46 -0
  38. package/cpp/skia/modules/sksg/include/SkSGMaskEffect.h +65 -0
  39. package/cpp/skia/modules/sksg/include/SkSGMerge.h +74 -0
  40. package/cpp/skia/modules/sksg/include/SkSGNode.h +128 -0
  41. package/cpp/skia/modules/sksg/include/SkSGOpacityEffect.h +54 -0
  42. package/cpp/skia/modules/sksg/include/SkSGPaint.h +112 -0
  43. package/cpp/skia/modules/sksg/include/SkSGPath.h +68 -0
  44. package/cpp/skia/modules/sksg/include/SkSGPlane.h +47 -0
  45. package/cpp/skia/modules/sksg/include/SkSGRect.h +122 -0
  46. package/cpp/skia/modules/sksg/include/SkSGRenderEffect.h +283 -0
  47. package/cpp/skia/modules/sksg/include/SkSGRenderNode.h +157 -0
  48. package/cpp/skia/modules/sksg/include/SkSGScene.h +47 -0
  49. package/cpp/skia/modules/sksg/include/SkSGText.h +82 -0
  50. package/cpp/skia/modules/sksg/include/SkSGTransform.h +127 -0
  51. package/cpp/skia/src/base/SkArenaAlloc.h +371 -0
  52. package/lib/commonjs/dom/nodes/datatypes/Gradient.d.ts +15 -15
  53. package/lib/commonjs/dom/types/Drawings.d.ts +5 -1
  54. package/lib/commonjs/dom/types/Drawings.js.map +1 -1
  55. package/lib/commonjs/dom/types/NodeType.d.ts +2 -1
  56. package/lib/commonjs/dom/types/NodeType.js +2 -0
  57. package/lib/commonjs/dom/types/NodeType.js.map +1 -1
  58. package/lib/commonjs/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
  59. package/lib/commonjs/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
  60. package/lib/commonjs/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
  61. package/lib/commonjs/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
  62. package/lib/commonjs/renderer/__tests__/setup.d.ts +5 -0
  63. package/lib/commonjs/renderer/components/Skottie.d.ts +4 -0
  64. package/lib/commonjs/renderer/components/Skottie.js +13 -0
  65. package/lib/commonjs/renderer/components/Skottie.js.map +1 -0
  66. package/lib/commonjs/renderer/components/index.d.ts +1 -0
  67. package/lib/commonjs/renderer/components/index.js +11 -0
  68. package/lib/commonjs/renderer/components/index.js.map +1 -1
  69. package/lib/commonjs/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
  70. package/lib/commonjs/skia/types/ImageFilter/ImageFilterFactory.js.map +1 -1
  71. package/lib/commonjs/skia/types/Matrix4.d.ts +11 -2
  72. package/lib/commonjs/skia/types/Matrix4.js +42 -1
  73. package/lib/commonjs/skia/types/Matrix4.js.map +1 -1
  74. package/lib/commonjs/skia/types/Recorder.d.ts +2 -1
  75. package/lib/commonjs/skia/types/Recorder.js.map +1 -1
  76. package/lib/commonjs/skia/types/Skia.d.ts +2 -0
  77. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  78. package/lib/commonjs/skia/types/Skottie.d.ts +223 -0
  79. package/lib/commonjs/skia/types/Skottie.js +73 -0
  80. package/lib/commonjs/skia/types/Skottie.js.map +1 -0
  81. package/lib/commonjs/skia/types/index.d.ts +1 -0
  82. package/lib/commonjs/skia/types/index.js +11 -0
  83. package/lib/commonjs/skia/types/index.js.map +1 -1
  84. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
  85. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +88 -19
  86. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  87. package/lib/commonjs/skia/web/JsiSkia.js +2 -0
  88. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  89. package/lib/commonjs/skia/web/JsiSkottieAnimation.d.ts +59 -0
  90. package/lib/commonjs/skia/web/JsiSkottieAnimation.js +243 -0
  91. package/lib/commonjs/skia/web/JsiSkottieAnimation.js.map +1 -0
  92. package/lib/commonjs/skia/web/JsiSkottieFactory.d.ts +9 -0
  93. package/lib/commonjs/skia/web/JsiSkottieFactory.js +26 -0
  94. package/lib/commonjs/skia/web/JsiSkottieFactory.js.map +1 -0
  95. package/lib/commonjs/sksg/Elements.d.ts +2 -1
  96. package/lib/commonjs/sksg/Elements.js.map +1 -1
  97. package/lib/commonjs/sksg/Recorder/Core.d.ts +4 -2
  98. package/lib/commonjs/sksg/Recorder/Core.js +1 -0
  99. package/lib/commonjs/sksg/Recorder/Core.js.map +1 -1
  100. package/lib/commonjs/sksg/Recorder/Player.js +2 -0
  101. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  102. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
  103. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +4 -0
  104. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  105. package/lib/commonjs/sksg/Recorder/Recorder.d.ts +2 -1
  106. package/lib/commonjs/sksg/Recorder/Recorder.js +6 -0
  107. package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
  108. package/lib/commonjs/sksg/Recorder/Visitor.js +3 -0
  109. package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
  110. package/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +2 -2
  111. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +11 -4
  112. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  113. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js +1 -1
  114. package/lib/commonjs/sksg/Recorder/commands/ImageFilters.js.map +1 -1
  115. package/lib/module/dom/nodes/datatypes/Gradient.d.ts +15 -15
  116. package/lib/module/dom/types/Drawings.d.ts +5 -1
  117. package/lib/module/dom/types/Drawings.js.map +1 -1
  118. package/lib/module/dom/types/NodeType.d.ts +2 -1
  119. package/lib/module/dom/types/NodeType.js +2 -0
  120. package/lib/module/dom/types/NodeType.js.map +1 -1
  121. package/lib/module/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
  122. package/lib/module/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
  123. package/lib/module/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
  124. package/lib/module/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
  125. package/lib/module/renderer/__tests__/setup.d.ts +5 -0
  126. package/lib/module/renderer/components/Skottie.d.ts +4 -0
  127. package/lib/module/renderer/components/Skottie.js +5 -0
  128. package/lib/module/renderer/components/Skottie.js.map +1 -0
  129. package/lib/module/renderer/components/index.d.ts +1 -0
  130. package/lib/module/renderer/components/index.js +1 -0
  131. package/lib/module/renderer/components/index.js.map +1 -1
  132. package/lib/module/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
  133. package/lib/module/skia/types/ImageFilter/ImageFilterFactory.js.map +1 -1
  134. package/lib/module/skia/types/Matrix4.d.ts +11 -2
  135. package/lib/module/skia/types/Matrix4.js +40 -0
  136. package/lib/module/skia/types/Matrix4.js.map +1 -1
  137. package/lib/module/skia/types/Recorder.d.ts +2 -1
  138. package/lib/module/skia/types/Recorder.js.map +1 -1
  139. package/lib/module/skia/types/Skia.d.ts +2 -0
  140. package/lib/module/skia/types/Skia.js.map +1 -1
  141. package/lib/module/skia/types/Skottie.d.ts +223 -0
  142. package/lib/module/skia/types/Skottie.js +74 -0
  143. package/lib/module/skia/types/Skottie.js.map +1 -0
  144. package/lib/module/skia/types/index.d.ts +1 -0
  145. package/lib/module/skia/types/index.js +1 -0
  146. package/lib/module/skia/types/index.js.map +1 -1
  147. package/lib/module/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
  148. package/lib/module/skia/web/JsiSkImageFilterFactory.js +88 -19
  149. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  150. package/lib/module/skia/web/JsiSkia.js +2 -0
  151. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  152. package/lib/module/skia/web/JsiSkottieAnimation.d.ts +59 -0
  153. package/lib/module/skia/web/JsiSkottieAnimation.js +236 -0
  154. package/lib/module/skia/web/JsiSkottieAnimation.js.map +1 -0
  155. package/lib/module/skia/web/JsiSkottieFactory.d.ts +9 -0
  156. package/lib/module/skia/web/JsiSkottieFactory.js +19 -0
  157. package/lib/module/skia/web/JsiSkottieFactory.js.map +1 -0
  158. package/lib/module/sksg/Elements.d.ts +2 -1
  159. package/lib/module/sksg/Elements.js.map +1 -1
  160. package/lib/module/sksg/Recorder/Core.d.ts +4 -2
  161. package/lib/module/sksg/Recorder/Core.js +1 -0
  162. package/lib/module/sksg/Recorder/Core.js.map +1 -1
  163. package/lib/module/sksg/Recorder/Player.js +3 -1
  164. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  165. package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
  166. package/lib/module/sksg/Recorder/ReanimatedRecorder.js +4 -0
  167. package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  168. package/lib/module/sksg/Recorder/Recorder.d.ts +2 -1
  169. package/lib/module/sksg/Recorder/Recorder.js +6 -0
  170. package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
  171. package/lib/module/sksg/Recorder/Visitor.js +3 -0
  172. package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
  173. package/lib/module/sksg/Recorder/commands/Drawing.d.ts +2 -2
  174. package/lib/module/sksg/Recorder/commands/Drawing.js +9 -2
  175. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  176. package/lib/module/sksg/Recorder/commands/ImageFilters.js +1 -1
  177. package/lib/module/sksg/Recorder/commands/ImageFilters.js.map +1 -1
  178. package/lib/typescript/lib/commonjs/renderer/components/Skottie.d.ts +2 -0
  179. package/lib/typescript/lib/commonjs/skia/types/Matrix4.d.ts +1 -0
  180. package/lib/typescript/lib/commonjs/skia/types/Skottie.d.ts +6 -0
  181. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFilterFactory.d.ts +22 -5
  182. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +2 -0
  183. package/lib/typescript/lib/commonjs/skia/web/JsiSkottieAnimation.d.ts +48 -0
  184. package/lib/typescript/lib/commonjs/skia/web/JsiSkottieFactory.d.ts +6 -0
  185. package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  186. package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -0
  187. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Drawing.d.ts +1 -1
  188. package/lib/typescript/lib/module/mock/index.d.ts +7 -0
  189. package/lib/typescript/lib/module/renderer/components/Skottie.d.ts +2 -0
  190. package/lib/typescript/lib/module/renderer/components/index.d.ts +1 -0
  191. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -0
  192. package/lib/typescript/lib/module/skia/types/Matrix4.d.ts +1 -0
  193. package/lib/typescript/lib/module/skia/types/Skottie.d.ts +5 -0
  194. package/lib/typescript/lib/module/skia/types/index.d.ts +1 -0
  195. package/lib/typescript/lib/module/skia/web/JsiSkImageFilterFactory.d.ts +22 -5
  196. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +2 -0
  197. package/lib/typescript/lib/module/skia/web/JsiSkottieAnimation.d.ts +47 -0
  198. package/lib/typescript/lib/module/skia/web/JsiSkottieFactory.d.ts +5 -0
  199. package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -0
  200. package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -0
  201. package/lib/typescript/lib/module/sksg/Recorder/commands/Drawing.d.ts +1 -1
  202. package/lib/typescript/src/dom/nodes/datatypes/Gradient.d.ts +15 -15
  203. package/lib/typescript/src/dom/types/Drawings.d.ts +5 -1
  204. package/lib/typescript/src/dom/types/NodeType.d.ts +2 -1
  205. package/lib/typescript/src/renderer/__tests__/e2e/AdvancedImageFilters.spec.d.ts +1 -0
  206. package/lib/typescript/src/renderer/__tests__/e2e/Camera.spec.d.ts +21 -0
  207. package/lib/typescript/src/renderer/__tests__/e2e/LightingImageFilters.spec.d.ts +1 -0
  208. package/lib/typescript/src/renderer/__tests__/e2e/Skottie.spec.d.ts +1 -0
  209. package/lib/typescript/src/renderer/__tests__/setup.d.ts +5 -0
  210. package/lib/typescript/src/renderer/components/Skottie.d.ts +4 -0
  211. package/lib/typescript/src/renderer/components/index.d.ts +1 -0
  212. package/lib/typescript/src/skia/types/ImageFilter/ImageFilterFactory.d.ts +252 -15
  213. package/lib/typescript/src/skia/types/Matrix4.d.ts +11 -2
  214. package/lib/typescript/src/skia/types/Recorder.d.ts +2 -1
  215. package/lib/typescript/src/skia/types/Skia.d.ts +2 -0
  216. package/lib/typescript/src/skia/types/Skottie.d.ts +223 -0
  217. package/lib/typescript/src/skia/types/index.d.ts +1 -0
  218. package/lib/typescript/src/skia/web/JsiSkImageFilterFactory.d.ts +29 -12
  219. package/lib/typescript/src/skia/web/JsiSkottieAnimation.d.ts +59 -0
  220. package/lib/typescript/src/skia/web/JsiSkottieFactory.d.ts +9 -0
  221. package/lib/typescript/src/sksg/Elements.d.ts +2 -1
  222. package/lib/typescript/src/sksg/Recorder/Core.d.ts +4 -2
  223. package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +2 -1
  224. package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +2 -1
  225. package/lib/typescript/src/sksg/Recorder/commands/Drawing.d.ts +2 -2
  226. package/libs/android/arm64-v8a/libjsonreader.a +0 -0
  227. package/libs/android/armeabi-v7a/libjsonreader.a +0 -0
  228. package/libs/android/x86/libjsonreader.a +0 -0
  229. package/libs/android/x86_64/libjsonreader.a +0 -0
  230. package/libs/apple/libpathops.xcframework/Info.plist +9 -9
  231. package/libs/apple/libskia.xcframework/Info.plist +14 -14
  232. package/libs/apple/libskottie.xcframework/Info.plist +13 -13
  233. package/libs/apple/libskparagraph.xcframework/Info.plist +15 -15
  234. package/libs/apple/libsksg.xcframework/Info.plist +13 -13
  235. package/libs/apple/libskshaper.xcframework/Info.plist +15 -15
  236. package/libs/apple/libskunicode_core.xcframework/Info.plist +9 -9
  237. package/libs/apple/libskunicode_libgrapheme.xcframework/Info.plist +13 -13
  238. package/libs/apple/libsvg.xcframework/Info.plist +15 -15
  239. package/package.json +1 -1
  240. package/react-native-skia.podspec +4 -2
  241. package/src/__tests__/snapshots/matrix4/camera-corner.png +0 -0
  242. package/src/__tests__/snapshots/matrix4/camera-offset.png +0 -0
  243. package/src/__tests__/snapshots/matrix4/camera-top-left-center.png +0 -0
  244. package/src/__tests__/snapshots/matrix4/camera-zoom-out.png +0 -0
  245. package/src/__tests__/snapshots/matrix4/full-rect.png +0 -0
  246. package/src/__tests__/snapshots/matrix4/rect.png +0 -0
  247. package/src/__tests__/snapshots/matrix4/scaled-rect.png +0 -0
  248. package/src/__tests__/snapshots/matrix4/test-perspective.png +0 -0
  249. package/src/__tests__/snapshots/matrix4/test-perspective2.png +0 -0
  250. package/src/dom/types/Drawings.ts +6 -0
  251. package/src/dom/types/NodeType.ts +2 -0
  252. package/src/renderer/__tests__/e2e/AdvancedImageFilters.spec.tsx +492 -0
  253. package/src/renderer/__tests__/e2e/Camera.spec.tsx +475 -0
  254. package/src/renderer/__tests__/e2e/LightingImageFilters.spec.tsx +1478 -0
  255. package/src/renderer/__tests__/e2e/Skottie.spec.tsx +440 -0
  256. package/src/renderer/__tests__/e2e/setup/skottie/basic_slots.json +1118 -0
  257. package/src/renderer/__tests__/e2e/setup/skottie/color-props.json +1 -0
  258. package/src/renderer/__tests__/e2e/setup/skottie/confetti.json +5899 -0
  259. package/src/renderer/__tests__/e2e/setup/skottie/drinks.json +43857 -0
  260. package/src/renderer/__tests__/e2e/setup/skottie/fingerprint.json +1 -0
  261. package/src/renderer/__tests__/e2e/setup/skottie/lego_loader.json +29540 -0
  262. package/src/renderer/__tests__/e2e/setup/skottie/new-drop.json +1 -0
  263. package/src/renderer/__tests__/e2e/setup/skottie/onboarding.json +1 -0
  264. package/src/renderer/__tests__/e2e/setup/skottie/text-layer.json +1 -0
  265. package/src/renderer/__tests__/setup.tsx +23 -0
  266. package/src/renderer/components/Skottie.tsx +8 -0
  267. package/src/renderer/components/index.ts +1 -0
  268. package/src/skia/__tests__/assets/Avenir-Heavy.ttf +0 -0
  269. package/src/skia/types/ImageFilter/ImageFilterFactory.ts +391 -21
  270. package/src/skia/types/Matrix4.ts +108 -2
  271. package/src/skia/types/Recorder.ts +2 -0
  272. package/src/skia/types/Skia.ts +2 -0
  273. package/src/skia/types/Skottie.ts +266 -0
  274. package/src/skia/types/index.ts +1 -0
  275. package/src/skia/web/JsiSkImageFilterFactory.ts +266 -31
  276. package/src/skia/web/JsiSkia.ts +2 -0
  277. package/src/skia/web/JsiSkottieAnimation.ts +259 -0
  278. package/src/skia/web/JsiSkottieFactory.ts +25 -0
  279. package/src/sksg/Elements.tsx +2 -0
  280. package/src/sksg/Recorder/Core.ts +3 -0
  281. package/src/sksg/Recorder/Player.ts +3 -0
  282. package/src/sksg/Recorder/ReanimatedRecorder.ts +6 -0
  283. package/src/sksg/Recorder/Recorder.ts +5 -0
  284. package/src/sksg/Recorder/Visitor.ts +3 -0
  285. package/src/sksg/Recorder/commands/Drawing.ts +7 -3
  286. package/src/sksg/Recorder/commands/ImageFilters.ts +1 -1
  287. package/cpp/skia/include/pathops/SkPathOps.h +0 -17
@@ -1,6 +1,9 @@
1
1
  import type { SkColor } from "../Color";
2
2
  import type { SkColorFilter } from "../ColorFilter/ColorFilter";
3
+ import type { FilterMode, MipmapMode, SkImage } from "../Image/Image";
4
+ import type { SkMatrix } from "../Matrix";
3
5
  import type { BlendMode } from "../Paint";
6
+ import type { SkPicture } from "../Picture";
4
7
  import type { SkRect } from "../Rect";
5
8
  import type { SkRuntimeShaderBuilder } from "../RuntimeEffect";
6
9
  import type { SkShader } from "../Shader";
@@ -18,8 +21,9 @@ export interface ImageFilterFactory {
18
21
  * @param dx - Offset along the X axis
19
22
  * @param dy - Offset along the X axis
20
23
  * @param input - if null, it will use the dynamic source image
24
+ * @param cropRect - Optional rectangle that crops the input and output
21
25
  */
22
- MakeOffset(dx: number, dy: number, input: SkImageFilter | null): SkImageFilter;
26
+ MakeOffset(dx: number, dy: number, input?: SkImageFilter | null, cropRect?: SkRect | null): SkImageFilter;
23
27
  /**
24
28
  * Spatially displace pixel values of the filtered image
25
29
  *
@@ -28,31 +32,36 @@ export interface ImageFilterFactory {
28
32
  * @param scale - Scale factor to be used in the displacement
29
33
  * @param in1 - Source image filter to use for the displacement
30
34
  * @param input - if null, it will use the dynamic source image
35
+ * @param cropRect - Optional rectangle that crops the input and output
31
36
  */
32
- MakeDisplacementMap(channelX: ColorChannel, channelY: ColorChannel, scale: number, in1: SkImageFilter, input: SkImageFilter | null): SkImageFilter;
37
+ MakeDisplacementMap(channelX: ColorChannel, channelY: ColorChannel, scale: number, in1: SkImageFilter, input?: SkImageFilter | null, cropRect?: SkRect | null): SkImageFilter;
33
38
  /**
34
39
  * Transforms a shader into an impage filter
35
40
  *
36
41
  * @param shader - The Shader to be transformed
37
- * @param input - if null, it will use the dynamic source image
42
+ * @param dither - Whether to apply dithering to the shader
43
+ * @param cropRect - Optional rectangle that crops the input and output
38
44
  */
39
- MakeShader(shader: SkShader, input: SkImageFilter | null): SkImageFilter;
45
+ MakeShader(shader: SkShader, dither?: boolean, cropRect?: SkRect | null): SkImageFilter;
40
46
  /**
41
47
  * Create a filter that blurs its input by the separate X and Y sigmas. The provided tile mode
42
48
  * is used when the blur kernel goes outside the input image.
43
49
  *
44
50
  * @param sigmaX - The Gaussian sigma value for blurring along the X axis.
45
51
  * @param sigmaY - The Gaussian sigma value for blurring along the Y axis.
46
- * @param mode
52
+ * @param mode - The tile mode to use when blur kernel goes outside the image
47
53
  * @param input - if null, it will use the dynamic source image (e.g. a saved layer)
54
+ * @param cropRect - Optional rectangle that crops the input and output
48
55
  */
49
- MakeBlur(sigmaX: number, sigmaY: number, mode: TileMode, input: SkImageFilter | null): SkImageFilter;
56
+ MakeBlur(sigmaX: number, sigmaY: number, mode: TileMode, input?: SkImageFilter | null, cropRect?: SkRect | null): SkImageFilter;
50
57
  /**
51
58
  * Create a filter that applies the color filter to the input filter results.
52
- * @param cf
59
+ *
60
+ * @param colorFilter - The color filter to apply
53
61
  * @param input - if null, it will use the dynamic source image (e.g. a saved layer)
62
+ * @param cropRect - Optional rectangle that crops the input and output
54
63
  */
55
- MakeColorFilter(cf: SkColorFilter, input: SkImageFilter | null): SkImageFilter;
64
+ MakeColorFilter(colorFilter: SkColorFilter, input?: SkImageFilter | null, cropRect?: SkRect | null): SkImageFilter;
56
65
  /**
57
66
  * Create a filter that composes 'inner' with 'outer', such that the results of 'inner' are
58
67
  * treated as the source bitmap passed to 'outer'.
@@ -72,7 +81,7 @@ export interface ImageFilterFactory {
72
81
  * @param input The input filter, or will use the source bitmap if this is null.
73
82
  * @param cropRect Optional rectangle that crops the input and output.
74
83
  */
75
- MakeDropShadow: (dx: number, dy: number, sigmaX: number, sigmaY: number, color: SkColor, input: SkImageFilter | null, cropRect?: SkRect) => SkImageFilter;
84
+ MakeDropShadow: (dx: number, dy: number, sigmaX: number, sigmaY: number, color: SkColor, input?: SkImageFilter | null, cropRect?: SkRect | null) => SkImageFilter;
76
85
  /**
77
86
  * Create a filter that renders a drop shadow, in exactly the same manner as ::DropShadow, except
78
87
  * that the resulting image does not include the input content.
@@ -85,7 +94,7 @@ export interface ImageFilterFactory {
85
94
  * @param input The input filter, or will use the source bitmap if this is null.
86
95
  * @param cropRect Optional rectangle that crops the input and output.
87
96
  */
88
- MakeDropShadowOnly: (dx: number, dy: number, sigmaX: number, sigmaY: number, color: SkColor, input: SkImageFilter | null, cropRect?: SkRect) => SkImageFilter;
97
+ MakeDropShadowOnly: (dx: number, dy: number, sigmaX: number, sigmaY: number, color: SkColor, input?: SkImageFilter | null, cropRect?: SkRect | null) => SkImageFilter;
89
98
  /**
90
99
  * Create a filter that erodes each input pixel's channel values to the minimum channel value
91
100
  * within the given radii along the x and y axes.
@@ -94,7 +103,7 @@ export interface ImageFilterFactory {
94
103
  * @param input The image filter that is eroded, using source bitmap if this is null.
95
104
  * @param cropRect Optional rectangle that crops the input and output.
96
105
  */
97
- MakeErode: (rx: number, ry: number, input: SkImageFilter | null, cropRect?: SkRect) => SkImageFilter;
106
+ MakeErode: (rx: number, ry: number, input?: SkImageFilter | null, cropRect?: SkRect | null) => SkImageFilter;
98
107
  /**
99
108
  * Create a filter that dilates each input pixel's channel values to the max value within the
100
109
  * given radii along the x and y axes.
@@ -103,15 +112,15 @@ export interface ImageFilterFactory {
103
112
  * @param input The image filter that is dilated, using source bitmap if this is null.
104
113
  * @param cropRect Optional rectangle that crops the input and output.
105
114
  */
106
- MakeDilate: (rx: number, ry: number, input: SkImageFilter | null, cropRect?: SkRect) => SkImageFilter;
115
+ MakeDilate: (rx: number, ry: number, input?: SkImageFilter | null, cropRect?: SkRect | null) => SkImageFilter;
107
116
  /**
108
117
  * This filter takes an SkBlendMode and uses it to composite the two filters together.
109
118
  * @param mode The blend mode that defines the compositing operation
110
119
  * @param background The Dst pixels used in blending, if null the source bitmap is used.
111
120
  * @param foreground The Src pixels used in blending, if null the source bitmap is used.
112
- * @cropRect Optional rectangle to crop input and output.
121
+ * @param cropRect Optional rectangle to crop input and output.
113
122
  */
114
- MakeBlend: (mode: BlendMode, background: SkImageFilter, foreground: SkImageFilter | null, cropRect?: SkRect) => SkImageFilter;
123
+ MakeBlend: (mode: BlendMode, background: SkImageFilter, foreground?: SkImageFilter | null, cropRect?: SkRect | null) => SkImageFilter;
115
124
  /**
116
125
  * Create a filter that fills the output with the per-pixel evaluation of the SkShader produced
117
126
  * by the SkRuntimeShaderBuilder. The shader is defined in the image filter's local coordinate
@@ -126,5 +135,233 @@ export interface ImageFilterFactory {
126
135
  * @param input The image filter that will be provided as input to the runtime
127
136
  * shader. If null the implicit source image is used instead
128
137
  */
129
- MakeRuntimeShader: (builder: SkRuntimeShaderBuilder, childShaderName: string | null, input: SkImageFilter | null) => SkImageFilter;
138
+ MakeRuntimeShader: (builder: SkRuntimeShaderBuilder, childShaderName: string | null, input?: SkImageFilter | null) => SkImageFilter;
139
+ /**
140
+ * Create a filter that implements a custom blend mode. Each output pixel is the result of
141
+ * combining the corresponding background and foreground pixels using the 4 coefficients:
142
+ * k1 * foreground * background + k2 * foreground + k3 * background + k4
143
+ *
144
+ * @param k1, k2, k3, k4 The four coefficients used to combine the foreground and background.
145
+ * @param enforcePMColor If true, the RGB channels will be clamped to the calculated alpha.
146
+ * @param background The background content, using the source bitmap when this is null.
147
+ * @param foreground The foreground content, using the source bitmap when this is null.
148
+ * @param cropRect Optional rectangle that crops the inputs and output.
149
+ */
150
+ MakeArithmetic(k1: number, k2: number, k3: number, k4: number, enforcePMColor: boolean, background?: SkImageFilter | null, foreground?: SkImageFilter | null, cropRect?: SkRect | null): SkImageFilter;
151
+ /**
152
+ * Create a filter that applies a crop to the result of the 'input' filter. Pixels within the
153
+ * crop rectangle are unmodified from what 'input' produced. Pixels outside of crop match the
154
+ * provided SkTileMode (defaulting to kDecal).
155
+ *
156
+ * NOTE: The optional CropRect argument for many of the factories is equivalent to creating the
157
+ * filter without a CropRect and then wrapping it in ::Crop(rect, kDecal). Explicitly adding
158
+ * Crop filters lets you control their tiling and use different geometry for the input and the
159
+ * output of another filter.
160
+ *
161
+ * @param rect The cropping rect
162
+ * @param tileMode The TileMode applied to pixels *outside* of 'crop' @default TileMode.Decal
163
+ * @param input The input filter that is cropped, uses source image if this is null
164
+ */
165
+ MakeCrop(rect: SkRect, tileMode?: TileMode | null, input?: SkImageFilter | null): SkImageFilter;
166
+ /**
167
+ * Create a filter that always produces transparent black.
168
+ */
169
+ MakeEmpty(): SkImageFilter;
170
+ /**
171
+ * Create a filter that draws the 'srcRect' portion of image into 'dstRect' using the given
172
+ * filter quality. Similar to SkCanvas::drawImageRect. The returned image filter evaluates
173
+ * to transparent black if 'image' is null.
174
+ *
175
+ * @param image The image that is output by the filter, subset by 'srcRect'.
176
+ * @param srcRect The source pixels sampled into 'dstRect', if null the image bounds are used.
177
+ * @param dstRect The local rectangle to draw the image into, if null the srcRect is used.
178
+ * @param filterMode The filter mode to use when sampling the image @default FilterMode.Nearest
179
+ * @param mipmap The mipmap mode to use when sampling the image @default MipmapMode.None
180
+ */
181
+ MakeImage(image: SkImage, srcRect?: SkRect | null, dstRect?: SkRect | null, filterMode?: FilterMode, mipmap?: MipmapMode): SkImageFilter;
182
+ /**
183
+ * Create a filter that fills 'lensBounds' with a magnification of the input.
184
+ *
185
+ * @param lensBounds The outer bounds of the magnifier effect
186
+ * @param zoomAmount The amount of magnification applied to the input image
187
+ * @param inset The size or width of the fish-eye distortion around the magnified content
188
+ * @param filterMode The filter mode to use when sampling the image @default FilterMode.Nearest
189
+ * @param mipmap The mipmap mode to use when sampling the image @default MipmapMode.None
190
+ * @param input The input filter that is magnified; if null the source bitmap is used
191
+ * @param cropRect Optional rectangle that crops the input and output.
192
+ */
193
+ MakeMagnifier(lensBounds: SkRect, zoomAmount: number, inset: number, filterMode?: FilterMode, mipmap?: MipmapMode, input?: SkImageFilter | null, cropRect?: SkRect | null): SkImageFilter;
194
+ /**
195
+ * Create a filter that applies an NxM image processing kernel to the input image. This can be
196
+ * used to produce effects such as sharpening, blurring, edge detection, etc.
197
+ * @param kernelSizeX The width of the kernel. Must be greater than zero.
198
+ * @param kernelSizeY The height of the kernel. Must be greater than zero.
199
+ * @param kernel The image processing kernel. Must contain kernelSizeX * kernelSizeY elements, in row order.
200
+ * @param gain A scale factor applied to each pixel after convolution. This can be
201
+ * used to normalize the kernel, if it does not already sum to 1.
202
+ * @param bias A bias factor added to each pixel after convolution.
203
+ * @param kernelOffsetX An offset applied to each pixel coordinate before convolution.
204
+ * This can be used to center the kernel over the image
205
+ * (e.g., a 3x3 kernel should have an offset of {1, 1}).
206
+ * @param kernelOffsetY An offset applied to each pixel coordinate before convolution.
207
+ * This can be used to center the kernel over the image
208
+ * (e.g., a 3x3 kernel should have an offset of {1, 1}).
209
+ * @param tileMode How accesses outside the image are treated. TileMode.Mirror is not supported.
210
+ * @param convolveAlpha If true, all channels are convolved. If false, only the RGB channels
211
+ * are convolved, and alpha is copied from the source image.
212
+ * @param input The input image filter, if null the source bitmap is used instead.
213
+ * @param cropRect Optional rectangle to which the output processing will be limited.
214
+ */
215
+ MakeMatrixConvolution(kernelSizeX: number, kernelSizeY: number, kernel: number[], gain: number, bias: number, kernelOffsetX: number, kernelOffsetY: number, tileMode: TileMode, convolveAlpha: boolean, input?: SkImageFilter | null, cropRect?: SkRect | null): SkImageFilter;
216
+ /**
217
+ * Create a filter that transforms the input image by 'matrix'. This matrix transforms the
218
+ * local space, which means it effectively happens prior to any transformation coming from the
219
+ * SkCanvas initiating the filtering.
220
+ * @param matrix The matrix to apply to the original content.
221
+ * @param filterMode The filter mode to use when sampling the image @default FilterMode.Nearest
222
+ * @param mipmap The mipmap mode to use when sampling the image @default MipmapMode.None
223
+ * @param input The image filter to transform, or null to use the source image.
224
+ */
225
+ MakeMatrixTransform(matrix: SkMatrix, filterMode?: FilterMode, mipmap?: MipmapMode, input?: SkImageFilter | null): SkImageFilter;
226
+ /**
227
+ * Create a filter that merges filters together by drawing their results in order
228
+ * with src-over blending.
229
+ * @param filters The input filter array to merge. Any null
230
+ * filter pointers will use the source bitmap instead.
231
+ * @param cropRect Optional rectangle that crops all input filters and the output.
232
+ */
233
+ MakeMerge(filters: Array<SkImageFilter | null>, cropRect?: SkRect | null): SkImageFilter;
234
+ /**
235
+ * Create a filter that produces the SkPicture as its output, clipped to both 'targetRect' and
236
+ * the picture's internal cull rect.
237
+ *
238
+ * If 'pic' is null, the returned image filter produces transparent black.
239
+ *
240
+ * @param picture The picture that is drawn for the filter output.
241
+ * @param targetRect The drawing region for the picture. If null, the picture's bounds are used.
242
+ */
243
+ MakePicture(picture: SkPicture, targetRect?: SkRect | null): SkImageFilter;
244
+ /**
245
+ * Create a filter that fills the output with the per-pixel evaluation of the SkShader produced
246
+ * by the SkRuntimeEffectBuilder. The shader is defined in the image filter's local coordinate
247
+ * system, so it will automatically be affected by SkCanvas' transform.
248
+ *
249
+ * This requires a GPU backend or SkSL to be compiled in.
250
+ *
251
+ * @param builder The builder used to produce the runtime shader, that will in turn
252
+ * fill the result image
253
+ * @param sampleRadius defines the sampling radius of 'childShaderName' relative to
254
+ * the runtime shader produced by 'builder'.
255
+ * If greater than 0, the coordinate passed to childShader.eval() will
256
+ * be up to 'sampleRadius' away (maximum absolute offset in 'x' or 'y')
257
+ * from the coordinate passed into the runtime shader.
258
+ * @param childShaderNames The names of the child shaders defined in the builder that will be
259
+ * bound to the input params (or the source image if the input param
260
+ * is null). If any name is null, or appears more than once, factory
261
+ * fails and returns nullptr.
262
+ * @param inputs The image filters that will be provided as input to the runtime
263
+ * shader. If any are null, the implicit source image is used instead.
264
+ */
265
+ MakeRuntimeShaderWithChildren: (builder: SkRuntimeShaderBuilder, sampleRadius: number, childShaderNames: string[], inputs: Array<SkImageFilter | null>) => SkImageFilter;
266
+ /**
267
+ * Create a tile image filter.
268
+ * @param src Defines the pixels to tile
269
+ * @param dst Defines the pixel region that the tiles will be drawn to
270
+ * @param input The input that will be tiled, if null the source bitmap is used instead.
271
+ */
272
+ MakeTile(src: SkRect, dst: SkRect, input?: SkImageFilter | null): SkImageFilter;
273
+ /**
274
+ * Create a filter that calculates the diffuse illumination from a distant light source,
275
+ * interpreting the alpha channel of the input as the height profile of the surface (to
276
+ * approximate normal vectors).
277
+ * @param direction The direction to the distance light.
278
+ * @param lightColor The color of the diffuse light source.
279
+ * @param surfaceScale Scale factor to transform from alpha values to physical height.
280
+ * @param kd Diffuse reflectance coefficient.
281
+ * @param input The input filter that defines surface normals (as alpha), or uses the
282
+ * source bitmap when null.
283
+ * @param cropRect Optional rectangle that crops the input and output.
284
+ */
285
+ MakeDistantLitDiffuse(direction: SkPoint3, lightColor: SkColor, surfaceScale: number, kd: number, input?: SkImageFilter | null, cropRect?: SkRect | null): SkImageFilter;
286
+ /**
287
+ * Create a filter that calculates the diffuse illumination from a point light source, using
288
+ * alpha channel of the input as the height profile of the surface (to approximate normal
289
+ * vectors).
290
+ * @param location The location of the point light.
291
+ * @param lightColor The color of the diffuse light source.
292
+ * @param surfaceScale Scale factor to transform from alpha values to physical height.
293
+ * @param kd Diffuse reflectance coefficient.
294
+ * @param input The input filter that defines surface normals (as alpha), or uses the
295
+ * source bitmap when null.
296
+ * @param cropRect Optional rectangle that crops the input and output.
297
+ */
298
+ MakePointLitDiffuse(location: SkPoint3, lightColor: SkColor, surfaceScale: number, kd: number, input?: SkImageFilter | null, cropRect?: SkRect | null): SkImageFilter;
299
+ /**
300
+ * Create a filter that calculates the diffuse illumination from a spot light source, using
301
+ * alpha channel of the input as the height profile of the surface (to approximate normal
302
+ * vectors). The spot light is restricted to be within 'cutoffAngle' of the vector between
303
+ * the location and target.
304
+ * @param location The location of the spot light.
305
+ * @param target The location that the spot light is point towards
306
+ * @param falloffExponent Exponential falloff parameter for illumination outside of cutoffAngle
307
+ * @param cutoffAngle Maximum angle from lighting direction that receives full light
308
+ * @param lightColor The color of the diffuse light source.
309
+ * @param surfaceScale Scale factor to transform from alpha values to physical height.
310
+ * @param kd Diffuse reflectance coefficient.
311
+ * @param input The input filter that defines surface normals (as alpha), or uses the
312
+ * source bitmap when null.
313
+ * @param cropRect Optional rectangle that crops the input and output.
314
+ */
315
+ MakeSpotLitDiffuse(location: SkPoint3, target: SkPoint3, falloffExponent: number, cutoffAngle: number, lightColor: SkColor, surfaceScale: number, kd: number, input?: SkImageFilter | null, cropRect?: SkRect | null): SkImageFilter;
316
+ /**
317
+ * Create a filter that calculates the specular illumination from a distant light source,
318
+ * interpreting the alpha channel of the input as the height profile of the surface (to
319
+ * approximate normal vectors).
320
+ * @param direction The direction to the distance light.
321
+ * @param lightColor The color of the specular light source.
322
+ * @param surfaceScale Scale factor to transform from alpha values to physical height.
323
+ * @param ks Specular reflectance coefficient.
324
+ * @param shininess The specular exponent determining how shiny the surface is.
325
+ * @param input The input filter that defines surface normals (as alpha), or uses the
326
+ * source bitmap when null.
327
+ * @param cropRect Optional rectangle that crops the input and output.
328
+ */
329
+ MakeDistantLitSpecular(direction: SkPoint3, lightColor: SkColor, surfaceScale: number, ks: number, shininess: number, input?: SkImageFilter | null, cropRect?: SkRect | null): SkImageFilter;
330
+ /**
331
+ * Create a filter that calculates the specular illumination from a point light source, using
332
+ * alpha channel of the input as the height profile of the surface (to approximate normal
333
+ * vectors).
334
+ * @param location The location of the point light.
335
+ * @param lightColor The color of the specular light source.
336
+ * @param surfaceScale Scale factor to transform from alpha values to physical height.
337
+ * @param ks Specular reflectance coefficient.
338
+ * @param shininess The specular exponent determining how shiny the surface is.
339
+ * @param input The input filter that defines surface normals (as alpha), or uses the
340
+ * source bitmap when null.
341
+ * @param cropRect Optional rectangle that crops the input and output.
342
+ */
343
+ MakePointLitSpecular(location: SkPoint3, lightColor: SkColor, surfaceScale: number, ks: number, shininess: number, input?: SkImageFilter | null, cropRect?: SkRect | null): SkImageFilter;
344
+ /**
345
+ * Create a filter that calculates the specular illumination from a spot light source, using
346
+ * alpha channel of the input as the height profile of the surface (to approximate normal
347
+ * vectors). The spot light is restricted to be within 'cutoffAngle' of the vector between
348
+ * the location and target.
349
+ * @param location The location of the spot light.
350
+ * @param target The location that the spot light is point towards
351
+ * @param falloffExponent Exponential falloff parameter for illumination outside of cutoffAngle
352
+ * @param cutoffAngle Maximum angle from lighting direction that receives full light
353
+ * @param lightColor The color of the specular light source.
354
+ * @param surfaceScale Scale factor to transform from alpha values to physical height.
355
+ * @param ks Specular reflectance coefficient.
356
+ * @param shininess The specular exponent determining how shiny the surface is.
357
+ * @param input The input filter that defines surface normals (as alpha), or uses the
358
+ * source bitmap when null.
359
+ * @param cropRect Optional rectangle that crops the input and output.
360
+ */
361
+ MakeSpotLitSpecular(location: SkPoint3, target: SkPoint3, falloffExponent: number, cutoffAngle: number, lightColor: SkColor, surfaceScale: number, ks: number, shininess: number, input?: SkImageFilter | null, cropRect?: SkRect | null): SkImageFilter;
130
362
  }
363
+ export type SkPoint3 = {
364
+ x: number;
365
+ y: number;
366
+ z: number;
367
+ };
@@ -1 +1 @@
1
- {"version":3,"names":["ColorChannel","exports"],"sources":["ImageFilterFactory.ts"],"sourcesContent":["import type { SkColor } from \"../Color\";\nimport type { SkColorFilter } from \"../ColorFilter/ColorFilter\";\nimport type { BlendMode } from \"../Paint\";\nimport type { SkRect } from \"../Rect\";\nimport type { SkRuntimeShaderBuilder } from \"../RuntimeEffect\";\nimport type { SkShader } from \"../Shader\";\n\nimport type { SkImageFilter, TileMode } from \"./ImageFilter\";\n\nexport enum ColorChannel {\n R,\n G,\n B,\n A,\n}\n\nexport interface ImageFilterFactory {\n /**\n * Offsets the input image\n *\n * @param dx - Offset along the X axis\n * @param dy - Offset along the X axis\n * @param input - if null, it will use the dynamic source image\n */\n MakeOffset(\n dx: number,\n dy: number,\n input: SkImageFilter | null\n ): SkImageFilter;\n /**\n * Spatially displace pixel values of the filtered image\n *\n * @param channelX - Color channel to be used along the X axis\n * @param channelY - Color channel to be used along the Y axis\n * @param scale - Scale factor to be used in the displacement\n * @param in1 - Source image filter to use for the displacement\n * @param input - if null, it will use the dynamic source image\n */\n MakeDisplacementMap(\n channelX: ColorChannel,\n channelY: ColorChannel,\n scale: number,\n in1: SkImageFilter,\n input: SkImageFilter | null\n ): SkImageFilter;\n /**\n * Transforms a shader into an impage filter\n *\n * @param shader - The Shader to be transformed\n * @param input - if null, it will use the dynamic source image\n */\n MakeShader(shader: SkShader, input: SkImageFilter | null): SkImageFilter;\n /**\n * Create a filter that blurs its input by the separate X and Y sigmas. The provided tile mode\n * is used when the blur kernel goes outside the input image.\n *\n * @param sigmaX - The Gaussian sigma value for blurring along the X axis.\n * @param sigmaY - The Gaussian sigma value for blurring along the Y axis.\n * @param mode\n * @param input - if null, it will use the dynamic source image (e.g. a saved layer)\n */\n MakeBlur(\n sigmaX: number,\n sigmaY: number,\n mode: TileMode,\n input: SkImageFilter | null\n ): SkImageFilter;\n\n /**\n * Create a filter that applies the color filter to the input filter results.\n * @param cf\n * @param input - if null, it will use the dynamic source image (e.g. a saved layer)\n */\n MakeColorFilter(\n cf: SkColorFilter,\n input: SkImageFilter | null\n ): SkImageFilter;\n\n /**\n * Create a filter that composes 'inner' with 'outer', such that the results of 'inner' are\n * treated as the source bitmap passed to 'outer'.\n * If either param is null, the other param will be returned.\n * @param outer\n * @param inner - if null, it will use the dynamic source image (e.g. a saved layer)\n */\n MakeCompose(\n outer: SkImageFilter | null,\n inner: SkImageFilter | null\n ): SkImageFilter;\n\n /**\n * Create a filter that draws a drop shadow under the input content.\n * This filter produces an image that includes the inputs' content.\n * @param dx The X offset of the shadow.\n * @param dy\tThe Y offset of the shadow.\n * @param sigmaX\tThe blur radius for the shadow, along the X axis.\n * @param sigmaY\tThe blur radius for the shadow, along the Y axis.\n * @param color\tThe color of the drop shadow.\n * @param input\tThe input filter, or will use the source bitmap if this is null.\n * @param cropRect\tOptional rectangle that crops the input and output.\n */\n MakeDropShadow: (\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n /**\n * Create a filter that renders a drop shadow, in exactly the same manner as ::DropShadow, except\n * that the resulting image does not include the input content.\n * This allows the shadow and input to be composed by a filter DAG in a more flexible manner.\n * @param dx The X offset of the shadow.\n * @param dy\tThe Y offset of the shadow.\n * @param sigmaX\tThe blur radius for the shadow, along the X axis.\n * @param sigmaY\tThe blur radius for the shadow, along the Y axis.\n * @param color\tThe color of the drop shadow.\n * @param input\tThe input filter, or will use the source bitmap if this is null.\n * @param cropRect\tOptional rectangle that crops the input and output.\n */\n MakeDropShadowOnly: (\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n /**\n * Create a filter that erodes each input pixel's channel values to the minimum channel value\n * within the given radii along the x and y axes.\n * @param radiusX The distance to erode along the x axis to either side of each pixel.\n * @param radiusY The distance to erode along the y axis to either side of each pixel.\n * @param input The image filter that is eroded, using source bitmap if this is null.\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakeErode: (\n rx: number,\n ry: number,\n input: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n /**\n * Create a filter that dilates each input pixel's channel values to the max value within the\n * given radii along the x and y axes.\n * @param radiusX The distance to dilate along the x axis to either side of each pixel.\n * @param radiusY The distance to dilate along the y axis to either side of each pixel.\n * @param input The image filter that is dilated, using source bitmap if this is null.\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakeDilate: (\n rx: number,\n ry: number,\n input: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n /**\n * This filter takes an SkBlendMode and uses it to composite the two filters together.\n * @param mode The blend mode that defines the compositing operation\n * @param background The Dst pixels used in blending, if null the source bitmap is used.\n * @param foreground The Src pixels used in blending, if null the source bitmap is used.\n * @cropRect Optional rectangle to crop input and output.\n */\n MakeBlend: (\n mode: BlendMode,\n background: SkImageFilter,\n foreground: SkImageFilter | null,\n cropRect?: SkRect\n ) => SkImageFilter;\n /**\n * Create a filter that fills the output with the per-pixel evaluation of the SkShader produced\n * by the SkRuntimeShaderBuilder. The shader is defined in the image filter's local coordinate\n * system, so it will automatically be affected by SkCanvas' transform.\n *\n * @param builder The builder used to produce the runtime shader, that will in turn\n * fill the result image\n * @param childShaderName The name of the child shader defined in the builder that will be\n * bound to the input param (or the source image if the input param\n * is null). If null the builder can have exactly one child shader,\n * which automatically binds the input param.\n * @param input The image filter that will be provided as input to the runtime\n * shader. If null the implicit source image is used instead\n */\n MakeRuntimeShader: (\n builder: SkRuntimeShaderBuilder,\n childShaderName: string | null,\n input: SkImageFilter | null\n ) => SkImageFilter;\n}\n"],"mappings":";;;;;;IASYA,YAAY,GAAAC,OAAA,CAAAD,YAAA,0BAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["ColorChannel","exports"],"sources":["ImageFilterFactory.ts"],"sourcesContent":["import type { SkColor } from \"../Color\";\nimport type { SkColorFilter } from \"../ColorFilter/ColorFilter\";\nimport type { FilterMode, MipmapMode, SkImage } from \"../Image/Image\";\nimport type { SkMatrix } from \"../Matrix\";\nimport type { BlendMode } from \"../Paint\";\nimport type { SkPicture } from \"../Picture\";\nimport type { SkRect } from \"../Rect\";\nimport type { SkRuntimeShaderBuilder } from \"../RuntimeEffect\";\nimport type { SkShader } from \"../Shader\";\n\nimport type { SkImageFilter, TileMode } from \"./ImageFilter\";\n\nexport enum ColorChannel {\n R,\n G,\n B,\n A,\n}\n\nexport interface ImageFilterFactory {\n /**\n * Offsets the input image\n *\n * @param dx - Offset along the X axis\n * @param dy - Offset along the X axis\n * @param input - if null, it will use the dynamic source image\n * @param cropRect - Optional rectangle that crops the input and output\n */\n MakeOffset(\n dx: number,\n dy: number,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ): SkImageFilter;\n /**\n * Spatially displace pixel values of the filtered image\n *\n * @param channelX - Color channel to be used along the X axis\n * @param channelY - Color channel to be used along the Y axis\n * @param scale - Scale factor to be used in the displacement\n * @param in1 - Source image filter to use for the displacement\n * @param input - if null, it will use the dynamic source image\n * @param cropRect - Optional rectangle that crops the input and output\n */\n MakeDisplacementMap(\n channelX: ColorChannel,\n channelY: ColorChannel,\n scale: number,\n in1: SkImageFilter,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ): SkImageFilter;\n /**\n * Transforms a shader into an impage filter\n *\n * @param shader - The Shader to be transformed\n * @param dither - Whether to apply dithering to the shader\n * @param cropRect - Optional rectangle that crops the input and output\n */\n MakeShader(\n shader: SkShader,\n dither?: boolean,\n cropRect?: SkRect | null\n ): SkImageFilter;\n /**\n * Create a filter that blurs its input by the separate X and Y sigmas. The provided tile mode\n * is used when the blur kernel goes outside the input image.\n *\n * @param sigmaX - The Gaussian sigma value for blurring along the X axis.\n * @param sigmaY - The Gaussian sigma value for blurring along the Y axis.\n * @param mode - The tile mode to use when blur kernel goes outside the image\n * @param input - if null, it will use the dynamic source image (e.g. a saved layer)\n * @param cropRect - Optional rectangle that crops the input and output\n */\n MakeBlur(\n sigmaX: number,\n sigmaY: number,\n mode: TileMode,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ): SkImageFilter;\n\n /**\n * Create a filter that applies the color filter to the input filter results.\n *\n * @param colorFilter - The color filter to apply\n * @param input - if null, it will use the dynamic source image (e.g. a saved layer)\n * @param cropRect - Optional rectangle that crops the input and output\n */\n MakeColorFilter(\n colorFilter: SkColorFilter,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ): SkImageFilter;\n\n /**\n * Create a filter that composes 'inner' with 'outer', such that the results of 'inner' are\n * treated as the source bitmap passed to 'outer'.\n * If either param is null, the other param will be returned.\n * @param outer\n * @param inner - if null, it will use the dynamic source image (e.g. a saved layer)\n */\n MakeCompose(\n outer: SkImageFilter | null,\n inner: SkImageFilter | null\n ): SkImageFilter;\n\n /**\n * Create a filter that draws a drop shadow under the input content.\n * This filter produces an image that includes the inputs' content.\n * @param dx The X offset of the shadow.\n * @param dy\tThe Y offset of the shadow.\n * @param sigmaX\tThe blur radius for the shadow, along the X axis.\n * @param sigmaY\tThe blur radius for the shadow, along the Y axis.\n * @param color\tThe color of the drop shadow.\n * @param input\tThe input filter, or will use the source bitmap if this is null.\n * @param cropRect\tOptional rectangle that crops the input and output.\n */\n MakeDropShadow: (\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ) => SkImageFilter;\n /**\n * Create a filter that renders a drop shadow, in exactly the same manner as ::DropShadow, except\n * that the resulting image does not include the input content.\n * This allows the shadow and input to be composed by a filter DAG in a more flexible manner.\n * @param dx The X offset of the shadow.\n * @param dy\tThe Y offset of the shadow.\n * @param sigmaX\tThe blur radius for the shadow, along the X axis.\n * @param sigmaY\tThe blur radius for the shadow, along the Y axis.\n * @param color\tThe color of the drop shadow.\n * @param input\tThe input filter, or will use the source bitmap if this is null.\n * @param cropRect\tOptional rectangle that crops the input and output.\n */\n MakeDropShadowOnly: (\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ) => SkImageFilter;\n /**\n * Create a filter that erodes each input pixel's channel values to the minimum channel value\n * within the given radii along the x and y axes.\n * @param radiusX The distance to erode along the x axis to either side of each pixel.\n * @param radiusY The distance to erode along the y axis to either side of each pixel.\n * @param input The image filter that is eroded, using source bitmap if this is null.\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakeErode: (\n rx: number,\n ry: number,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ) => SkImageFilter;\n /**\n * Create a filter that dilates each input pixel's channel values to the max value within the\n * given radii along the x and y axes.\n * @param radiusX The distance to dilate along the x axis to either side of each pixel.\n * @param radiusY The distance to dilate along the y axis to either side of each pixel.\n * @param input The image filter that is dilated, using source bitmap if this is null.\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakeDilate: (\n rx: number,\n ry: number,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ) => SkImageFilter;\n /**\n * This filter takes an SkBlendMode and uses it to composite the two filters together.\n * @param mode The blend mode that defines the compositing operation\n * @param background The Dst pixels used in blending, if null the source bitmap is used.\n * @param foreground The Src pixels used in blending, if null the source bitmap is used.\n * @param cropRect Optional rectangle to crop input and output.\n */\n MakeBlend: (\n mode: BlendMode,\n background: SkImageFilter,\n foreground?: SkImageFilter | null,\n cropRect?: SkRect | null\n ) => SkImageFilter;\n /**\n * Create a filter that fills the output with the per-pixel evaluation of the SkShader produced\n * by the SkRuntimeShaderBuilder. The shader is defined in the image filter's local coordinate\n * system, so it will automatically be affected by SkCanvas' transform.\n *\n * @param builder The builder used to produce the runtime shader, that will in turn\n * fill the result image\n * @param childShaderName The name of the child shader defined in the builder that will be\n * bound to the input param (or the source image if the input param\n * is null). If null the builder can have exactly one child shader,\n * which automatically binds the input param.\n * @param input The image filter that will be provided as input to the runtime\n * shader. If null the implicit source image is used instead\n */\n MakeRuntimeShader: (\n builder: SkRuntimeShaderBuilder,\n childShaderName: string | null,\n input?: SkImageFilter | null\n ) => SkImageFilter;\n\n /**\n * Create a filter that implements a custom blend mode. Each output pixel is the result of\n * combining the corresponding background and foreground pixels using the 4 coefficients:\n * k1 * foreground * background + k2 * foreground + k3 * background + k4\n *\n * @param k1, k2, k3, k4 The four coefficients used to combine the foreground and background.\n * @param enforcePMColor If true, the RGB channels will be clamped to the calculated alpha.\n * @param background The background content, using the source bitmap when this is null.\n * @param foreground The foreground content, using the source bitmap when this is null.\n * @param cropRect Optional rectangle that crops the inputs and output.\n */\n MakeArithmetic(\n k1: number,\n k2: number,\n k3: number,\n k4: number,\n enforcePMColor: boolean,\n background?: SkImageFilter | null,\n foreground?: SkImageFilter | null,\n cropRect?: SkRect | null\n ): SkImageFilter;\n\n /**\n * Create a filter that applies a crop to the result of the 'input' filter. Pixels within the\n * crop rectangle are unmodified from what 'input' produced. Pixels outside of crop match the\n * provided SkTileMode (defaulting to kDecal).\n *\n * NOTE: The optional CropRect argument for many of the factories is equivalent to creating the\n * filter without a CropRect and then wrapping it in ::Crop(rect, kDecal). Explicitly adding\n * Crop filters lets you control their tiling and use different geometry for the input and the\n * output of another filter.\n *\n * @param rect The cropping rect\n * @param tileMode The TileMode applied to pixels *outside* of 'crop' @default TileMode.Decal\n * @param input The input filter that is cropped, uses source image if this is null\n */\n MakeCrop(\n rect: SkRect,\n tileMode?: TileMode | null,\n input?: SkImageFilter | null\n ): SkImageFilter;\n\n /**\n * Create a filter that always produces transparent black.\n */\n MakeEmpty(): SkImageFilter;\n\n /**\n * Create a filter that draws the 'srcRect' portion of image into 'dstRect' using the given\n * filter quality. Similar to SkCanvas::drawImageRect. The returned image filter evaluates\n * to transparent black if 'image' is null.\n *\n * @param image The image that is output by the filter, subset by 'srcRect'.\n * @param srcRect The source pixels sampled into 'dstRect', if null the image bounds are used.\n * @param dstRect The local rectangle to draw the image into, if null the srcRect is used.\n * @param filterMode The filter mode to use when sampling the image @default FilterMode.Nearest\n * @param mipmap The mipmap mode to use when sampling the image @default MipmapMode.None\n */\n MakeImage(\n image: SkImage,\n srcRect?: SkRect | null,\n dstRect?: SkRect | null,\n filterMode?: FilterMode,\n mipmap?: MipmapMode\n ): SkImageFilter;\n\n /**\n * Create a filter that fills 'lensBounds' with a magnification of the input.\n *\n * @param lensBounds The outer bounds of the magnifier effect\n * @param zoomAmount The amount of magnification applied to the input image\n * @param inset The size or width of the fish-eye distortion around the magnified content\n * @param filterMode The filter mode to use when sampling the image @default FilterMode.Nearest\n * @param mipmap The mipmap mode to use when sampling the image @default MipmapMode.None\n * @param input The input filter that is magnified; if null the source bitmap is used\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakeMagnifier(\n lensBounds: SkRect,\n zoomAmount: number,\n inset: number,\n filterMode?: FilterMode,\n mipmap?: MipmapMode,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ): SkImageFilter;\n\n /**\n * Create a filter that applies an NxM image processing kernel to the input image. This can be\n * used to produce effects such as sharpening, blurring, edge detection, etc.\n * @param kernelSizeX The width of the kernel. Must be greater than zero.\n * @param kernelSizeY The height of the kernel. Must be greater than zero.\n * @param kernel The image processing kernel. Must contain kernelSizeX * kernelSizeY elements, in row order.\n * @param gain A scale factor applied to each pixel after convolution. This can be\n * used to normalize the kernel, if it does not already sum to 1.\n * @param bias A bias factor added to each pixel after convolution.\n * @param kernelOffsetX An offset applied to each pixel coordinate before convolution.\n * This can be used to center the kernel over the image\n * (e.g., a 3x3 kernel should have an offset of {1, 1}).\n * @param kernelOffsetY An offset applied to each pixel coordinate before convolution.\n * This can be used to center the kernel over the image\n * (e.g., a 3x3 kernel should have an offset of {1, 1}).\n * @param tileMode How accesses outside the image are treated. TileMode.Mirror is not supported.\n * @param convolveAlpha If true, all channels are convolved. If false, only the RGB channels\n * are convolved, and alpha is copied from the source image.\n * @param input The input image filter, if null the source bitmap is used instead.\n * @param cropRect Optional rectangle to which the output processing will be limited.\n */\n MakeMatrixConvolution(\n kernelSizeX: number,\n kernelSizeY: number,\n kernel: number[],\n gain: number,\n bias: number,\n kernelOffsetX: number,\n kernelOffsetY: number,\n tileMode: TileMode,\n convolveAlpha: boolean,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ): SkImageFilter;\n\n /**\n * Create a filter that transforms the input image by 'matrix'. This matrix transforms the\n * local space, which means it effectively happens prior to any transformation coming from the\n * SkCanvas initiating the filtering.\n * @param matrix The matrix to apply to the original content.\n * @param filterMode The filter mode to use when sampling the image @default FilterMode.Nearest\n * @param mipmap The mipmap mode to use when sampling the image @default MipmapMode.None\n * @param input The image filter to transform, or null to use the source image.\n */\n MakeMatrixTransform(\n matrix: SkMatrix,\n filterMode?: FilterMode,\n mipmap?: MipmapMode,\n input?: SkImageFilter | null\n ): SkImageFilter;\n\n /**\n * Create a filter that merges filters together by drawing their results in order\n * with src-over blending.\n * @param filters The input filter array to merge. Any null\n * filter pointers will use the source bitmap instead.\n * @param cropRect Optional rectangle that crops all input filters and the output.\n */\n MakeMerge(\n filters: Array<SkImageFilter | null>,\n cropRect?: SkRect | null\n ): SkImageFilter;\n\n /**\n * Create a filter that produces the SkPicture as its output, clipped to both 'targetRect' and\n * the picture's internal cull rect.\n *\n * If 'pic' is null, the returned image filter produces transparent black.\n *\n * @param picture The picture that is drawn for the filter output.\n * @param targetRect The drawing region for the picture. If null, the picture's bounds are used.\n */\n MakePicture(picture: SkPicture, targetRect?: SkRect | null): SkImageFilter;\n\n /**\n * Create a filter that fills the output with the per-pixel evaluation of the SkShader produced\n * by the SkRuntimeEffectBuilder. The shader is defined in the image filter's local coordinate\n * system, so it will automatically be affected by SkCanvas' transform.\n *\n * This requires a GPU backend or SkSL to be compiled in.\n *\n * @param builder The builder used to produce the runtime shader, that will in turn\n * fill the result image\n * @param sampleRadius defines the sampling radius of 'childShaderName' relative to\n * the runtime shader produced by 'builder'.\n * If greater than 0, the coordinate passed to childShader.eval() will\n * be up to 'sampleRadius' away (maximum absolute offset in 'x' or 'y')\n * from the coordinate passed into the runtime shader.\n * @param childShaderNames The names of the child shaders defined in the builder that will be\n * bound to the input params (or the source image if the input param\n * is null). If any name is null, or appears more than once, factory\n * fails and returns nullptr.\n * @param inputs The image filters that will be provided as input to the runtime\n * shader. If any are null, the implicit source image is used instead.\n */\n MakeRuntimeShaderWithChildren: (\n builder: SkRuntimeShaderBuilder,\n sampleRadius: number,\n childShaderNames: string[],\n inputs: Array<SkImageFilter | null>\n ) => SkImageFilter;\n\n /**\n * Create a tile image filter.\n * @param src Defines the pixels to tile\n * @param dst Defines the pixel region that the tiles will be drawn to\n * @param input The input that will be tiled, if null the source bitmap is used instead.\n */\n MakeTile(\n src: SkRect,\n dst: SkRect,\n input?: SkImageFilter | null\n ): SkImageFilter;\n\n /**\n * Create a filter that calculates the diffuse illumination from a distant light source,\n * interpreting the alpha channel of the input as the height profile of the surface (to\n * approximate normal vectors).\n * @param direction The direction to the distance light.\n * @param lightColor The color of the diffuse light source.\n * @param surfaceScale Scale factor to transform from alpha values to physical height.\n * @param kd Diffuse reflectance coefficient.\n * @param input The input filter that defines surface normals (as alpha), or uses the\n * source bitmap when null.\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakeDistantLitDiffuse(\n direction: SkPoint3,\n lightColor: SkColor,\n surfaceScale: number,\n kd: number,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ): SkImageFilter;\n\n /**\n * Create a filter that calculates the diffuse illumination from a point light source, using\n * alpha channel of the input as the height profile of the surface (to approximate normal\n * vectors).\n * @param location The location of the point light.\n * @param lightColor The color of the diffuse light source.\n * @param surfaceScale Scale factor to transform from alpha values to physical height.\n * @param kd Diffuse reflectance coefficient.\n * @param input The input filter that defines surface normals (as alpha), or uses the\n * source bitmap when null.\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakePointLitDiffuse(\n location: SkPoint3,\n lightColor: SkColor,\n surfaceScale: number,\n kd: number,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ): SkImageFilter;\n\n /**\n * Create a filter that calculates the diffuse illumination from a spot light source, using\n * alpha channel of the input as the height profile of the surface (to approximate normal\n * vectors). The spot light is restricted to be within 'cutoffAngle' of the vector between\n * the location and target.\n * @param location The location of the spot light.\n * @param target The location that the spot light is point towards\n * @param falloffExponent Exponential falloff parameter for illumination outside of cutoffAngle\n * @param cutoffAngle Maximum angle from lighting direction that receives full light\n * @param lightColor The color of the diffuse light source.\n * @param surfaceScale Scale factor to transform from alpha values to physical height.\n * @param kd Diffuse reflectance coefficient.\n * @param input The input filter that defines surface normals (as alpha), or uses the\n * source bitmap when null.\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakeSpotLitDiffuse(\n location: SkPoint3,\n target: SkPoint3,\n falloffExponent: number,\n cutoffAngle: number,\n lightColor: SkColor,\n surfaceScale: number,\n kd: number,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ): SkImageFilter;\n\n /**\n * Create a filter that calculates the specular illumination from a distant light source,\n * interpreting the alpha channel of the input as the height profile of the surface (to\n * approximate normal vectors).\n * @param direction The direction to the distance light.\n * @param lightColor The color of the specular light source.\n * @param surfaceScale Scale factor to transform from alpha values to physical height.\n * @param ks Specular reflectance coefficient.\n * @param shininess The specular exponent determining how shiny the surface is.\n * @param input The input filter that defines surface normals (as alpha), or uses the\n * source bitmap when null.\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakeDistantLitSpecular(\n direction: SkPoint3,\n lightColor: SkColor,\n surfaceScale: number,\n ks: number,\n shininess: number,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ): SkImageFilter;\n\n /**\n * Create a filter that calculates the specular illumination from a point light source, using\n * alpha channel of the input as the height profile of the surface (to approximate normal\n * vectors).\n * @param location The location of the point light.\n * @param lightColor The color of the specular light source.\n * @param surfaceScale Scale factor to transform from alpha values to physical height.\n * @param ks Specular reflectance coefficient.\n * @param shininess The specular exponent determining how shiny the surface is.\n * @param input The input filter that defines surface normals (as alpha), or uses the\n * source bitmap when null.\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakePointLitSpecular(\n location: SkPoint3,\n lightColor: SkColor,\n surfaceScale: number,\n ks: number,\n shininess: number,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ): SkImageFilter;\n\n /**\n * Create a filter that calculates the specular illumination from a spot light source, using\n * alpha channel of the input as the height profile of the surface (to approximate normal\n * vectors). The spot light is restricted to be within 'cutoffAngle' of the vector between\n * the location and target.\n * @param location The location of the spot light.\n * @param target The location that the spot light is point towards\n * @param falloffExponent Exponential falloff parameter for illumination outside of cutoffAngle\n * @param cutoffAngle Maximum angle from lighting direction that receives full light\n * @param lightColor The color of the specular light source.\n * @param surfaceScale Scale factor to transform from alpha values to physical height.\n * @param ks Specular reflectance coefficient.\n * @param shininess The specular exponent determining how shiny the surface is.\n * @param input The input filter that defines surface normals (as alpha), or uses the\n * source bitmap when null.\n * @param cropRect Optional rectangle that crops the input and output.\n */\n MakeSpotLitSpecular(\n location: SkPoint3,\n target: SkPoint3,\n falloffExponent: number,\n cutoffAngle: number,\n lightColor: SkColor,\n surfaceScale: number,\n ks: number,\n shininess: number,\n input?: SkImageFilter | null,\n cropRect?: SkRect | null\n ): SkImageFilter;\n}\n\nexport type SkPoint3 = {\n x: number;\n y: number;\n z: number;\n};\n"],"mappings":";;;;;;IAYYA,YAAY,GAAAC,OAAA,CAAAD,YAAA,0BAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA","ignoreList":[]}
@@ -3,8 +3,8 @@ type Point = {
3
3
  y: number;
4
4
  };
5
5
  type Vec2 = readonly [number, number];
6
- type Vec3 = readonly [number, number, number];
7
- type Vec4 = readonly [number, number, number, number];
6
+ export type Vec3 = readonly [number, number, number];
7
+ export type Vec4 = readonly [number, number, number, number];
8
8
  export type Matrix3 = readonly [
9
9
  number,
10
10
  number,
@@ -106,4 +106,13 @@ export declare const convertToAffineMatrix: (m4: Matrix4) => number[];
106
106
  * @returns The inverted matrix, or the identity matrix if the input is not invertible
107
107
  */
108
108
  export declare const invert4: (m: Matrix4) => Matrix4;
109
+ export interface CameraConfig {
110
+ eye: Vec3;
111
+ coa: Vec3;
112
+ up: Vec3;
113
+ near: number;
114
+ far: number;
115
+ angle: number;
116
+ }
117
+ export declare const setupCamera: (area: Vec4, zscale: number, cam: CameraConfig) => Matrix4;
109
118
  export {};
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.translate = exports.toMatrix3 = exports.scale = exports.rotateZ = exports.rotateY = exports.rotateX = exports.processTransform3d = exports.pivot = exports.perspective = exports.multiply4 = exports.matrixVecMul4 = exports.mapPoint3d = exports.invert4 = exports.convertToColumnMajor = exports.convertToAffineMatrix = exports.Matrix4 = void 0;
6
+ exports.translate = exports.toMatrix3 = exports.setupCamera = exports.scale = exports.rotateZ = exports.rotateY = exports.rotateX = exports.processTransform3d = exports.pivot = exports.perspective = exports.multiply4 = exports.matrixVecMul4 = exports.mapPoint3d = exports.invert4 = exports.convertToColumnMajor = exports.convertToAffineMatrix = exports.Matrix4 = void 0;
7
7
  const exhaustiveCheck = a => {
8
8
  "worklet";
9
9
 
@@ -360,4 +360,45 @@ const invert4 = m => {
360
360
  return [b00 * invDet, b10 * invDet, b20 * invDet, b30 * invDet, b01 * invDet, b11 * invDet, b21 * invDet, b31 * invDet, b02 * invDet, b12 * invDet, b22 * invDet, b32 * invDet, b03 * invDet, b13 * invDet, b23 * invDet, b33 * invDet];
361
361
  };
362
362
  exports.invert4 = invert4;
363
+ const vecSub = (a, b) => {
364
+ "worklet";
365
+
366
+ return [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
367
+ };
368
+ const vecCross = (a, b) => {
369
+ "worklet";
370
+
371
+ return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
372
+ };
373
+ const lookat = (eyeVec, centerVec, upVec) => {
374
+ "worklet";
375
+
376
+ const f = normalizeVec(vecSub(centerVec, eyeVec));
377
+ const u = normalizeVec(upVec);
378
+ const s = normalizeVec(vecCross(f, u));
379
+ const uf = vecCross(s, f);
380
+
381
+ // Build the look-at matrix directly
382
+ const m = [s[0], uf[0], -f[0], eyeVec[0], s[1], uf[1], -f[1], eyeVec[1], s[2], uf[2], -f[2], eyeVec[2], 0, 0, 0, 1];
383
+ return invert4(m);
384
+ };
385
+ const perspectiveMatrix = (near, far, angle) => {
386
+ "worklet";
387
+
388
+ const dInv = 1 / (far - near);
389
+ const halfAngle = angle / 2;
390
+ const cot = Math.cos(halfAngle) / Math.sin(halfAngle);
391
+ return [cot, 0, 0, 0, 0, cot, 0, 0, 0, 0, (far + near) * dInv, 2 * far * near * dInv, 0, 0, -1, 1];
392
+ };
393
+ const setupCamera = (area, zscale, cam) => {
394
+ "worklet";
395
+
396
+ const camera = lookat(cam.eye, cam.coa, cam.up);
397
+ const p = perspectiveMatrix(cam.near, cam.far, cam.angle);
398
+ const center = [(area[0] + area[2]) / 2, (area[1] + area[3]) / 2, 0];
399
+ const viewScale = [(area[2] - area[0]) / 2, (area[3] - area[1]) / 2, zscale];
400
+ const viewport = multiply4(translate(center[0], center[1], center[2]), scale(viewScale[0], viewScale[1], viewScale[2]));
401
+ return multiply4(multiply4(viewport, p), multiply4(camera, invert4(viewport)));
402
+ };
403
+ exports.setupCamera = setupCamera;
363
404
  //# sourceMappingURL=Matrix4.js.map