@shopify/react-native-skia 0.1.124 → 0.1.127

Sign up to get free protection for your applications and to get access to all the features.
Files changed (388) hide show
  1. package/android/CMakeLists.txt +3 -0
  2. package/android/build.gradle +1 -1
  3. package/cpp/api/JsiSkApi.h +3 -1
  4. package/cpp/api/JsiSkCanvas.h +1 -1
  5. package/cpp/api/JsiSkColor.h +41 -7
  6. package/cpp/api/JsiSkColorFilterFactory.h +2 -1
  7. package/cpp/api/JsiSkImageFilter.h +0 -2
  8. package/cpp/api/JsiSkImageFilterFactory.h +37 -17
  9. package/cpp/api/JsiSkMatrix.h +44 -2
  10. package/cpp/api/JsiSkPaint.h +4 -7
  11. package/cpp/api/JsiSkRuntimeEffect.h +7 -0
  12. package/cpp/api/JsiSkRuntimeEffectFactory.h +3 -2
  13. package/cpp/api/JsiSkRuntimeShaderBuilder.h +70 -0
  14. package/cpp/api/JsiSkShaderFactory.h +2 -2
  15. package/cpp/api/JsiSkVertices.h +1 -1
  16. package/cpp/api/third_party/CSSColorParser.cpp +194 -0
  17. package/cpp/api/third_party/CSSColorParser.h +1 -191
  18. package/cpp/jsi/JsiSimpleValueWrapper.h +108 -0
  19. package/cpp/rnskia/values/RNSkReadonlyValue.h +13 -12
  20. package/ios/RNSkia-iOS/PlatformContext.h +30 -4
  21. package/ios/RNSkia-iOS/SkiaDrawView.mm +9 -12
  22. package/lib/commonjs/{values/animation → animation}/decay/decay.js +0 -0
  23. package/lib/commonjs/{values/animation → animation}/decay/decay.js.map +0 -0
  24. package/lib/commonjs/{values/animation → animation}/decay/index.js +0 -0
  25. package/lib/commonjs/{values/animation → animation}/decay/index.js.map +0 -0
  26. package/lib/commonjs/{values/animation → animation}/decay/runDecay.js +1 -1
  27. package/lib/commonjs/animation/decay/runDecay.js.map +1 -0
  28. package/lib/commonjs/{values/animation → animation}/decay/types.js +0 -0
  29. package/lib/commonjs/{values/animation → animation}/decay/types.js.map +0 -0
  30. package/lib/commonjs/{values/animation → animation}/functions/index.js +0 -0
  31. package/lib/commonjs/{values/animation → animation}/functions/index.js.map +0 -0
  32. package/lib/commonjs/animation/functions/interpolate.js +141 -0
  33. package/lib/commonjs/animation/functions/interpolate.js.map +1 -0
  34. package/lib/commonjs/animation/functions/interpolateColors.js +39 -0
  35. package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -0
  36. package/lib/commonjs/{values/animation → animation}/index.js +0 -0
  37. package/lib/commonjs/{values/animation → animation}/index.js.map +0 -0
  38. package/lib/commonjs/{values/animation → animation}/spring/Spring.js +0 -0
  39. package/lib/commonjs/{values/animation → animation}/spring/Spring.js.map +0 -0
  40. package/lib/commonjs/{values/animation → animation}/spring/functions/index.js +0 -0
  41. package/lib/commonjs/{values/animation → animation}/spring/functions/index.js.map +0 -0
  42. package/lib/commonjs/{values/animation → animation}/spring/functions/spring.js +0 -0
  43. package/lib/commonjs/{values/animation → animation}/spring/functions/spring.js.map +0 -0
  44. package/lib/commonjs/{values/animation → animation}/spring/index.js +0 -0
  45. package/lib/commonjs/{values/animation → animation}/spring/index.js.map +0 -0
  46. package/lib/commonjs/{values/animation → animation}/spring/runSpring.js +0 -0
  47. package/lib/commonjs/animation/spring/runSpring.js.map +1 -0
  48. package/lib/commonjs/{values/animation → animation}/spring/types.js +0 -0
  49. package/lib/commonjs/{values/animation → animation}/spring/types.js.map +0 -0
  50. package/lib/commonjs/{values/animation → animation}/spring/useSpring.js +0 -0
  51. package/lib/commonjs/animation/spring/useSpring.js.map +1 -0
  52. package/lib/commonjs/{values/animation → animation}/timing/Easing.js +0 -0
  53. package/lib/commonjs/{values/animation → animation}/timing/Easing.js.map +0 -0
  54. package/lib/commonjs/{values/animation → animation}/timing/createTiming.js +1 -1
  55. package/lib/commonjs/animation/timing/createTiming.js.map +1 -0
  56. package/lib/commonjs/{values/animation → animation}/timing/functions/bezier.js +0 -0
  57. package/lib/commonjs/{values/animation → animation}/timing/functions/bezier.js.map +0 -0
  58. package/lib/commonjs/{values/animation → animation}/timing/functions/getResolvedParams.js +0 -0
  59. package/lib/commonjs/{values/animation → animation}/timing/functions/getResolvedParams.js.map +0 -0
  60. package/lib/commonjs/{values/animation → animation}/timing/functions/index.js +0 -0
  61. package/lib/commonjs/{values/animation → animation}/timing/functions/index.js.map +0 -0
  62. package/lib/commonjs/{values/animation → animation}/timing/functions/timing.js +0 -0
  63. package/lib/commonjs/{values/animation → animation}/timing/functions/timing.js.map +1 -1
  64. package/lib/commonjs/{values/animation → animation}/timing/functions/types.js +0 -0
  65. package/lib/commonjs/{values/animation → animation}/timing/functions/types.js.map +0 -0
  66. package/lib/commonjs/{values/animation → animation}/timing/index.js +0 -0
  67. package/lib/commonjs/{values/animation → animation}/timing/index.js.map +0 -0
  68. package/lib/commonjs/{values/animation → animation}/timing/runTiming.js +0 -0
  69. package/lib/commonjs/animation/timing/runTiming.js.map +1 -0
  70. package/lib/commonjs/{values/animation → animation}/timing/useLoop.js +0 -0
  71. package/lib/commonjs/{values/animation → animation}/timing/useLoop.js.map +0 -0
  72. package/lib/commonjs/{values/animation → animation}/timing/useTiming.js +1 -1
  73. package/lib/commonjs/animation/timing/useTiming.js.map +1 -0
  74. package/lib/commonjs/{values/animation → animation}/types.js +0 -0
  75. package/lib/commonjs/{values/animation → animation}/types.js.map +0 -0
  76. package/lib/commonjs/index.js +13 -0
  77. package/lib/commonjs/index.js.map +1 -1
  78. package/lib/commonjs/renderer/components/colorFilters/BlendColor.js.map +1 -1
  79. package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js +4 -2
  80. package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js.map +1 -1
  81. package/lib/commonjs/renderer/components/imageFilters/RuntimeShader.js +37 -0
  82. package/lib/commonjs/renderer/components/imageFilters/RuntimeShader.js.map +1 -0
  83. package/lib/commonjs/renderer/components/imageFilters/index.js +13 -0
  84. package/lib/commonjs/renderer/components/imageFilters/index.js.map +1 -1
  85. package/lib/commonjs/renderer/components/shaders/Gradient.js +1 -1
  86. package/lib/commonjs/renderer/components/shaders/Gradient.js.map +1 -1
  87. package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
  88. package/lib/commonjs/renderer/processors/Rects.js +5 -15
  89. package/lib/commonjs/renderer/processors/Rects.js.map +1 -1
  90. package/lib/commonjs/renderer/processors/math/Matrix3.js +42 -63
  91. package/lib/commonjs/renderer/processors/math/Matrix3.js.map +1 -1
  92. package/lib/commonjs/renderer/processors/math/Vector.js +4 -5
  93. package/lib/commonjs/renderer/processors/math/Vector.js.map +1 -1
  94. package/lib/commonjs/skia/Color.js +14 -38
  95. package/lib/commonjs/skia/Color.js.map +1 -1
  96. package/lib/commonjs/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
  97. package/lib/commonjs/skia/Matrix.js.map +1 -1
  98. package/lib/commonjs/skia/Shader/useShader.js +4 -1
  99. package/lib/commonjs/skia/Shader/useShader.js.map +1 -1
  100. package/lib/commonjs/skia/Skia.js +3 -45
  101. package/lib/commonjs/skia/Skia.js.map +1 -1
  102. package/lib/commonjs/skia/SkiaApi.js +4 -0
  103. package/lib/commonjs/skia/SkiaApi.js.map +1 -0
  104. package/lib/commonjs/values/api.js +4 -6
  105. package/lib/commonjs/values/api.js.map +1 -1
  106. package/lib/commonjs/values/api.web.js +18 -0
  107. package/lib/commonjs/values/api.web.js.map +1 -0
  108. package/lib/commonjs/values/index.js +0 -13
  109. package/lib/commonjs/values/index.js.map +1 -1
  110. package/lib/commonjs/values/web/RNSkAnimation.js +46 -0
  111. package/lib/commonjs/values/web/RNSkAnimation.js.map +1 -0
  112. package/lib/commonjs/values/web/RNSkClockValue.js +75 -0
  113. package/lib/commonjs/values/web/RNSkClockValue.js.map +1 -0
  114. package/lib/commonjs/values/web/RNSkDerivedValue.js +51 -0
  115. package/lib/commonjs/values/web/RNSkDerivedValue.js.map +1 -0
  116. package/lib/commonjs/values/web/RNSkReadonlyValue.js +45 -0
  117. package/lib/commonjs/values/web/RNSkReadonlyValue.js.map +1 -0
  118. package/lib/commonjs/values/web/RNSkValue.js +73 -0
  119. package/lib/commonjs/values/web/RNSkValue.js.map +1 -0
  120. package/lib/commonjs/values/web/api.js +31 -0
  121. package/lib/commonjs/values/web/api.js.map +1 -0
  122. package/lib/commonjs/values/web/index.js +19 -0
  123. package/lib/commonjs/values/web/index.js.map +1 -0
  124. package/lib/commonjs/views/SkiaView.js +13 -10
  125. package/lib/commonjs/views/SkiaView.js.map +1 -1
  126. package/lib/commonjs/views/api.js +11 -0
  127. package/lib/commonjs/views/api.js.map +1 -0
  128. package/lib/commonjs/views/types.js.map +1 -1
  129. package/lib/module/{values/animation → animation}/decay/decay.js +0 -0
  130. package/lib/module/{values/animation → animation}/decay/decay.js.map +0 -0
  131. package/lib/module/{values/animation → animation}/decay/index.js +0 -0
  132. package/lib/module/{values/animation → animation}/decay/index.js.map +0 -0
  133. package/lib/module/{values/animation → animation}/decay/runDecay.js +1 -1
  134. package/lib/module/animation/decay/runDecay.js.map +1 -0
  135. package/lib/module/{values/animation → animation}/decay/types.js +0 -0
  136. package/lib/module/{values/animation → animation}/decay/types.js.map +0 -0
  137. package/lib/module/{values/animation → animation}/functions/index.js +0 -0
  138. package/lib/module/{values/animation → animation}/functions/index.js.map +0 -0
  139. package/lib/module/animation/functions/interpolate.js +132 -0
  140. package/lib/module/animation/functions/interpolate.js.map +1 -0
  141. package/lib/module/animation/functions/interpolateColors.js +23 -0
  142. package/lib/module/animation/functions/interpolateColors.js.map +1 -0
  143. package/lib/module/{values/animation → animation}/index.js +0 -0
  144. package/lib/module/{values/animation → animation}/index.js.map +0 -0
  145. package/lib/module/{values/animation → animation}/spring/Spring.js +0 -0
  146. package/lib/module/{values/animation → animation}/spring/Spring.js.map +0 -0
  147. package/lib/module/{values/animation → animation}/spring/functions/index.js +0 -0
  148. package/lib/module/{values/animation → animation}/spring/functions/index.js.map +0 -0
  149. package/lib/module/{values/animation → animation}/spring/functions/spring.js +0 -0
  150. package/lib/module/{values/animation → animation}/spring/functions/spring.js.map +0 -0
  151. package/lib/module/{values/animation → animation}/spring/index.js +0 -0
  152. package/lib/module/{values/animation → animation}/spring/index.js.map +0 -0
  153. package/lib/module/{values/animation → animation}/spring/runSpring.js +0 -0
  154. package/lib/module/animation/spring/runSpring.js.map +1 -0
  155. package/lib/module/{values/animation → animation}/spring/types.js +0 -0
  156. package/lib/module/{values/animation → animation}/spring/types.js.map +0 -0
  157. package/lib/module/{values/animation → animation}/spring/useSpring.js +0 -0
  158. package/lib/module/animation/spring/useSpring.js.map +1 -0
  159. package/lib/module/{values/animation → animation}/timing/Easing.js +0 -0
  160. package/lib/module/{values/animation → animation}/timing/Easing.js.map +0 -0
  161. package/lib/module/{values/animation → animation}/timing/createTiming.js +1 -1
  162. package/lib/module/animation/timing/createTiming.js.map +1 -0
  163. package/lib/module/{values/animation → animation}/timing/functions/bezier.js +0 -0
  164. package/lib/module/{values/animation → animation}/timing/functions/bezier.js.map +0 -0
  165. package/lib/module/{values/animation → animation}/timing/functions/getResolvedParams.js +0 -0
  166. package/lib/module/{values/animation → animation}/timing/functions/getResolvedParams.js.map +0 -0
  167. package/lib/module/{values/animation → animation}/timing/functions/index.js +0 -0
  168. package/lib/module/{values/animation → animation}/timing/functions/index.js.map +0 -0
  169. package/lib/module/{values/animation → animation}/timing/functions/timing.js +0 -0
  170. package/lib/module/{values/animation → animation}/timing/functions/timing.js.map +1 -1
  171. package/lib/module/{values/animation → animation}/timing/functions/types.js +0 -0
  172. package/lib/module/{values/animation → animation}/timing/functions/types.js.map +0 -0
  173. package/lib/module/{values/animation → animation}/timing/index.js +0 -0
  174. package/lib/module/{values/animation → animation}/timing/index.js.map +0 -0
  175. package/lib/module/{values/animation → animation}/timing/runTiming.js +0 -0
  176. package/lib/module/animation/timing/runTiming.js.map +1 -0
  177. package/lib/module/{values/animation → animation}/timing/useLoop.js +0 -0
  178. package/lib/module/{values/animation → animation}/timing/useLoop.js.map +0 -0
  179. package/lib/module/{values/animation → animation}/timing/useTiming.js +1 -1
  180. package/lib/module/animation/timing/useTiming.js.map +1 -0
  181. package/lib/module/{values/animation → animation}/types.js +0 -0
  182. package/lib/module/{values/animation → animation}/types.js.map +0 -0
  183. package/lib/module/index.js +1 -0
  184. package/lib/module/index.js.map +1 -1
  185. package/lib/module/renderer/components/colorFilters/BlendColor.js.map +1 -1
  186. package/lib/module/renderer/components/imageFilters/InnerShadow.js +3 -2
  187. package/lib/module/renderer/components/imageFilters/InnerShadow.js.map +1 -1
  188. package/lib/module/renderer/components/imageFilters/RuntimeShader.js +19 -0
  189. package/lib/module/renderer/components/imageFilters/RuntimeShader.js.map +1 -0
  190. package/lib/module/renderer/components/imageFilters/index.js +1 -0
  191. package/lib/module/renderer/components/imageFilters/index.js.map +1 -1
  192. package/lib/module/renderer/components/shaders/Gradient.js +2 -2
  193. package/lib/module/renderer/components/shaders/Gradient.js.map +1 -1
  194. package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
  195. package/lib/module/renderer/processors/Rects.js +4 -15
  196. package/lib/module/renderer/processors/Rects.js.map +1 -1
  197. package/lib/module/renderer/processors/math/Matrix3.js +52 -72
  198. package/lib/module/renderer/processors/math/Matrix3.js.map +1 -1
  199. package/lib/module/renderer/processors/math/Vector.js +3 -5
  200. package/lib/module/renderer/processors/math/Vector.js.map +1 -1
  201. package/lib/module/skia/Color.js +9 -25
  202. package/lib/module/skia/Color.js.map +1 -1
  203. package/lib/module/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
  204. package/lib/module/skia/Matrix.js.map +1 -1
  205. package/lib/module/skia/Shader/useShader.js +4 -1
  206. package/lib/module/skia/Shader/useShader.js.map +1 -1
  207. package/lib/module/skia/Skia.js +2 -46
  208. package/lib/module/skia/Skia.js.map +1 -1
  209. package/lib/module/skia/SkiaApi.js +2 -0
  210. package/lib/module/skia/SkiaApi.js.map +1 -0
  211. package/lib/module/values/api.js +4 -6
  212. package/lib/module/values/api.js.map +1 -1
  213. package/lib/module/values/api.web.js +7 -0
  214. package/lib/module/values/api.web.js.map +1 -0
  215. package/lib/module/values/index.js +0 -1
  216. package/lib/module/values/index.js.map +1 -1
  217. package/lib/module/values/web/RNSkAnimation.js +36 -0
  218. package/lib/module/values/web/RNSkAnimation.js.map +1 -0
  219. package/lib/module/values/web/RNSkClockValue.js +65 -0
  220. package/lib/module/values/web/RNSkClockValue.js.map +1 -0
  221. package/lib/module/values/web/RNSkDerivedValue.js +41 -0
  222. package/lib/module/values/web/RNSkDerivedValue.js.map +1 -0
  223. package/lib/module/values/web/RNSkReadonlyValue.js +36 -0
  224. package/lib/module/values/web/RNSkReadonlyValue.js.map +1 -0
  225. package/lib/module/values/web/RNSkValue.js +63 -0
  226. package/lib/module/values/web/RNSkValue.js.map +1 -0
  227. package/lib/module/values/web/api.js +19 -0
  228. package/lib/module/values/web/api.js.map +1 -0
  229. package/lib/module/values/web/index.js +2 -0
  230. package/lib/module/values/web/index.js.map +1 -0
  231. package/lib/module/views/SkiaView.js +1 -3
  232. package/lib/module/views/SkiaView.js.map +1 -1
  233. package/lib/module/views/api.js +4 -0
  234. package/lib/module/views/api.js.map +1 -0
  235. package/lib/module/views/types.js.map +1 -1
  236. package/lib/typescript/src/{values/animation → animation}/decay/decay.d.ts +0 -0
  237. package/lib/typescript/src/{values/animation → animation}/decay/index.d.ts +0 -0
  238. package/lib/typescript/src/{values/animation → animation}/decay/runDecay.d.ts +2 -2
  239. package/lib/typescript/src/{values/animation → animation}/decay/types.d.ts +1 -1
  240. package/lib/typescript/src/{values/animation → animation}/functions/index.d.ts +0 -0
  241. package/lib/typescript/src/animation/functions/interpolate.d.ts +11 -0
  242. package/lib/typescript/src/animation/functions/interpolateColors.d.ts +3 -0
  243. package/lib/typescript/src/{values/animation → animation}/index.d.ts +0 -0
  244. package/lib/typescript/src/{values/animation → animation}/spring/Spring.d.ts +0 -0
  245. package/lib/typescript/src/{values/animation → animation}/spring/functions/index.d.ts +0 -0
  246. package/lib/typescript/src/{values/animation → animation}/spring/functions/spring.d.ts +0 -0
  247. package/lib/typescript/src/{values/animation → animation}/spring/index.d.ts +0 -0
  248. package/lib/typescript/src/{values/animation → animation}/spring/runSpring.d.ts +1 -1
  249. package/lib/typescript/src/{values/animation → animation}/spring/types.d.ts +0 -0
  250. package/lib/typescript/src/{values/animation → animation}/spring/useSpring.d.ts +1 -1
  251. package/lib/typescript/src/{values/animation → animation}/timing/Easing.d.ts +0 -0
  252. package/lib/typescript/src/{values/animation → animation}/timing/createTiming.d.ts +2 -2
  253. package/lib/typescript/src/{values/animation → animation}/timing/functions/bezier.d.ts +0 -0
  254. package/lib/typescript/src/{values/animation → animation}/timing/functions/getResolvedParams.d.ts +0 -0
  255. package/lib/typescript/src/{values/animation → animation}/timing/functions/index.d.ts +0 -0
  256. package/lib/typescript/src/{values/animation → animation}/timing/functions/timing.d.ts +1 -1
  257. package/lib/typescript/src/{values/animation → animation}/timing/functions/types.d.ts +0 -0
  258. package/lib/typescript/src/{values/animation → animation}/timing/index.d.ts +0 -0
  259. package/lib/typescript/src/{values/animation → animation}/timing/runTiming.d.ts +1 -1
  260. package/lib/typescript/src/{values/animation → animation}/timing/useLoop.d.ts +0 -0
  261. package/lib/typescript/src/{values/animation → animation}/timing/useTiming.d.ts +1 -1
  262. package/lib/typescript/src/{values/animation → animation}/types.d.ts +0 -0
  263. package/lib/typescript/src/index.d.ts +1 -0
  264. package/lib/typescript/src/renderer/components/colorFilters/BlendColor.d.ts +1 -1
  265. package/lib/typescript/src/renderer/components/imageFilters/RuntimeShader.d.ts +7 -0
  266. package/lib/typescript/src/renderer/components/imageFilters/index.d.ts +1 -0
  267. package/lib/typescript/src/renderer/components/shaders/Gradient.d.ts +1 -1
  268. package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +2 -2
  269. package/lib/typescript/src/renderer/components/shapes/Circle.d.ts +1 -4
  270. package/lib/typescript/src/renderer/processors/Rects.d.ts +9 -41
  271. package/lib/typescript/src/renderer/processors/math/Matrix3.d.ts +1 -5
  272. package/lib/typescript/src/renderer/processors/math/Vector.d.ts +5 -17
  273. package/lib/typescript/src/skia/Color.d.ts +8 -9
  274. package/lib/typescript/src/skia/ImageFilter/ImageFilterFactory.d.ts +16 -0
  275. package/lib/typescript/src/skia/Matrix.d.ts +7 -1
  276. package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffect.d.ts +2 -1
  277. package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffectFactory.d.ts +2 -2
  278. package/lib/typescript/src/skia/Shader/useShader.d.ts +1 -1
  279. package/lib/typescript/src/skia/Skia.d.ts +28 -95
  280. package/lib/typescript/src/skia/SkiaApi.d.ts +71 -0
  281. package/lib/typescript/src/skia/Surface/Surface.d.ts +1 -1
  282. package/lib/typescript/src/skia/Surface/SurfaceFactory.d.ts +2 -2
  283. package/lib/typescript/src/values/api.d.ts +2 -25
  284. package/lib/typescript/src/values/api.web.d.ts +2 -0
  285. package/lib/typescript/src/values/index.d.ts +0 -1
  286. package/lib/typescript/src/values/types.d.ts +24 -1
  287. package/lib/typescript/src/values/web/RNSkAnimation.d.ts +9 -0
  288. package/lib/typescript/src/values/web/RNSkClockValue.d.ts +13 -0
  289. package/lib/typescript/src/values/web/RNSkDerivedValue.d.ts +9 -0
  290. package/lib/typescript/src/values/web/RNSkReadonlyValue.d.ts +11 -0
  291. package/lib/typescript/src/values/web/RNSkValue.d.ts +14 -0
  292. package/lib/typescript/src/values/web/api.d.ts +2 -0
  293. package/lib/typescript/src/values/web/index.d.ts +1 -0
  294. package/lib/typescript/src/views/SkiaView.d.ts +3 -36
  295. package/lib/typescript/src/views/api.d.ts +5 -0
  296. package/lib/typescript/src/views/types.d.ts +32 -0
  297. package/package.json +2 -2
  298. package/src/{values/animation → animation}/decay/decay.ts +0 -0
  299. package/src/{values/animation → animation}/decay/index.ts +0 -0
  300. package/src/{values/animation → animation}/decay/runDecay.ts +2 -2
  301. package/src/{values/animation → animation}/decay/types.ts +1 -1
  302. package/src/{values/animation → animation}/functions/index.ts +0 -0
  303. package/src/animation/functions/interpolate.ts +182 -0
  304. package/src/animation/functions/interpolateColors.ts +58 -0
  305. package/src/{values/animation → animation}/index.ts +0 -0
  306. package/src/{values/animation → animation}/spring/Spring.ts +0 -0
  307. package/src/{values/animation → animation}/spring/functions/index.ts +0 -0
  308. package/src/{values/animation → animation}/spring/functions/spring.ts +0 -0
  309. package/src/{values/animation → animation}/spring/index.ts +0 -0
  310. package/src/{values/animation → animation}/spring/runSpring.ts +1 -1
  311. package/src/{values/animation → animation}/spring/types.ts +0 -0
  312. package/src/{values/animation → animation}/spring/useSpring.ts +1 -1
  313. package/src/{values/animation → animation}/timing/Easing.ts +0 -0
  314. package/src/{values/animation → animation}/timing/createTiming.ts +2 -2
  315. package/src/{values/animation → animation}/timing/functions/__tests__/timing.spec.ts +0 -0
  316. package/src/{values/animation → animation}/timing/functions/bezier.ts +0 -0
  317. package/src/{values/animation → animation}/timing/functions/getResolvedParams.ts +0 -0
  318. package/src/{values/animation → animation}/timing/functions/index.ts +0 -0
  319. package/src/{values/animation → animation}/timing/functions/timing.ts +1 -1
  320. package/src/{values/animation → animation}/timing/functions/types.ts +0 -0
  321. package/src/{values/animation → animation}/timing/index.ts +0 -0
  322. package/src/{values/animation → animation}/timing/runTiming.ts +1 -1
  323. package/src/{values/animation → animation}/timing/useLoop.ts +0 -0
  324. package/src/{values/animation → animation}/timing/useTiming.ts +2 -2
  325. package/src/{values/animation → animation}/types.ts +0 -0
  326. package/src/index.ts +1 -0
  327. package/src/renderer/components/colorFilters/BlendColor.tsx +1 -1
  328. package/src/renderer/components/imageFilters/InnerShadow.tsx +4 -2
  329. package/src/renderer/components/imageFilters/RuntimeShader.tsx +23 -0
  330. package/src/renderer/components/imageFilters/index.ts +1 -0
  331. package/src/renderer/components/shaders/Gradient.ts +2 -4
  332. package/src/renderer/components/shaders/Shader.tsx +2 -2
  333. package/src/renderer/processors/Rects.ts +6 -12
  334. package/src/renderer/processors/math/Matrix3.ts +24 -105
  335. package/src/renderer/processors/math/Vector.ts +3 -2
  336. package/src/skia/Color.ts +13 -27
  337. package/src/skia/ImageFilter/ImageFilterFactory.ts +20 -0
  338. package/src/skia/Matrix.ts +8 -1
  339. package/src/skia/RuntimeEffect/RuntimeEffect.ts +3 -1
  340. package/src/skia/RuntimeEffect/RuntimeEffectFactory.ts +2 -2
  341. package/src/skia/Shader/useShader.ts +4 -1
  342. package/src/skia/Skia.ts +4 -126
  343. package/src/skia/SkiaApi.ts +86 -0
  344. package/src/skia/Surface/Surface.ts +1 -1
  345. package/src/skia/Surface/SurfaceFactory.ts +2 -2
  346. package/src/values/api.ts +3 -42
  347. package/src/values/api.web.ts +5 -0
  348. package/src/values/index.ts +0 -1
  349. package/src/values/types.ts +30 -1
  350. package/src/values/web/RNSkAnimation.ts +33 -0
  351. package/src/values/web/RNSkClockValue.ts +58 -0
  352. package/src/values/web/RNSkDerivedValue.ts +38 -0
  353. package/src/values/web/RNSkReadonlyValue.ts +32 -0
  354. package/src/values/web/RNSkValue.ts +57 -0
  355. package/src/values/web/__tests__/RNSkAnimation.spec.ts +21 -0
  356. package/src/values/web/__tests__/RNSkDerivedValue.spec.ts +15 -0
  357. package/src/values/web/__tests__/RNSkReadonlyValue.spec.ts +8 -0
  358. package/src/values/web/__tests__/RNSkValue.spec.ts +11 -0
  359. package/src/values/web/api.ts +33 -0
  360. package/src/values/web/index.ts +1 -0
  361. package/src/views/SkiaView.tsx +3 -49
  362. package/src/views/api.ts +7 -0
  363. package/src/views/types.ts +40 -0
  364. package/lib/commonjs/values/animation/decay/runDecay.js.map +0 -1
  365. package/lib/commonjs/values/animation/functions/interpolate.js +0 -139
  366. package/lib/commonjs/values/animation/functions/interpolate.js.map +0 -1
  367. package/lib/commonjs/values/animation/functions/interpolateColors.js +0 -47
  368. package/lib/commonjs/values/animation/functions/interpolateColors.js.map +0 -1
  369. package/lib/commonjs/values/animation/spring/runSpring.js.map +0 -1
  370. package/lib/commonjs/values/animation/spring/useSpring.js.map +0 -1
  371. package/lib/commonjs/values/animation/timing/createTiming.js.map +0 -1
  372. package/lib/commonjs/values/animation/timing/runTiming.js.map +0 -1
  373. package/lib/commonjs/values/animation/timing/useTiming.js.map +0 -1
  374. package/lib/module/values/animation/decay/runDecay.js.map +0 -1
  375. package/lib/module/values/animation/functions/interpolate.js +0 -132
  376. package/lib/module/values/animation/functions/interpolate.js.map +0 -1
  377. package/lib/module/values/animation/functions/interpolateColors.js +0 -32
  378. package/lib/module/values/animation/functions/interpolateColors.js.map +0 -1
  379. package/lib/module/values/animation/spring/runSpring.js.map +0 -1
  380. package/lib/module/values/animation/spring/useSpring.js.map +0 -1
  381. package/lib/module/values/animation/timing/createTiming.js.map +0 -1
  382. package/lib/module/values/animation/timing/runTiming.js.map +0 -1
  383. package/lib/module/values/animation/timing/useTiming.js.map +0 -1
  384. package/lib/typescript/scripts/install-npm.d.ts +0 -1
  385. package/lib/typescript/src/values/animation/functions/interpolate.d.ts +0 -7
  386. package/lib/typescript/src/values/animation/functions/interpolateColors.d.ts +0 -3
  387. package/src/values/animation/functions/interpolate.ts +0 -169
  388. package/src/values/animation/functions/interpolateColors.ts +0 -62
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mixColors = exports.interpolateColors = void 0;
7
+
8
+ var _renderer = require("../../renderer");
9
+
10
+ var _skia = require("../../skia");
11
+
12
+ var _interpolate = require("./interpolate");
13
+
14
+ const interpolateColorsRGB = (value, inputRange, outputRange) => {
15
+ const r = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[0]), "clamp");
16
+ const g = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[1]), "clamp");
17
+ const b = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[2]), "clamp");
18
+ const a = (0, _interpolate.interpolate)(value, inputRange, outputRange.map(c => c[3]), "clamp");
19
+ return new Float32Array([r, g, b, a]);
20
+ };
21
+
22
+ const interpolateColors = (value, inputRange, _outputRange) => {
23
+ const outputRange = _outputRange.map(cl => _skia.Skia.Color(cl));
24
+
25
+ return interpolateColorsRGB(value, inputRange, outputRange);
26
+ };
27
+
28
+ exports.interpolateColors = interpolateColors;
29
+
30
+ const mixColors = (value, x, y) => {
31
+ const c1 = _skia.Skia.Color(x);
32
+
33
+ const c2 = _skia.Skia.Color(y);
34
+
35
+ return new Float32Array([(0, _renderer.mix)(value, c1[0], c2[0]), (0, _renderer.mix)(value, c1[1], c2[1]), (0, _renderer.mix)(value, c1[2], c2[2]), (0, _renderer.mix)(value, c1[3], c2[3])]);
36
+ };
37
+
38
+ exports.mixColors = mixColors;
39
+ //# sourceMappingURL=interpolateColors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["interpolateColors.ts"],"names":["interpolateColorsRGB","value","inputRange","outputRange","r","map","c","g","b","a","Float32Array","interpolateColors","_outputRange","cl","Skia","Color","mixColors","x","y","c1","c2"],"mappings":";;;;;;;AAAA;;AAEA;;AAGA;;AAEA,MAAMA,oBAAoB,GAAG,CAC3BC,KAD2B,EAE3BC,UAF2B,EAG3BC,WAH2B,KAIxB;AACH,QAAMC,CAAC,GAAG,8BACRH,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;AAMA,QAAMC,CAAC,GAAG,8BACRN,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;AAMA,QAAME,CAAC,GAAG,8BACRP,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;AAMA,QAAMG,CAAC,GAAG,8BACRR,KADQ,EAERC,UAFQ,EAGRC,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOA,CAAC,CAAC,CAAD,CAAxB,CAHQ,EAIR,OAJQ,CAAV;AAMA,SAAO,IAAII,YAAJ,CAAiB,CAACN,CAAD,EAAIG,CAAJ,EAAOC,CAAP,EAAUC,CAAV,CAAjB,CAAP;AACD,CA9BD;;AAgCO,MAAME,iBAAiB,GAAG,CAC/BV,KAD+B,EAE/BC,UAF+B,EAG/BU,YAH+B,KAI5B;AACH,QAAMT,WAAW,GAAGS,YAAY,CAACP,GAAb,CAAkBQ,EAAD,IAAQC,WAAKC,KAAL,CAAWF,EAAX,CAAzB,CAApB;;AACA,SAAOb,oBAAoB,CAACC,KAAD,EAAQC,UAAR,EAAoBC,WAApB,CAA3B;AACD,CAPM;;;;AASA,MAAMa,SAAS,GAAG,CAACf,KAAD,EAAgBgB,CAAhB,EAA0BC,CAA1B,KAAuC;AAC9D,QAAMC,EAAE,GAAGL,WAAKC,KAAL,CAAWE,CAAX,CAAX;;AACA,QAAMG,EAAE,GAAGN,WAAKC,KAAL,CAAWG,CAAX,CAAX;;AACA,SAAO,IAAIR,YAAJ,CAAiB,CACtB,mBAAIT,KAAJ,EAAWkB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CADsB,EAEtB,mBAAInB,KAAJ,EAAWkB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAFsB,EAGtB,mBAAInB,KAAJ,EAAWkB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAHsB,EAItB,mBAAInB,KAAJ,EAAWkB,EAAE,CAAC,CAAD,CAAb,EAAkBC,EAAE,CAAC,CAAD,CAApB,CAJsB,CAAjB,CAAP;AAMD,CATM","sourcesContent":["import { mix } from \"../../renderer\";\nimport type { Color } from \"../../skia\";\nimport { Skia } from \"../../skia\";\nimport type { SkColor } from \"../../skia/Color\";\n\nimport { interpolate } from \"./interpolate\";\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: number[],\n outputRange: SkColor[]\n) => {\n const r = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[0]),\n \"clamp\"\n );\n const g = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[1]),\n \"clamp\"\n );\n const b = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[2]),\n \"clamp\"\n );\n const a = interpolate(\n value,\n inputRange,\n outputRange.map((c) => c[3]),\n \"clamp\"\n );\n return new Float32Array([r, g, b, a]);\n};\n\nexport const interpolateColors = (\n value: number,\n inputRange: number[],\n _outputRange: Color[]\n) => {\n const outputRange = _outputRange.map((cl) => Skia.Color(cl));\n return interpolateColorsRGB(value, inputRange, outputRange);\n};\n\nexport const mixColors = (value: number, x: Color, y: Color) => {\n const c1 = Skia.Color(x);\n const c2 = Skia.Color(y);\n return new Float32Array([\n mix(value, c1[0], c2[0]),\n mix(value, c1[1], c2[1]),\n mix(value, c1[2], c2[2]),\n mix(value, c1[3], c2[3]),\n ]);\n};\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["runSpring.ts"],"names":["runSpring","value","toOrParams","config","callback","Spring","Config","Default"],"mappings":";;;;;;;AAMA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,SAAS,GAAG,CACvBC,KADuB,EAEvBC,UAFuB,EAGvBC,MAHuB,EAIvBC,QAJuB,KAKL;AAClB,SAAO,0BACLH,KADK,EAELC,UAFK,EAGL,gCAAmBC,MAAnB,aAAmBA,MAAnB,cAAmBA,MAAnB,GAA6BE,eAAOC,MAAP,CAAcC,OAA3C,CAHK,EAILH,QAJK,CAAP;AAMD,CAZM","sourcesContent":["import type { SkiaValue, SkiaAnimation } from \"../../values/types\";\nimport type {\n AnimationParams,\n SpringConfig,\n AnimationCallback,\n} from \"../types\";\nimport { runTiming } from \"../timing/runTiming\";\n\nimport { Spring } from \"./Spring\";\nimport { createSpringEasing } from \"./functions/spring\";\n\n/**\n * Creates a new animation on an existing value that will be driven by\n * an animation value. The value will be run from / to the value in\n * params and modified by the provided easing curve for the length of\n * the duration. When the value has reached its desired \"to\" value the\n * animation will be stopped.\n *\n * @param value The value to animate\n * @param toOrParams To value or Animation parameters\n * @param config Spring configuration\n * @returns an animation value that can be used to start/stop\n * the animation.\n */\nexport const runSpring = (\n value: SkiaValue<number>,\n toOrParams: number | AnimationParams,\n config?: SpringConfig,\n callback?: AnimationCallback\n): SkiaAnimation => {\n return runTiming(\n value,\n toOrParams,\n createSpringEasing(config ?? Spring.Config.Default),\n callback\n );\n};\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useSpring.ts"],"names":["useSpring","toOrParams","config","callback","Spring","Config","Default"],"mappings":";;;;;;;AAMA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,SAAS,GAAG,CACvBC,UADuB,EAEvBC,MAFuB,EAGvBC,QAHuB,KAKvB,uBACEF,UADF,EAEE,gCAAmBC,MAAnB,aAAmBA,MAAnB,cAAmBA,MAAnB,GAA6BE,eAAOC,MAAP,CAAcC,OAA3C,CAFF,EAGEH,QAHF,CALK","sourcesContent":["import type { SkiaReadonlyValue } from \"../../values/types\";\nimport type {\n SpringConfig,\n AnimationParams,\n AnimationCallback,\n} from \"../types\";\nimport { useTiming } from \"../timing\";\n\nimport { Spring } from \"./Spring\";\nimport { createSpringEasing } from \"./functions/spring\";\n\n/**\n * Creats a spring based animation value that will run whenever\n * the animation parameters change.\n * @param toOrParams\n * @param config\n * @returns\n */\nexport const useSpring = (\n toOrParams: number | AnimationParams,\n config?: SpringConfig,\n callback?: AnimationCallback\n): SkiaReadonlyValue<number> =>\n useTiming(\n toOrParams,\n createSpringEasing(config ?? Spring.Config.Default),\n callback\n );\n"]}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createTiming = void 0;
7
7
 
8
- var _api = require("../../api");
8
+ var _api = require("../../values/api");
9
9
 
10
10
  var _functions = require("./functions");
11
11
 
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["createTiming.ts"],"names":["createTiming","params","value","callback","resolvedParams","from","current","animationFunction","t","state","nextState","duration","easing","loop","yoyo","finished","to","ValueApi","createAnimation"],"mappings":";;;;;;;AAMA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,YAAY,GAAG,CAC1BC,MAD0B,EAE1BC,KAF0B,EAG1BC,QAH0B,KAIvB;AAAA;;AACH;AACA;AACA,QAAMC,cAAc,GAAG,EACrB,GAAGH,MADkB;AAErBI,IAAAA,IAAI,0BAAEJ,MAAM,CAACI,IAAT,uDAAiBH,KAAjB,aAAiBA,KAAjB,uBAAiBA,KAAK,CAAEI,OAAxB,uCAAmC;AAFlB,GAAvB,CAHG,CAQH;;AACA,QAAMC,iBAAiB,GAAG,CAACC,CAAD,EAAYC,KAAZ,KAAkD;AAAA;;AAC1E;AACA,UAAMC,SAAS,GAAG,uBAChBF,CADgB,EAEhBP,MAAM,CAACU,QAFS,EAGhBV,MAAM,CAACW,MAHS,kBAIhBX,MAAM,CAACY,IAJS,uDAID,KAJC,kBAKhBZ,MAAM,CAACa,IALS,uDAKD,KALC,EAMhBL,KANgB,aAMhBA,KANgB,cAMhBA,KANgB,GAMP;AAAEH,MAAAA,OAAO,EAAEL,MAAM,CAACI,IAAlB;AAAyBU,MAAAA,QAAQ,EAAE;AAAnC,KANO,CAAlB;AAQA,UAAMT,OAAO,GACXI,SAAS,CAACJ,OAAV,IAAqBF,cAAc,CAACY,EAAf,GAAoBZ,cAAc,CAACC,IAAxD,IACAD,cAAc,CAACC,IAFjB;;AAGA,QAAIF,QAAQ,IAAIO,SAAS,CAACK,QAAV,KAAuB,IAAvC,EAA6C;AAC3CZ,MAAAA,QAAQ,CAACG,OAAD,CAAR;AACD;;AACD,WAAO,EACL,GAAGI,SADE;AAELJ,MAAAA;AAFK,KAAP;AAID,GApBD,CATG,CA+BH;;;AACA,SAAOW,cAASC,eAAT,CAAyBX,iBAAzB,CAAP;AACD,CArCM","sourcesContent":["import type {\n TimingConfig,\n RequiredAnimationParams,\n AnimationCallback,\n} from \"../types\";\nimport type { AnimationState, SkiaValue } from \"../../values/types\";\nimport { ValueApi } from \"../../values/api\";\n\nimport { timing } from \"./functions\";\n\n/**\n * Creates an animation that is driven by a clock value.\n * The value will be run from / to the value in params and modified\n * by the provided easing curve for the length of the duration. When\n * the value has reached its desired \"to\" value the animation\n * will be stopped. If loop is set to true, the animation will continue\n * to run until stopped.\n *\n * @param params Animation parameters\n * @param config Spring or timing configuration\n * @param value Optional value that the animation will update\n * @params an animation value that can be used to start/stop\n * the animation.\n */\nexport const createTiming = (\n params: RequiredAnimationParams & Required<TimingConfig>,\n value?: SkiaValue<number>,\n callback?: AnimationCallback\n) => {\n // Update from to be either the declared from value,\n // the current value of the value or zero\n const resolvedParams = {\n ...params,\n from: params.from ?? value?.current ?? 0,\n };\n\n // Update function for the animation value\n const animationFunction = (t: number, state: AnimationState | undefined) => {\n // Update the input value using the provided update function\n const nextState = timing(\n t,\n params.duration,\n params.easing,\n params.loop ?? false,\n params.yoyo ?? false,\n state ?? { current: params.from!, finished: false }\n );\n const current =\n nextState.current * (resolvedParams.to - resolvedParams.from!) +\n resolvedParams.from!;\n if (callback && nextState.finished === true) {\n callback(current);\n }\n return {\n ...nextState,\n current,\n };\n };\n\n // Create animation value\n return ValueApi.createAnimation(animationFunction);\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["timing.ts"],"names":["timing","t","duration","easing","loop","yoyo","state","current","finished","n","Math","max","min"],"mappings":";;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,MAAM,GAAG,CACpBC,CADoB,EAEpBC,QAFoB,EAGpBC,MAHoB,EAIpBC,IAJoB,EAKpBC,IALoB,EAMpBC,KANoB,KAOjB;AACH,MAAIC,OAAO,GAAGN,CAAC,GAAGC,QAAlB;AACA,MAAI;AAAEM,IAAAA;AAAF,MAAeF,KAAnB,CAFG,CAGH;;AACA,MAAIC,OAAO,IAAI,GAAX,IAAkB,CAACH,IAAvB,EAA6B;AAC3BI,IAAAA,QAAQ,GAAG,IAAX;AACAD,IAAAA,OAAO,GAAG,GAAV;AACD,GAPE,CAQH;;;AACA,MAAIE,CAAC,GAAGF,OAAO,GAAG,CAAlB;;AACA,MAAIF,IAAJ,EAAU;AACRI,IAAAA,CAAC,GAAGF,OAAO,GAAG,GAAV,IAAiB,GAAjB,GAAuB,IAAKA,OAAO,GAAG,CAAtC,GAA2CA,OAAO,GAAG,CAAzD;AACD,GAFD,MAEO,IAAI,CAACH,IAAL,EAAW;AAChB,QAAIG,OAAO,IAAI,GAAf,EAAoB;AAClBE,MAAAA,CAAC,GAAG,GAAJ;AACD;AACF;;AACDF,EAAAA,OAAO,GAAGJ,MAAM,CAACO,IAAI,CAACC,GAAL,CAAS,CAAT,EAAYD,IAAI,CAACE,GAAL,CAAS,CAAT,EAAYH,CAAZ,CAAZ,CAAD,CAAhB;AACA,SAAO;AACLF,IAAAA,OADK;AAELC,IAAAA;AAFK,GAAP;AAID,CA7BM","sourcesContent":["import type { AnimationState } from \"../../../types\";\n\n/**\n * Calculates and returns a timing value based on the\n * input parameters. The timing value is a number between\n * 0 and 1.\n * @param t\n * @param duration\n * @param easing\n * @param loop\n * @param yoyo\n * @param onStop\n * @returns\n */\nexport const timing = (\n t: number,\n duration: number,\n easing: (t: number) => number,\n loop: boolean,\n yoyo: boolean,\n state: AnimationState\n) => {\n let current = t / duration;\n let { finished } = state;\n // Side effect to stop animation when duration is reached (if loop is false)\n if (current >= 1.0 && !loop) {\n finished = true;\n current = 1.0;\n }\n // calculate return value\n let n = current % 1;\n if (yoyo) {\n n = current % 2.0 >= 1.0 ? 1 - (current % 1) : current % 1;\n } else if (!loop) {\n if (current >= 1.0) {\n n = 1.0;\n }\n }\n current = easing(Math.max(0, Math.min(1, n)));\n return {\n current,\n finished,\n };\n};\n"]}
1
+ {"version":3,"sources":["timing.ts"],"names":["timing","t","duration","easing","loop","yoyo","state","current","finished","n","Math","max","min"],"mappings":";;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,MAAM,GAAG,CACpBC,CADoB,EAEpBC,QAFoB,EAGpBC,MAHoB,EAIpBC,IAJoB,EAKpBC,IALoB,EAMpBC,KANoB,KAOjB;AACH,MAAIC,OAAO,GAAGN,CAAC,GAAGC,QAAlB;AACA,MAAI;AAAEM,IAAAA;AAAF,MAAeF,KAAnB,CAFG,CAGH;;AACA,MAAIC,OAAO,IAAI,GAAX,IAAkB,CAACH,IAAvB,EAA6B;AAC3BI,IAAAA,QAAQ,GAAG,IAAX;AACAD,IAAAA,OAAO,GAAG,GAAV;AACD,GAPE,CAQH;;;AACA,MAAIE,CAAC,GAAGF,OAAO,GAAG,CAAlB;;AACA,MAAIF,IAAJ,EAAU;AACRI,IAAAA,CAAC,GAAGF,OAAO,GAAG,GAAV,IAAiB,GAAjB,GAAuB,IAAKA,OAAO,GAAG,CAAtC,GAA2CA,OAAO,GAAG,CAAzD;AACD,GAFD,MAEO,IAAI,CAACH,IAAL,EAAW;AAChB,QAAIG,OAAO,IAAI,GAAf,EAAoB;AAClBE,MAAAA,CAAC,GAAG,GAAJ;AACD;AACF;;AACDF,EAAAA,OAAO,GAAGJ,MAAM,CAACO,IAAI,CAACC,GAAL,CAAS,CAAT,EAAYD,IAAI,CAACE,GAAL,CAAS,CAAT,EAAYH,CAAZ,CAAZ,CAAD,CAAhB;AACA,SAAO;AACLF,IAAAA,OADK;AAELC,IAAAA;AAFK,GAAP;AAID,CA7BM","sourcesContent":["import type { AnimationState } from \"../../../values/types\";\n\n/**\n * Calculates and returns a timing value based on the\n * input parameters. The timing value is a number between\n * 0 and 1.\n * @param t\n * @param duration\n * @param easing\n * @param loop\n * @param yoyo\n * @param onStop\n * @returns\n */\nexport const timing = (\n t: number,\n duration: number,\n easing: (t: number) => number,\n loop: boolean,\n yoyo: boolean,\n state: AnimationState\n) => {\n let current = t / duration;\n let { finished } = state;\n // Side effect to stop animation when duration is reached (if loop is false)\n if (current >= 1.0 && !loop) {\n finished = true;\n current = 1.0;\n }\n // calculate return value\n let n = current % 1;\n if (yoyo) {\n n = current % 2.0 >= 1.0 ? 1 - (current % 1) : current % 1;\n } else if (!loop) {\n if (current >= 1.0) {\n n = 1.0;\n }\n }\n current = easing(Math.max(0, Math.min(1, n)));\n return {\n current,\n finished,\n };\n};\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["runTiming.ts"],"names":["runTiming","value","toOrParams","config","callback","resolvedParameters","animation"],"mappings":";;;;;;;AAOA;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,SAAS,GAAG,CACvBC,KADuB,EAEvBC,UAFuB,EAGvBC,MAHuB,EAIvBC,QAJuB,KAKL;AAClB,QAAMC,kBAAkB,GAAG,kCAAkBH,UAAlB,EAA8BC,MAA9B,CAA3B;AACA,QAAMG,SAAS,GAAG,gCAAaD,kBAAb,EAAiCJ,KAAjC,EAAwCG,QAAxC,CAAlB;AACAH,EAAAA,KAAK,CAACK,SAAN,GAAkBA,SAAlB;AACA,SAAOA,SAAP;AACD,CAVM","sourcesContent":["import type { SkiaValue, SkiaAnimation } from \"../../values/types\";\nimport type {\n AnimationParams,\n TimingConfig,\n AnimationCallback,\n} from \"../types\";\n\nimport { getResolvedParams } from \"./functions\";\nimport { createTiming } from \"./createTiming\";\n/**\n * Creates a new animation on an existing value that will be driven by\n * an animation value. The value will be run from / to the value in\n * params and modified by the provided easing curve for the length of\n * the duration. When the value has reached its desired \"to\" value the\n * animation will be stopped.\n *\n * @param value The value to animate\n * @param toOrParams To value or Animation parameters\n * @param config Spring or timing configuration\n * @returns an animation value that can be used to start/stop\n * the animation.\n */\nexport const runTiming = (\n value: SkiaValue<number>,\n toOrParams: number | AnimationParams,\n config?: TimingConfig,\n callback?: AnimationCallback\n): SkiaAnimation => {\n const resolvedParameters = getResolvedParams(toOrParams, config);\n const animation = createTiming(resolvedParameters, value, callback);\n value.animation = animation;\n return animation;\n};\n"]}
@@ -7,7 +7,7 @@ exports.useTiming = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
- var _useValue = require("../../hooks/useValue");
10
+ var _useValue = require("../../values/hooks/useValue");
11
11
 
12
12
  var _functions = require("./functions");
13
13
 
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useTiming.ts"],"names":["useTiming","toOrParams","config","callback","prevCfgRef","resolvedParameters","nextParams","equals","current","value","from","prevAnimationRef","prevParamsRef","animation","undefined","a","b","JSON","stringify"],"mappings":";;;;;;;AAAA;;AAQA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,SAAS,GAAG,CACvBC,UADuB,EAEvBC,MAFuB,EAGvBC,QAHuB,KAIO;AAAA;;AAC9B;AACA;AACA,QAAMC,UAAU,GAAG,oBAAnB;AACA,QAAMC,kBAAkB,GAAG,oBAAQ,MAAM;AACvC,UAAMC,UAAU,GAAG,kCAAkBL,UAAlB,EAA8BC,MAA9B,CAAnB;;AACA,QAAI,CAACK,MAAM,CAACH,UAAU,CAACI,OAAZ,EAAqBF,UAArB,CAAX,EAA6C;AAC3CF,MAAAA,UAAU,CAACI,OAAX,GAAqBF,UAArB;AACD;;AACD,WAAOF,UAAU,CAACI,OAAlB;AACD,GAN0B,EAMxB,CAACN,MAAD,EAASD,UAAT,CANwB,CAA3B,CAJ8B,CAY9B;;AACA,QAAMQ,KAAK,GAAG,iDAASJ,kBAAkB,CAACK,IAA5B,yEAAoC,CAApC,CAAd,CAb8B,CAe9B;AACA;;AACA,QAAMC,gBAAgB,GAAG,oBAAzB;AACA,QAAMC,aAAa,GAAG,oBAAtB;AACA,QAAMC,SAAS,GAAG,oBAAQ,MAAM;AAC9B,QAAI,CAACN,MAAM,CAACK,aAAa,CAACJ,OAAf,EAAwBH,kBAAxB,CAAX,EAAwD;AACtDO,MAAAA,aAAa,CAACJ,OAAd,GAAwBH,kBAAxB;AACAM,MAAAA,gBAAgB,CAACH,OAAjB,GAA2B,gCACzBH,kBADyB,EAEzBI,KAFyB,EAGzBN,QAHyB,CAA3B;AAKD;;AACD,WAAOQ,gBAAgB,CAACH,OAAxB;AACD,GAViB,EAUf,CAACL,QAAD,EAAWE,kBAAX,EAA+BI,KAA/B,CAVe,CAAlB,CAnB8B,CA+B9B;;AACA,wBAAU,MAAM;AACdA,IAAAA,KAAK,CAACI,SAAN,GAAkBA,SAAlB;AACA,WAAO,MAAOJ,KAAK,CAACI,SAAN,GAAkBC,SAAhC;AACD,GAHD,EAGG,CAACD,SAAD,EAAYJ,KAAZ,CAHH,EAhC8B,CAqC9B;;AACA,SAAOA,KAAP;AACD,CA3CM;;;;AA6CP,MAAMF,MAAM,GAAG,CAASQ,CAAT,EAAgBC,CAAhB,KAA0B;AACvC,SAAOC,IAAI,CAACC,SAAL,CAAeH,CAAf,MAAsBE,IAAI,CAACC,SAAL,CAAeF,CAAf,CAA7B;AACD,CAFD","sourcesContent":["import { useEffect, useMemo, useRef } from \"react\";\n\nimport type { SkiaReadonlyValue, SkiaAnimation } from \"../../values/types\";\nimport type {\n AnimationParams,\n TimingConfig,\n AnimationCallback,\n} from \"../types\";\nimport { useValue } from \"../../values/hooks/useValue\";\n\nimport { getResolvedParams } from \"./functions\";\nimport { createTiming } from \"./createTiming\";\n\n/**\n * Creats an animation value that will run whenever\n * the animation parameters change. The animation start immediately.\n * @param toOrParams\n * @param config\n * @returns A value that is animated\n */\nexport const useTiming = (\n toOrParams: number | AnimationParams,\n config?: TimingConfig,\n callback?: AnimationCallback\n): SkiaReadonlyValue<number> => {\n // Resolve parameters - keep a cached version to avoid\n // unnecesary re-renders.\n const prevCfgRef = useRef<ReturnType<typeof getResolvedParams>>();\n const resolvedParameters = useMemo(() => {\n const nextParams = getResolvedParams(toOrParams, config);\n if (!equals(prevCfgRef.current, nextParams)) {\n prevCfgRef.current = nextParams;\n }\n return prevCfgRef.current!;\n }, [config, toOrParams]);\n\n // Create value\n const value = useValue(resolvedParameters.from ?? 0);\n\n // Create timing animation - keep a cached version to avoid\n // uneccessary recreation of animations\n const prevAnimationRef = useRef<SkiaAnimation>();\n const prevParamsRef = useRef<typeof resolvedParameters>();\n const animation = useMemo(() => {\n if (!equals(prevParamsRef.current, resolvedParameters)) {\n prevParamsRef.current = resolvedParameters;\n prevAnimationRef.current = createTiming(\n resolvedParameters,\n value,\n callback\n );\n }\n return prevAnimationRef.current!;\n }, [callback, resolvedParameters, value]);\n\n // Run animation on the value - and stop it on unmount\n useEffect(() => {\n value.animation = animation;\n return () => (value.animation = undefined);\n }, [animation, value]);\n\n // Return the value that is animated\n return value;\n};\n\nconst equals = <T1, T2>(a: T1, b: T2) => {\n return JSON.stringify(a) === JSON.stringify(b);\n};\n"]}
@@ -70,4 +70,17 @@ Object.keys(_values).forEach(function (key) {
70
70
  }
71
71
  });
72
72
  });
73
+
74
+ var _animation = require("./animation");
75
+
76
+ Object.keys(_animation).forEach(function (key) {
77
+ if (key === "default" || key === "__esModule") return;
78
+ if (key in exports && exports[key] === _animation[key]) return;
79
+ Object.defineProperty(exports, key, {
80
+ enumerable: true,
81
+ get: function () {
82
+ return _animation[key];
83
+ }
84
+ });
85
+ });
73
86
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["import \"./skia/NativeSetup\";\n\nexport * from \"./renderer\";\nexport * from \"./views\";\nexport * from \"./skia\";\nexport * from \"./external\";\nexport * from \"./values\";\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["import \"./skia/NativeSetup\";\n\nexport * from \"./renderer\";\nexport * from \"./views\";\nexport * from \"./skia\";\nexport * from \"./external\";\nexport * from \"./values\";\nexport * from \"./animation\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["BlendColor.tsx"],"names":["onDeclare","children","mode","color","cf","Skia","ColorFilter","MakeBlend","Color","BlendMode","BlendColor","props"],"mappings":";;;;;;;AAAA;;AAGA;;AACA;;AAEA;;AAGA;;;;;;AAQA,MAAMA,SAAS,GAAG,8BAChB,OAAkBC,QAAlB,KAA+B;AAAA,MAA9B;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAA8B;;AAC7B,QAAMC,EAAE,GAAGC,WAAKC,WAAL,CAAiBC,SAAjB,CACTF,WAAKG,KAAL,CAAWL,KAAX,CADS,EAETM,gBAAU,yBAAQP,IAAR,CAAV,CAFS,CAAX;;AAIA,SAAO,iCAAmBE,EAAnB,EAAuBH,QAAvB,CAAP;AACD,CAPe,CAAlB;;AAUO,MAAMS,UAAU,GAAIC,KAAD,IAA2C;AACnE,sBAAO;AAAe,IAAA,SAAS,EAAEX;AAA1B,KAAyCW,KAAzC,EAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport { BlendMode, Skia } from \"../../../skia\";\nimport { createDeclaration } from \"../../nodes\";\nimport type { SkEnum, AnimatedProps } from \"../../processors\";\nimport { enumKey } from \"../../processors\";\nimport type { Color } from \"../../../skia\";\n\nimport { composeColorFilter } from \"./Compose\";\n\nexport interface BlendColorProps {\n mode: SkEnum<typeof BlendMode>;\n color: Color;\n children?: ReactNode | ReactNode[];\n}\n\nconst onDeclare = createDeclaration<BlendColorProps>(\n ({ mode, color }, children) => {\n const cf = Skia.ColorFilter.MakeBlend(\n Skia.Color(color),\n BlendMode[enumKey(mode)]\n );\n return composeColorFilter(cf, children);\n }\n);\n\nexport const BlendColor = (props: AnimatedProps<BlendColorProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n"]}
1
+ {"version":3,"sources":["BlendColor.tsx"],"names":["onDeclare","children","mode","color","cf","Skia","ColorFilter","MakeBlend","Color","BlendMode","BlendColor","props"],"mappings":";;;;;;;AAAA;;AAIA;;AACA;;AAEA;;AAEA;;;;;;AAQA,MAAMA,SAAS,GAAG,8BAChB,OAAkBC,QAAlB,KAA+B;AAAA,MAA9B;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAA8B;;AAC7B,QAAMC,EAAE,GAAGC,WAAKC,WAAL,CAAiBC,SAAjB,CACTF,WAAKG,KAAL,CAAWL,KAAX,CADS,EAETM,gBAAU,yBAAQP,IAAR,CAAV,CAFS,CAAX;;AAIA,SAAO,iCAAmBE,EAAnB,EAAuBH,QAAvB,CAAP;AACD,CAPe,CAAlB;;AAUO,MAAMS,UAAU,GAAIC,KAAD,IAA2C;AACnE,sBAAO;AAAe,IAAA,SAAS,EAAEX;AAA1B,KAAyCW,KAAzC,EAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport type { Color } from \"../../../skia\";\nimport { BlendMode, Skia } from \"../../../skia\";\nimport { createDeclaration } from \"../../nodes\";\nimport type { SkEnum, AnimatedProps } from \"../../processors\";\nimport { enumKey } from \"../../processors\";\n\nimport { composeColorFilter } from \"./Compose\";\n\nexport interface BlendColorProps {\n mode: SkEnum<typeof BlendMode>;\n color: Color;\n children?: ReactNode | ReactNode[];\n}\n\nconst onDeclare = createDeclaration<BlendColorProps>(\n ({ mode, color }, children) => {\n const cf = Skia.ColorFilter.MakeBlend(\n Skia.Color(color),\n BlendMode[enumKey(mode)]\n );\n return composeColorFilter(cf, children);\n }\n);\n\nexport const BlendColor = (props: AnimatedProps<BlendColorProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n"]}
@@ -7,10 +7,12 @@ exports.MakeInnerShadow = void 0;
7
7
 
8
8
  var _skia = require("../../../skia");
9
9
 
10
+ const Black = _skia.Skia.Color("black");
11
+
10
12
  const MakeInnerShadow = (shadowOnly, dx, dy, sigmaX, sigmaY, color, input) => {
11
- const sourceGraphic = _skia.Skia.ImageFilter.MakeColorFilter(_skia.Skia.ColorFilter.MakeBlend(0xff000000, _skia.BlendMode.Dst), null);
13
+ const sourceGraphic = _skia.Skia.ImageFilter.MakeColorFilter(_skia.Skia.ColorFilter.MakeBlend(Black, _skia.BlendMode.Dst), null);
12
14
 
13
- const sourceAlpha = _skia.Skia.ImageFilter.MakeColorFilter(_skia.Skia.ColorFilter.MakeBlend(0xff000000, _skia.BlendMode.SrcIn), null);
15
+ const sourceAlpha = _skia.Skia.ImageFilter.MakeColorFilter(_skia.Skia.ColorFilter.MakeBlend(Black, _skia.BlendMode.SrcIn), null);
14
16
 
15
17
  const f1 = _skia.Skia.ImageFilter.MakeColorFilter(_skia.Skia.ColorFilter.MakeBlend(color, _skia.BlendMode.SrcOut), null);
16
18
 
@@ -1 +1 @@
1
- {"version":3,"sources":["InnerShadow.tsx"],"names":["MakeInnerShadow","shadowOnly","dx","dy","sigmaX","sigmaY","color","input","sourceGraphic","Skia","ImageFilter","MakeColorFilter","ColorFilter","MakeBlend","BlendMode","Dst","sourceAlpha","SrcIn","f1","SrcOut","f2","MakeOffset","f3","MakeBlur","TileMode","Decal","f4","MakeCompose","SrcOver"],"mappings":";;;;;;;AACA;;AAGO,MAAMA,eAAe,GAAG,CAC7BC,UAD6B,EAE7BC,EAF6B,EAG7BC,EAH6B,EAI7BC,MAJ6B,EAK7BC,MAL6B,EAM7BC,KAN6B,EAO7BC,KAP6B,KAQ1B;AACH,QAAMC,aAAa,GAAGC,WAAKC,WAAL,CAAiBC,eAAjB,CACpBF,WAAKG,WAAL,CAAiBC,SAAjB,CAA2B,UAA3B,EAAuCC,gBAAUC,GAAjD,CADoB,EAEpB,IAFoB,CAAtB;;AAIA,QAAMC,WAAW,GAAGP,WAAKC,WAAL,CAAiBC,eAAjB,CAClBF,WAAKG,WAAL,CAAiBC,SAAjB,CAA2B,UAA3B,EAAuCC,gBAAUG,KAAjD,CADkB,EAElB,IAFkB,CAApB;;AAIA,QAAMC,EAAE,GAAGT,WAAKC,WAAL,CAAiBC,eAAjB,CACTF,WAAKG,WAAL,CAAiBC,SAAjB,CAA2BP,KAA3B,EAAkCQ,gBAAUK,MAA5C,CADS,EAET,IAFS,CAAX;;AAIA,QAAMC,EAAE,GAAGX,WAAKC,WAAL,CAAiBW,UAAjB,CAA4BnB,EAA5B,EAAgCC,EAAhC,EAAoCe,EAApC,CAAX;;AACA,QAAMI,EAAE,GAAGb,WAAKC,WAAL,CAAiBa,QAAjB,CAA0BnB,MAA1B,EAAkCC,MAAlC,EAA0CmB,eAASC,KAAnD,EAA0DL,EAA1D,CAAX;;AACA,QAAMM,EAAE,GAAGjB,WAAKC,WAAL,CAAiBG,SAAjB,CAA2BC,gBAAUG,KAArC,EAA4CD,WAA5C,EAAyDM,EAAzD,CAAX;;AACA,MAAIrB,UAAJ,EAAgB;AACd,WAAOyB,EAAP;AACD;;AACD,SAAOjB,WAAKC,WAAL,CAAiBiB,WAAjB,CACLpB,KADK,EAELE,WAAKC,WAAL,CAAiBG,SAAjB,CAA2BC,gBAAUc,OAArC,EAA8CpB,aAA9C,EAA6DkB,EAA7D,CAFK,CAAP;AAID,CA/BM","sourcesContent":["import type { SkColor } from \"../../../skia\";\nimport { BlendMode, Skia, TileMode } from \"../../../skia\";\nimport type { SkImageFilter } from \"../../../skia/ImageFilter/ImageFilter\";\n\nexport const MakeInnerShadow = (\n shadowOnly: boolean | undefined,\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null\n) => {\n const sourceGraphic = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(0xff000000, BlendMode.Dst),\n null\n );\n const sourceAlpha = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(0xff000000, BlendMode.SrcIn),\n null\n );\n const f1 = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(color, BlendMode.SrcOut),\n null\n );\n const f2 = Skia.ImageFilter.MakeOffset(dx, dy, f1);\n const f3 = Skia.ImageFilter.MakeBlur(sigmaX, sigmaY, TileMode.Decal, f2);\n const f4 = Skia.ImageFilter.MakeBlend(BlendMode.SrcIn, sourceAlpha, f3);\n if (shadowOnly) {\n return f4;\n }\n return Skia.ImageFilter.MakeCompose(\n input,\n Skia.ImageFilter.MakeBlend(BlendMode.SrcOver, sourceGraphic, f4)\n );\n};\n"]}
1
+ {"version":3,"sources":["InnerShadow.tsx"],"names":["Black","Skia","Color","MakeInnerShadow","shadowOnly","dx","dy","sigmaX","sigmaY","color","input","sourceGraphic","ImageFilter","MakeColorFilter","ColorFilter","MakeBlend","BlendMode","Dst","sourceAlpha","SrcIn","f1","SrcOut","f2","MakeOffset","f3","MakeBlur","TileMode","Decal","f4","MakeCompose","SrcOver"],"mappings":";;;;;;;AACA;;AAGA,MAAMA,KAAK,GAAGC,WAA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A/BM","sourcesContent":["import type { SkColor } from \"../../../skia\";\nimport { BlendMode, Skia, TileMode } from \"../../../skia\";\nimport type { SkImageFilter } from \"../../../skia/ImageFilter/ImageFilter\";\n\nconst Black = Skia.Color(\"black\");\n\nexport const MakeInnerShadow = (\n shadowOnly: boolean | undefined,\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null\n) => {\n const sourceGraphic = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(Black, BlendMode.Dst),\n null\n );\n const sourceAlpha = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(Black, BlendMode.SrcIn),\n null\n );\n const f1 = Skia.ImageFilter.MakeColorFilter(\n Skia.ColorFilter.MakeBlend(color, BlendMode.SrcOut),\n null\n );\n const f2 = Skia.ImageFilter.MakeOffset(dx, dy, f1);\n const f3 = Skia.ImageFilter.MakeBlur(sigmaX, sigmaY, TileMode.Decal, f2);\n const f4 = Skia.ImageFilter.MakeBlend(BlendMode.SrcIn, sourceAlpha, f3);\n if (shadowOnly) {\n return f4;\n }\n return Skia.ImageFilter.MakeCompose(\n input,\n Skia.ImageFilter.MakeBlend(BlendMode.SrcOver, sourceGraphic, f4)\n );\n};\n"]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RuntimeShader = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _skia = require("../../../skia");
11
+
12
+ var _Declaration = require("../../nodes/Declaration");
13
+
14
+ var _getInput = require("./getInput");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
+
20
+ const onDeclare = (0, _Declaration.createDeclaration)((_ref, children) => {
21
+ let {
22
+ source
23
+ } = _ref;
24
+
25
+ const rtb = _skia.Skia.RuntimeShaderBuilder(source);
26
+
27
+ return _skia.Skia.ImageFilter.MakeRuntimeShader(rtb, null, (0, _getInput.getInput)(children));
28
+ });
29
+
30
+ const RuntimeShader = props => {
31
+ return /*#__PURE__*/_react.default.createElement("skDeclaration", _extends({
32
+ onDeclare: onDeclare
33
+ }, props));
34
+ };
35
+
36
+ exports.RuntimeShader = RuntimeShader;
37
+ //# sourceMappingURL=RuntimeShader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["RuntimeShader.tsx"],"names":["onDeclare","children","source","rtb","Skia","RuntimeShaderBuilder","ImageFilter","MakeRuntimeShader","RuntimeShader","props"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAIA;;;;;;AAMA,MAAMA,SAAS,GAAG,oCAChB,OAAaC,QAAb,KAA0B;AAAA,MAAzB;AAAEC,IAAAA;AAAF,GAAyB;;AACxB,QAAMC,GAAG,GAAGC,WAAKC,oBAAL,CAA0BH,MAA1B,CAAZ;;AACA,SAAOE,WAAKE,WAAL,CAAiBC,iBAAjB,CAAmCJ,GAAnC,EAAwC,IAAxC,EAA8C,wBAASF,QAAT,CAA9C,CAAP;AACD,CAJe,CAAlB;;AAOO,MAAMO,aAAa,GAAIC,KAAD,IAA8C;AACzE,sBAAO;AAAe,IAAA,SAAS,EAAET;AAA1B,KAAyCS,KAAzC,EAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\n\nimport { Skia } from \"../../../skia\";\nimport { createDeclaration } from \"../../nodes/Declaration\";\nimport type { AnimatedProps } from \"../../processors/Animations/Animations\";\nimport type { SkRuntimeEffect } from \"../../../skia/RuntimeEffect/RuntimeEffect\";\n\nimport { getInput } from \"./getInput\";\n\nexport interface RuntimeShaderProps {\n source: SkRuntimeEffect;\n}\n\nconst onDeclare = createDeclaration<RuntimeShaderProps>(\n ({ source }, children) => {\n const rtb = Skia.RuntimeShaderBuilder(source);\n return Skia.ImageFilter.MakeRuntimeShader(rtb, null, getInput(children));\n }\n);\n\nexport const RuntimeShader = (props: AnimatedProps<RuntimeShaderProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n"]}
@@ -68,4 +68,17 @@ Object.keys(_Morphology).forEach(function (key) {
68
68
  }
69
69
  });
70
70
  });
71
+
72
+ var _RuntimeShader = require("./RuntimeShader");
73
+
74
+ Object.keys(_RuntimeShader).forEach(function (key) {
75
+ if (key === "default" || key === "__esModule") return;
76
+ if (key in exports && exports[key] === _RuntimeShader[key]) return;
77
+ Object.defineProperty(exports, key, {
78
+ enumerable: true,
79
+ get: function () {
80
+ return _RuntimeShader[key];
81
+ }
82
+ });
83
+ });
71
84
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from \"./Blur\";\nexport * from \"./Offset\";\nexport * from \"./DisplacementMap\";\nexport * from \"./Shadow\";\nexport * from \"./Morphology\";\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from \"./Blur\";\nexport * from \"./Offset\";\nexport * from \"./DisplacementMap\";\nexport * from \"./Shadow\";\nexport * from \"./Morphology\";\nexport * from \"./RuntimeShader\";\n"]}
@@ -20,7 +20,7 @@ const processGradientProps = _ref => {
20
20
  ...transform
21
21
  } = _ref;
22
22
  return {
23
- colors: colors.map(color => typeof color === "string" ? _skia.Skia.Color(color) : color),
23
+ colors: colors.map(color => _skia.Skia.Color(color)),
24
24
  positions: positions !== null && positions !== void 0 ? positions : null,
25
25
  mode: _skia.TileMode[(0, _Paint.enumKey)(mode !== null && mode !== void 0 ? mode : "clamp")],
26
26
  flags,
@@ -1 +1 @@
1
- {"version":3,"sources":["Gradient.ts"],"names":["processGradientProps","colors","positions","mode","flags","transform","map","color","Skia","Color","TileMode","localMatrix"],"mappings":";;;;;;;AAAA;;AAGA;;AACA;;AAUO,MAAMA,oBAAoB,GAAG;AAAA,MAAC;AACnCC,IAAAA,MADmC;AAEnCC,IAAAA,SAFmC;AAGnCC,IAAAA,IAHmC;AAInCC,IAAAA,KAJmC;AAKnC,OAAGC;AALgC,GAAD;AAAA,SAMd;AACpBJ,IAAAA,MAAM,EAAEA,MAAM,CAACK,GAAP,CAAYC,KAAD,IACjB,OAAOA,KAAP,KAAiB,QAAjB,GAA4BC,WAAKC,KAAL,CAAWF,KAAX,CAA5B,GAAgDA,KAD1C,CADY;AAIpBL,IAAAA,SAAS,EAAEA,SAAF,aAAEA,SAAF,cAAEA,SAAF,GAAe,IAJJ;AAKpBC,IAAAA,IAAI,EAAEO,eAAS,oBAAQP,IAAR,aAAQA,IAAR,cAAQA,IAAR,GAAgB,OAAhB,CAAT,CALc;AAMpBC,IAAAA,KANoB;AAOpBO,IAAAA,WAAW,EAAE,4BAAYN,SAAZ;AAPO,GANc;AAAA,CAA7B","sourcesContent":["import { TileMode, Skia } from \"../../../skia\";\nimport type { SkEnum } from \"../../processors/Paint\";\nimport type { TransformProps } from \"../../processors/Transform\";\nimport { enumKey } from \"../../processors/Paint\";\nimport { localMatrix } from \"../../processors/Transform\";\nimport type { Color } from \"../../../skia/Color\";\n\nexport interface GradientProps extends TransformProps {\n colors: Color[];\n positions?: number[];\n mode?: SkEnum<typeof TileMode>;\n flags?: number;\n}\n\nexport const processGradientProps = ({\n colors,\n positions,\n mode,\n flags,\n ...transform\n}: GradientProps) => ({\n colors: colors.map((color) =>\n typeof color === \"string\" ? Skia.Color(color) : color\n ),\n positions: positions ?? null,\n mode: TileMode[enumKey(mode ?? \"clamp\")],\n flags,\n localMatrix: localMatrix(transform),\n});\n"]}
1
+ {"version":3,"sources":["Gradient.ts"],"names":["processGradientProps","colors","positions","mode","flags","transform","map","color","Skia","Color","TileMode","localMatrix"],"mappings":";;;;;;;AAAA;;AAGA;;AACA;;AAUO,MAAMA,oBAAoB,GAAG;AAAA,MAAC;AACnCC,IAAAA,MADmC;AAEnCC,IAAAA,SAFmC;AAGnCC,IAAAA,IAHmC;AAInCC,IAAAA,KAJmC;AAKnC,OAAGC;AALgC,GAAD;AAAA,SAMd;AACpBJ,IAAAA,MAAM,EAAEA,MAAM,CAACK,GAAP,CAAYC,KAAD,IAAWC,WAAKC,KAAL,CAAWF,KAAX,CAAtB,CADY;AAEpBL,IAAAA,SAAS,EAAEA,SAAF,aAAEA,SAAF,cAAEA,SAAF,GAAe,IAFJ;AAGpBC,IAAAA,IAAI,EAAEO,eAAS,oBAAQP,IAAR,aAAQA,IAAR,cAAQA,IAAR,GAAgB,OAAhB,CAAT,CAHc;AAIpBC,IAAAA,KAJoB;AAKpBO,IAAAA,WAAW,EAAE,4BAAYN,SAAZ;AALO,GANc;AAAA,CAA7B","sourcesContent":["import { Skia, TileMode } from \"../../../skia\";\nimport type { SkEnum } from \"../../processors/Paint\";\nimport type { TransformProps } from \"../../processors/Transform\";\nimport { enumKey } from \"../../processors/Paint\";\nimport { localMatrix } from \"../../processors/Transform\";\nimport type { Color } from \"../../../skia/Color\";\n\nexport interface GradientProps extends TransformProps {\n colors: Color[];\n positions?: number[];\n mode?: SkEnum<typeof TileMode>;\n flags?: number;\n}\n\nexport const processGradientProps = ({\n colors,\n positions,\n mode,\n flags,\n ...transform\n}: GradientProps) => ({\n colors: colors.map((color) => Skia.Color(color)),\n positions: positions ?? null,\n mode: TileMode[enumKey(mode ?? \"clamp\")],\n flags,\n localMatrix: localMatrix(transform),\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["Shader.tsx"],"names":["isVector","obj","x","undefined","y","processValue","value","onDeclare","children","uniforms","source","opaque","transform","processedUniforms","Array","getUniformCount","fill","flatMap","_","i","name","getUniformName","Error","isArray","names","Object","keys","length","usedUniforms","map","unusedUniform","indexOf","filter","n","console","warn","join","makeShaderWithChildren","isShader","Shader","props","defaultProps"],"mappings":";;;;;;;AAAA;;AAGA;;AAGA;;AACA;;;;;;AAEA,MAAMA,QAAQ,GAAIC,GAAD,IACf;AACA;AACCA,GAAD,CAAaC,CAAb,KAAmBC,SAAnB,IAAiCF,GAAD,CAAaG,CAAb,KAAmBD,SAHrD;;AAaA,MAAME,YAAY,GAAIC,KAAD,IAAqD;AACxE,MAAIN,QAAQ,CAACM,KAAD,CAAZ,EAAqB;AACnB,WAAO,CAACA,KAAK,CAACJ,CAAP,EAAUI,KAAK,CAACF,CAAhB,CAAP;AACD;;AACD,SAAOE,KAAP;AACD,CALD;;AAcA,MAAMC,SAAS,GAAG,oCAChB,OAA6CC,QAA7C,KAA0D;AAAA,MAAzD;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,MAAZ;AAAoBC,IAAAA,MAApB;AAA4B,OAAGC;AAA/B,GAAyD;AACxD,QAAMC,iBA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AC2B,sBAAP,CACLxB,iBADK,EAELF,MAFK,EAGLH,QAAQ,CAACwB,MAAT,CAAgBM,cAAhB,CAHK,EAIL,6BAAY1B,SAAZ,CAJK,CAAP;AAMD,CAtCe,CAAlB;;AAyCO,MAAM2B,MAAM,GAAIC,KAAD,IAAuC;AAC3D,sBAAO;AAAe,IAAA,SAAS,EAAEjC;AAA1B,KAAyCiC,KAAzC,EAAP;AACD,CAFM;;;AAIPD,MAAM,CAACE,YAAP,GAAsB;AACpBhC,EAAAA,QAAQ,EAAE;AADU,CAAtB","sourcesContent":["import React from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport { isShader } from \"../../../skia\";\nimport type { IRuntimeEffect } from \"../../../skia\";\nimport type { Vector, AnimatedProps, TransformProps } from \"../../processors\";\nimport { createDeclaration } from \"../../nodes/Declaration\";\nimport { localMatrix } from \"../../processors\";\n\nconst isVector = (obj: unknown): obj is Vector =>\n // We have an issue to check property existence on JSI backed instances\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (obj as any).x !== undefined && (obj as any).y !== undefined;\n\ntype UniformValue = number | Vector | readonly number[];\n\ntype Uniform = UniformValue | readonly UniformValue[];\n\ninterface Uniforms {\n [name: string]: Uniform;\n}\n\nconst processValue = (value: UniformValue): number | readonly number[] => {\n if (isVector(value)) {\n return [value.x, value.y];\n }\n return value;\n};\n\nexport interface ShaderProps extends TransformProps {\n source: IRuntimeEffect;\n uniforms: Uniforms;\n opaque?: boolean;\n children?: ReactNode | ReactNode[];\n}\n\nconst onDeclare = createDeclaration<ShaderProps>(\n ({ uniforms, source, opaque, ...transform }, children) => {\n const processedUniforms = new Array(source.getUniformCount())\n .fill(0)\n .flatMap((_, i) => {\n const name = source.getUniformName(i);\n const value = uniforms[name];\n if (value === undefined) {\n throw new Error(`No value specified for uniform ${name}`);\n }\n if (Array.isArray(value)) {\n return value.flatMap(processValue);\n }\n return processValue(value as UniformValue);\n });\n const names = Object.keys(uniforms);\n if (names.length > source.getUniformCount()) {\n const usedUniforms = new Array(source.getUniformCount())\n .fill(0)\n .map((_, i) => source.getUniformName(i));\n const unusedUniform = names\n .map((name) => {\n if (usedUniforms.indexOf(name) === -1) {\n return name;\n }\n return null;\n })\n .filter((n) => n !== null);\n console.warn(\n \"Unused uniforms were provided: \" + unusedUniform.join(\", \")\n );\n }\n return source.makeShaderWithChildren(\n processedUniforms,\n opaque,\n children.filter(isShader),\n localMatrix(transform)\n );\n }\n);\n\nexport const Shader = (props: AnimatedProps<ShaderProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n\nShader.defaultProps = {\n uniforms: [],\n};\n"]}
1
+ {"version":3,"sources":["Shader.tsx"],"names":["isVector","obj","x","undefined","y","processValue","value","onDeclare","children","uniforms","source","opaque","transform","processedUniforms","Array","getUniformCount","fill","flatMap","_","i","name","getUniformName","Error","isArray","names","Object","keys","length","usedUniforms","map","unusedUniform","indexOf","filter","n","console","warn","join","makeShaderWithChildren","isShader","Shader","props","defaultProps"],"mappings":";;;;;;;AAAA;;AAGA;;AAGA;;AACA;;;;;;AAEA,MAAMA,QAAQ,GAAIC,GAAD,IACf;AACA;AACCA,GAAD,CAAaC,CAAb,KAAmBC,SAAnB,IAAiCF,GAAD,CAAaG,CAAb,KAAmBD,SAHrD;;AAaA,MAAME,YAAY,GAAIC,KAAD,IAAqD;AACxE,MAAIN,QAAQ,CAACM,KAAD,CAAZ,EAAqB;AACnB,WAAO,CAACA,KAAK,CAACJ,CAAP,EAAUI,KAAK,CAACF,CAAhB,CAAP;AACD;;AACD,SAAOE,KAAP;AACD,CALD;;AAcA,MAAMC,SAAS,GAAG,oCAChB,OAA6CC,QAA7C,KAA0D;AAAA,MAAzD;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,MAAZ;AAAoBC,IAAAA,MAApB;AAA4B,OAAGC;AAA/B,GAAyD;AACxD,QAAMC,iBAAiB,GAAG,IAAIC,KAAJ,CAAUJ,MAAM,CAACK,eAAP,EAAV,EACvBC,IADuB,CACl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cAAhB,CAHK,EAIL,6BAAY1B,SAAZ,CAJK,CAAP;AAMD,CAtCe,CAAlB;;AAyCO,MAAM2B,MAAM,GAAIC,KAAD,IAAuC;AAC3D,sBAAO;AAAe,IAAA,SAAS,EAAEjC;AAA1B,KAAyCiC,KAAzC,EAAP;AACD,CAFM;;;AAIPD,MAAM,CAACE,YAAP,GAAsB;AACpBhC,EAAAA,QAAQ,EAAE;AADU,CAAtB","sourcesContent":["import React from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport { isShader } from \"../../../skia\";\nimport type { SkRuntimeEffect } from \"../../../skia\";\nimport type { Vector, AnimatedProps, TransformProps } from \"../../processors\";\nimport { createDeclaration } from \"../../nodes/Declaration\";\nimport { localMatrix } from \"../../processors\";\n\nconst isVector = (obj: unknown): obj is Vector =>\n // We have an issue to check property existence on JSI backed instances\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (obj as any).x !== undefined && (obj as any).y !== undefined;\n\ntype UniformValue = number | Vector | readonly number[];\n\ntype Uniform = UniformValue | readonly UniformValue[];\n\ninterface Uniforms {\n [name: string]: Uniform;\n}\n\nconst processValue = (value: UniformValue): number | readonly number[] => {\n if (isVector(value)) {\n return [value.x, value.y];\n }\n return value;\n};\n\nexport interface ShaderProps extends TransformProps {\n source: SkRuntimeEffect;\n uniforms: Uniforms;\n opaque?: boolean;\n children?: ReactNode | ReactNode[];\n}\n\nconst onDeclare = createDeclaration<ShaderProps>(\n ({ uniforms, source, opaque, ...transform }, children) => {\n const processedUniforms = new Array(source.getUniformCount())\n .fill(0)\n .flatMap((_, i) => {\n const name = source.getUniformName(i);\n const value = uniforms[name];\n if (value === undefined) {\n throw new Error(`No value specified for uniform ${name}`);\n }\n if (Array.isArray(value)) {\n return value.flatMap(processValue);\n }\n return processValue(value as UniformValue);\n });\n const names = Object.keys(uniforms);\n if (names.length > source.getUniformCount()) {\n const usedUniforms = new Array(source.getUniformCount())\n .fill(0)\n .map((_, i) => source.getUniformName(i));\n const unusedUniform = names\n .map((name) => {\n if (usedUniforms.indexOf(name) === -1) {\n return name;\n }\n return null;\n })\n .filter((n) => n !== null);\n console.warn(\n \"Unused uniforms were provided: \" + unusedUniform.join(\", \")\n );\n }\n return source.makeShaderWithChildren(\n processedUniforms,\n opaque,\n children.filter(isShader),\n localMatrix(transform)\n );\n }\n);\n\nexport const Shader = (props: AnimatedProps<ShaderProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n\nShader.defaultProps = {\n uniforms: [],\n};\n"]}
@@ -5,32 +5,22 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.topRight = exports.topLeft = exports.rrect = exports.rect = exports.processRect = exports.processRRect = exports.point = exports.isRRect = exports.center = exports.bounds = exports.bottomRight = exports.bottomLeft = void 0;
7
7
 
8
+ var _skia = require("../../skia");
9
+
8
10
  var _Vector = require("./math/Vector");
9
11
 
10
12
  var _Radius = require("./Radius");
11
13
 
12
14
  /* eslint-disable @typescript-eslint/no-explicit-any */
13
- const point = (x, y) => ({
14
- x,
15
- y
16
- });
15
+ const point = (x, y) => _skia.Skia.Point(x, y);
17
16
 
18
17
  exports.point = point;
19
18
 
20
- const rect = (x, y, width, height) => ({
21
- x,
22
- y,
23
- width,
24
- height
25
- });
19
+ const rect = (x, y, width, height) => _skia.Skia.XYWHRect(x, y, width, height);
26
20
 
27
21
  exports.rect = rect;
28
22
 
29
- const rrect = (r, rx, ry) => ({
30
- rect: r,
31
- rx,
32
- ry
33
- });
23
+ const rrect = (r, rx, ry) => _skia.Skia.RRectXY(r, rx, ry);
34
24
 
35
25
  exports.rrect = rrect;
36
26
 
@@ -1 +1 @@
1
- {"version":3,"sources":["Rects.ts"],"names":["point","x","y","rect","width","height","rrect","r","rx","ry","bounds","rects","Math","min","map","max","topLeft","isRRect","topRight","bottomLeft","bottomRight","center","isRRectCtor","def","undefined","isRectCtor","processRect","processRRect"],"mappings":";;;;;;;AAGA;;AAEA;;AALA;AAOO,MAAMA,KAAK,GAAG,C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;AACD;AACF,CAPM","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { SkRect, SkRRect } from \"../../skia\";\n\nimport { vec } from \"./math/Vector\";\nimport type { Radius } from \"./Radius\";\nimport { processRadius } from \"./Radius\";\n\nexport const point = (x: number, y: number) => ({ x, y });\n\nexport const rect = (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n});\n\nexport const rrect = (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n});\n\nexport const bounds = (rects: SkRect[]) => {\n const x = Math.min(...rects.map((r) => r.x));\n const y = Math.min(...rects.map((r) => r.y));\n const width = Math.max(...rects.map((r) => r.x + r.width));\n const height = Math.max(...rects.map((r) => r.y + r.height));\n return rect(x, y, width, height);\n};\n\nexport const topLeft = (r: SkRect | SkRRect) =>\n isRRect(r) ? vec(r.rect.x, r.rect.y) : vec(r.x, r.y);\nexport const topRight = (r: SkRect | SkRRect) =>\n isRRect(r) ? vec(r.rect.x + r.rect.width, r.rect.y) : vec(r.x + r.width, r.y);\nexport const bottomLeft = (r: SkRect | SkRRect) =>\n isRRect(r)\n ? vec(r.rect.x, r.rect.y + r.rect.height)\n : vec(r.x, r.y + r.height);\nexport const bottomRight = (r: SkRect | SkRRect) =>\n isRRect(r)\n ? vec(r.rect.x + r.rect.width, r.rect.y + r.rect.height)\n : vec(r.x + r.width, r.y + r.height);\nexport const center = (r: SkRect | SkRRect) =>\n isRRect(r)\n ? vec(r.rect.x + r.rect.width / 2, r.rect.y + r.rect.height / 2)\n : vec(r.x + r.width / 2, r.y + r.height / 2);\n\n// We have an issue to check property existence on JSI backed instances\nconst isRRectCtor = (def: RRectDef): def is RRectCtor =>\n (def as any).rect === undefined;\n// We have an issue to check property existence on JSI backed instances\nconst isRectCtor = (def: RectDef): def is RectCtor =>\n (def as any).rect === undefined;\n// We have an issue to check property existence on JSI backed instances\nexport const isRRect = (def: SkRect | SkRRect): def is SkRRect =>\n (def as any).rect !== undefined;\n\nexport interface RectCtor {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface RRectCtor extends RectCtor {\n r: Radius;\n}\n\nexport type RectDef = RectCtor | { rect: SkRect };\nexport type RRectDef = RRectCtor | { rect: SkRRect };\n\nexport const processRect = (def: RectDef) => {\n if (isRectCtor(def)) {\n return rect(def.x, def.y, def.width, def.height);\n } else {\n return def.rect;\n }\n};\n\nexport const processRRect = (def: RRectDef) => {\n if (isRRectCtor(def)) {\n const r = processRadius(def.r);\n return rrect(rect(def.x, def.y, def.width, def.height), r.x, r.y);\n } else {\n return def.rect;\n }\n};\n"]}
1
+ {"version":3,"sources":["Rects.ts"],"names":["point","x","y","Skia","Point","rect","width","height","XYWHRect","rrect","r","rx","ry","RRectXY","bounds","rects","Math","min","map","max","topLeft","isRRect","topRight","bottomLeft","bottomRight","center","isRRectCtor","def","undefined","isRectCtor","processRect","processRRect"],"mappings":";;;;;;;AAEA;;AAEA;;AAEA;;AANA;AAQO,MAAMA,KAAK,GAAG,CAACC,CAAD,EAAYC,CAAZ,KAA0BC,WAAKC,KAAL,CAAWH,CAAX,EAAcC,CAAd,CAAxC;;;;AAEA,MAAMG,IAAI,GAAG,CAACJ,CAAD,EAAYC,CAAZ,EAAuBI,KAAvB,EAAsCC,MAAtC,KAClBJ,WAAKK,QAAL,CAAcP,CAAd,EAAiBC,CAAjB,EAAoBI,KAApB,EAA2BC,MAA3B,CADK;;;;AAGA,MAAME,KAAK,GAAG,CAACC,CAAD,EAAYC,EAAZ,EAAwBC,EAAxB,KACnBT,WAAKU,OAAL,CAAaH,CAAb,EAAgBC,EAAhB,EAAoBC,EAApB,CADK;;;;AAGA,MAAME,MAAM,GAAIC,KAAD,IAAqB;AACzC,QAAMd,CAAC,GAAGe,IAAI,CAACC,GAAL,CAAS,GAAGF,KAAK,CAACG,GAAN,CAAWR,CAAD,IAAOA,CAAC,CAACT,CAAnB,CAAZ,CAAV;AACA,QAAMC,CAAC,GAAGc,IAAI,CAACC,GAAL,C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,GAAG,CAACzB,CAAZ,EAAeyB,GAAG,CAACrB,KAAnB,EAA0BqB,GAAG,CAACpB,MAA9B,CAAX;AACD,GAFD,MAEO;AACL,WAAOoB,GAAG,CAACtB,IAAX;AACD;AACF,CANM;;;;AAQA,MAAM0B,YAAY,GAAIJ,GAAD,IAAmB;AAC7C,MAAID,WAAW,CAACC,GAAD,CAAf,EAAsB;AACpB,UAAMjB,CAAC,GAAG,2BAAciB,GAAG,CAACjB,CAAlB,CAAV;AACA,WAAOD,KAAK,CAACJ,IAAI,CAACsB,GAAG,CAAC1B,CAAL,EAAQ0B,GAAG,CAACzB,CAAZ,EAAeyB,GAAG,CAACrB,KAAnB,EAA0BqB,GAAG,CAACpB,MAA9B,CAAL,EAA4CG,CAAC,CAACT,CAA9C,EAAiDS,CAAC,CAACR,CAAnD,CAAZ;AACD,GAHD,MAGO;AACL,WAAOyB,GAAG,CAACtB,IAAX;AACD;AACF,CAPM","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { SkRect, SkRRect } from \"../../skia\";\nimport { Skia } from \"../../skia\";\n\nimport { vec } from \"./math/Vector\";\nimport type { Radius } from \"./Radius\";\nimport { processRadius } from \"./Radius\";\n\nexport const point = (x: number, y: number) => Skia.Point(x, y);\n\nexport const rect = (x: number, y: number, width: number, height: number) =>\n Skia.XYWHRect(x, y, width, height);\n\nexport const rrect = (r: SkRect, rx: number, ry: number) =>\n Skia.RRectXY(r, rx, ry);\n\nexport const bounds = (rects: SkRect[]) => {\n const x = Math.min(...rects.map((r) => r.x));\n const y = Math.min(...rects.map((r) => r.y));\n const width = Math.max(...rects.map((r) => r.x + r.width));\n const height = Math.max(...rects.map((r) => r.y + r.height));\n return rect(x, y, width, height);\n};\n\nexport const topLeft = (r: SkRect | SkRRect) =>\n isRRect(r) ? vec(r.rect.x, r.rect.y) : vec(r.x, r.y);\nexport const topRight = (r: SkRect | SkRRect) =>\n isRRect(r) ? vec(r.rect.x + r.rect.width, r.rect.y) : vec(r.x + r.width, r.y);\nexport const bottomLeft = (r: SkRect | SkRRect) =>\n isRRect(r)\n ? vec(r.rect.x, r.rect.y + r.rect.height)\n : vec(r.x, r.y + r.height);\nexport const bottomRight = (r: SkRect | SkRRect) =>\n isRRect(r)\n ? vec(r.rect.x + r.rect.width, r.rect.y + r.rect.height)\n : vec(r.x + r.width, r.y + r.height);\nexport const center = (r: SkRect | SkRRect) =>\n isRRect(r)\n ? vec(r.rect.x + r.rect.width / 2, r.rect.y + r.rect.height / 2)\n : vec(r.x + r.width / 2, r.y + r.height / 2);\n\n// We have an issue to check property existence on JSI backed instances\nconst isRRectCtor = (def: RRectDef): def is RRectCtor =>\n (def as any).rect === undefined;\n// We have an issue to check property existence on JSI backed instances\nconst isRectCtor = (def: RectDef): def is RectCtor =>\n (def as any).rect === undefined;\n// We have an issue to check property existence on JSI backed instances\nexport const isRRect = (def: SkRect | SkRRect): def is SkRRect =>\n (def as any).rect !== undefined;\n\nexport interface RectCtor {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface RRectCtor extends RectCtor {\n r: Radius;\n}\n\nexport type RectDef = RectCtor | { rect: SkRect };\nexport type RRectDef = RRectCtor | { rect: SkRRect };\n\nexport const processRect = (def: RectDef) => {\n if (isRectCtor(def)) {\n return rect(def.x, def.y, def.width, def.height);\n } else {\n return def.rect;\n }\n};\n\nexport const processRRect = (def: RRectDef) => {\n if (isRRectCtor(def)) {\n const r = processRadius(def.r);\n return rrect(rect(def.x, def.y, def.width, def.height), r.x, r.y);\n } else {\n return def.rect;\n }\n};\n"]}
@@ -3,85 +3,64 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.processTransform2d = exports.matrixVecMul3 = void 0;
6
+ exports.processTransform2d = void 0;
7
7
 
8
8
  var _typeddash = require("../../typeddash");
9
9
 
10
- const identityMatrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
10
+ var _skia = require("../../../skia");
11
11
 
12
- const translateXMatrix = x => [[1, 0, x], [0, 1, 0], [0, 0, 1]];
12
+ const processTransform2d = transforms => {
13
+ const m = _skia.Skia.Matrix();
13
14
 
14
- const translateYMatrix = y => [[1, 0, 0], [0, 1, y], [0, 0, 1]];
15
+ for (const transform of transforms) {
16
+ const key = Object.keys(transform)[0];
17
+ const value = transform[key];
15
18
 
16
- const scaleMatrix = s => [[s, 0, 0], [0, s, 0], [0, 0, 1]];
19
+ if (key === "translateX") {
20
+ m.preTranslate(value, 0);
21
+ continue;
22
+ }
17
23
 
18
- const scaleXMatrix = s => [[s, 0, 0], [0, 1, 0], [0, 0, 1]];
24
+ if (key === "translateY") {
25
+ m.preTranslate(0, value);
26
+ continue;
27
+ }
19
28
 
20
- const scaleYMatrix = s => [[1, 0, 0], [0, s, 0], [0, 0, 1]];
29
+ if (key === "scale") {
30
+ m.preScale(value, value);
31
+ continue;
32
+ }
21
33
 
22
- const skewXMatrix = s => [[1, Math.tan(s), 0], [0, 1, 0], [0, 0, 1]];
34
+ if (key === "scaleX") {
35
+ m.preScale(value, 1);
36
+ continue;
37
+ }
23
38
 
24
- const skewYMatrix = s => [[1, 0, 0], [Math.tan(s), 1, 0], [0, 0, 1]];
39
+ if (key === "scaleY") {
40
+ m.preScale(1, value);
41
+ continue;
42
+ }
25
43
 
26
- const rotateZMatrix = r => [[Math.cos(r), -1 * Math.sin(r), 0], [Math.sin(r), Math.cos(r), 0], [0, 0, 1]];
44
+ if (key === "skewX") {
45
+ m.preSkew(value, 0);
46
+ continue;
47
+ }
27
48
 
28
- const dot3 = (row, col) => row[0] * col[0] + row[1] * col[1] + row[2] * col[2];
49
+ if (key === "skewY") {
50
+ m.preSkew(0, value);
51
+ continue;
52
+ }
29
53
 
30
- const multiply3 = (m1, m2) => {
31
- const col0 = [m2[0][0], m2[1][0], m2[2][0]];
32
- const col1 = [m2[0][1], m2[1][1], m2[2][1]];
33
- const col2 = [m2[0][2], m2[1][2], m2[2][2]];
34
- return [[dot3(m1[0], col0), dot3(m1[0], col1), dot3(m1[0], col2)], [dot3(m1[1], col0), dot3(m1[1], col1), dot3(m1[1], col2)], [dot3(m1[2], col0), dot3(m1[2], col1), dot3(m1[2], col2)]];
35
- };
36
-
37
- const matrixVecMul3 = (m, v) => [dot3(m[0], v), dot3(m[1], v), dot3(m[2], v)];
54
+ if (key === "rotate" || key === "rotateZ") {
55
+ m.preRotate(value * 180 / Math.PI);
56
+ continue;
57
+ }
38
58
 
39
- exports.matrixVecMul3 = matrixVecMul3;
59
+ (0, _typeddash.exhaustiveCheck)(key);
60
+ }
40
61
 
41
- const skiaMatrix3 = m => {
42
- return [m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]];
62
+ return m;
43
63
  };
44
64
 
45
- const processTransform2d = transforms => skiaMatrix3(processTransform(transforms));
46
-
47
65
  exports.processTransform2d = processTransform2d;
48
-
49
- const processTransform = transforms => transforms.reduce((acc, transform) => {
50
- const key = Object.keys(transform)[0];
51
- const value = transform[key];
52
-
53
- if (key === "translateX") {
54
- return multiply3(acc, translateXMatrix(value));
55
- }
56
-
57
- if (key === "translateY") {
58
- return multiply3(acc, translateYMatrix(value));
59
- }
60
-
61
- if (key === "scale") {
62
- return multiply3(acc, scaleMatrix(value));
63
- }
64
-
65
- if (key === "scaleX") {
66
- return multiply3(acc, scaleXMatrix(value));
67
- }
68
-
69
- if (key === "scaleY") {
70
- return multiply3(acc, scaleYMatrix(value));
71
- }
72
-
73
- if (key === "skewX") {
74
- return multiply3(acc, skewXMatrix(value));
75
- }
76
-
77
- if (key === "skewY") {
78
- return multiply3(acc, skewYMatrix(value));
79
- }
80
-
81
- if (key === "rotate" || key === "rotateZ") {
82
- return multiply3(acc, rotateZMatrix(value));
83
- }
84
-
85
- return (0, _typeddash.exhaustiveCheck)(key);
86
- }, identityMatrix);
87
66
  //# sourceMappingURL=Matrix3.js.map