@shijiu/jsview-vue-samples 2.2.426-test.0 → 2.3.151-test.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 (246) hide show
  1. package/BakeViewDemo/AnimatePic.vue +1 -1
  2. package/Basic/components/text/TextDirection.vue +7 -1
  3. package/BasicFocusControl/components/BaseBlock.vue +65 -18
  4. package/BreakRender/assets/imageList.json +235 -235
  5. package/ColorSpace/App.vue +2 -2
  6. package/CoupletsTest/App.vue +1 -1
  7. package/CoupletsTest/widget/Banger/Banger.vue +3 -3
  8. package/CoupletsTest/widget/Banger/MaroonLoader.vue +5 -5
  9. package/CoupletsTest/widget/Couplets/Couplets.vue +4 -4
  10. package/CoupletsTest/widget/Fireworks/Fireworks.vue +13 -13
  11. package/CustomShader/App.vue +4 -4
  12. package/CustomShader/gaussianBlur.glsl +1 -1
  13. package/DashPath/App.vue +80 -0
  14. package/DashPath/AppForOperator.vue +33 -0
  15. package/DemoForOperator/AnimPic/AnimPic.vue +69 -0
  16. package/DemoForOperator/AnimPic/App.vue +28 -0
  17. package/DemoForOperator/Banger/App.vue +26 -0
  18. package/DemoForOperator/Banger/Banger/Banger.vue +316 -0
  19. package/DemoForOperator/Banger/Banger/Maroon.vue +123 -0
  20. package/DemoForOperator/Banger/Banger/MaroonLoader.vue +78 -0
  21. package/DemoForOperator/Banger/Banger/SpriteDeal.js +30 -0
  22. package/DemoForOperator/Blur/Blur.vue +146 -0
  23. package/DemoForOperator/Blur/BlurInOut/BlurInOut.vue +158 -0
  24. package/DemoForOperator/Blur/BlurInOut/StaticBgSlide.vue +162 -0
  25. package/DemoForOperator/Blur/BlurPopup/BlurPopup.vue +113 -0
  26. package/DemoForOperator/BookFlip/App.vue +115 -0
  27. package/DemoForOperator/BookFlip/BookFlip/FlipPage.vue +179 -0
  28. package/DemoForOperator/BookFlip/BookFlip/FlippingBook.vue +310 -0
  29. package/DemoForOperator/BookFlip/BookFlip/flip.glsl +135 -0
  30. package/DemoForOperator/BookFlip/BookPage.vue +82 -0
  31. package/DemoForOperator/Bounce/App.vue +43 -0
  32. package/DemoForOperator/Bounce/Bounce.vue +81 -0
  33. package/DemoForOperator/Bounce/FreeMoveBuilder.js +139 -0
  34. package/DemoForOperator/ChunLian/App.vue +47 -0
  35. package/DemoForOperator/ChunLian/Couplets.vue +291 -0
  36. package/DemoForOperator/ClickSpriteAnim/App.vue +130 -0
  37. package/DemoForOperator/ClickSpriteAnim/Item.vue +74 -0
  38. package/DemoForOperator/DominantColor/App.vue +187 -0
  39. package/DemoForOperator/EpisodeList/App.vue +80 -0
  40. package/DemoForOperator/EpisodeList/EpisodeList/Controller.vue +110 -0
  41. package/DemoForOperator/EpisodeList/EpisodeList/EpisodeList.vue +250 -0
  42. package/DemoForOperator/EpisodeList/GroupItem.vue +65 -0
  43. package/DemoForOperator/EpisodeList/ListItem.vue +48 -0
  44. package/DemoForOperator/Firework1/App.vue +25 -0
  45. package/DemoForOperator/Firework1/Fireworks.vue +397 -0
  46. package/DemoForOperator/Firework1/SpriteDeal.js +30 -0
  47. package/DemoForOperator/FlipPage/App.vue +75 -0
  48. package/DemoForOperator/FlipPage/FlipPage/FlipPage.vue +178 -0
  49. package/DemoForOperator/FlipPage/FlipPage/flipIn.glsl +41 -0
  50. package/DemoForOperator/FlipPage/FlipPage/flipOut.glsl +41 -0
  51. package/DemoForOperator/Focus/Alpha/AlphaFocusBox.vue +95 -0
  52. package/DemoForOperator/Focus/Alpha/AlphaPage.vue +40 -0
  53. package/DemoForOperator/Focus/Alpha/Item.vue +64 -0
  54. package/DemoForOperator/Focus/App.vue +124 -0
  55. package/DemoForOperator/Focus/CommonPageSetting.js +30 -0
  56. package/DemoForOperator/Focus/Item.vue +46 -0
  57. package/DemoForOperator/Focus/Light/Item.vue +67 -0
  58. package/DemoForOperator/Focus/Light/LightFocusBox.vue +87 -0
  59. package/DemoForOperator/Focus/Light/LightPage.vue +43 -0
  60. package/DemoForOperator/Focus/Light/utils/FrameCanvasStore.ts +68 -0
  61. package/DemoForOperator/Focus/Light/utils/RotateFrame.vue +146 -0
  62. package/DemoForOperator/Focus/Light/utils/circleHaloMask.png +0 -0
  63. package/DemoForOperator/Focus/Normal/Item.vue +64 -0
  64. package/DemoForOperator/Focus/Normal/NormalFocusBox.vue +65 -0
  65. package/DemoForOperator/Focus/Normal/NormalPage.vue +41 -0
  66. package/DemoForOperator/Focus/SwipeLight/Item.vue +73 -0
  67. package/DemoForOperator/Focus/SwipeLight/SwipeLightBox.vue +62 -0
  68. package/DemoForOperator/Focus/SwipeLight/SwipeLightPage.vue +44 -0
  69. package/DemoForOperator/FrameShadow/App.vue +193 -0
  70. package/DemoForOperator/FrameShadow/FrameShadow.vue +61 -0
  71. package/DemoForOperator/FullscreenIn/App.vue +105 -0
  72. package/DemoForOperator/FullscreenIn/FullscreenPoster.vue +56 -0
  73. package/DemoForOperator/FullscreenIn/Item.vue +50 -0
  74. package/DemoForOperator/Genie/App.vue +78 -0
  75. package/DemoForOperator/Genie/geniePakcer/Genie.vue +741 -0
  76. package/DemoForOperator/Genie/geniePakcer/genieBottom.glsl +49 -0
  77. package/DemoForOperator/Genie/geniePakcer/genieLeft.glsl +50 -0
  78. package/DemoForOperator/Genie/geniePakcer/genieRight.glsl +57 -0
  79. package/DemoForOperator/Genie/geniePakcer/genieTop.glsl +50 -0
  80. package/DemoForOperator/GrayFilter/App.vue +51 -0
  81. package/DemoForOperator/GrayFilter/GrayFilter.vue +59 -0
  82. package/DemoForOperator/Jigsaw/App.vue +45 -0
  83. package/DemoForOperator/Jigsaw/JigsawFull.vue +142 -0
  84. package/DemoForOperator/Jigsaw/JigsawSingle.vue +118 -0
  85. package/DemoForOperator/LongChatBox/App.vue +36 -0
  86. package/DemoForOperator/LongChatBox/Bubble.vue +104 -0
  87. package/DemoForOperator/LongChatBox/LongChat.vue +173 -0
  88. package/DemoForOperator/LongChatBox/TextManager.ts +147 -0
  89. package/DemoForOperator/LongChatBox/VirtualList.vue +298 -0
  90. package/DemoForOperator/LongChatBox/testData.js +51 -0
  91. package/DemoForOperator/LongChatBox/utile.js +331 -0
  92. package/DemoForOperator/Particle/App.vue +69 -0
  93. package/DemoForOperator/Particle/Drop/DropParticle.vue +208 -0
  94. package/DemoForOperator/Particle/Explode/ExplodeParticle.vue +120 -0
  95. package/DemoForOperator/PosterAnim/App.vue +125 -0
  96. package/DemoForOperator/PosterAnim/Bounce/BouncePage.vue +54 -0
  97. package/DemoForOperator/PosterAnim/Bounce/Item.vue +85 -0
  98. package/DemoForOperator/PosterAnim/Breath/BreathPage.vue +47 -0
  99. package/DemoForOperator/PosterAnim/Breath/Item.vue +58 -0
  100. package/DemoForOperator/PosterAnim/CommonPageSetting.js +30 -0
  101. package/DemoForOperator/PosterAnim/Item.vue +46 -0
  102. package/DemoForOperator/PosterAnim/PosterAnim.js +79 -0
  103. package/DemoForOperator/PosterAnim/Scale/Item.vue +72 -0
  104. package/DemoForOperator/PosterAnim/Scale/ScalePage.vue +48 -0
  105. package/DemoForOperator/PosterAnim/Shake/Item.vue +85 -0
  106. package/DemoForOperator/PosterAnim/Shake/ShakePage.vue +53 -0
  107. package/DemoForOperator/PosterOverflow/App.vue +116 -0
  108. package/DemoForOperator/PosterOverflow/Item.vue +67 -0
  109. package/DemoForOperator/PosterOverflow/PosterOverflow.vue +39 -0
  110. package/DemoForOperator/Resize/App.vue +157 -0
  111. package/DemoForOperator/Resize/Resize/Item.vue +234 -0
  112. package/DemoForOperator/Resize/Resize/Resize.vue +96 -0
  113. package/DemoForOperator/Ripple/App.vue +54 -0
  114. package/DemoForOperator/Ripple/Ripple.vue +65 -0
  115. package/DemoForOperator/ScreenShootScale/App.vue +96 -0
  116. package/DemoForOperator/ScreenShootScale/Back.vue +86 -0
  117. package/DemoForOperator/ScreenShootScale/Front.vue +133 -0
  118. package/DemoForOperator/ScreenShootScale/Item.vue +62 -0
  119. package/DemoForOperator/ScreenShootScale/ScreenShootScale.vue +109 -0
  120. package/DemoForOperator/SmoothSwiper/App.vue +50 -0
  121. package/DemoForOperator/Sound/Bounce/App.vue +56 -0
  122. package/DemoForOperator/Sound/Bounce/Bounce.vue +87 -0
  123. package/DemoForOperator/Sound/Bounce/FreeMoveBuilder.js +146 -0
  124. package/DemoForOperator/Sound/Bounce/bgmusic.mp3 +0 -0
  125. package/DemoForOperator/Sound/Bounce/coin.mp3 +0 -0
  126. package/DemoForOperator/Sound/FocusMove/App.vue +134 -0
  127. package/DemoForOperator/Sound/FocusMove/Item.vue +43 -0
  128. package/DemoForOperator/Sound/FocusMove/move.mp3 +0 -0
  129. package/DemoForOperator/Sound/Rain/App.vue +11 -0
  130. package/DemoForOperator/Sound/Rain/Raining/Rain.vue +69 -0
  131. package/DemoForOperator/Sound/Rain/Raining/RainScene.vue +118 -0
  132. package/DemoForOperator/Sound/Sound/Sound.vue +24 -0
  133. package/DemoForOperator/Sound/Sound/index.js +4 -0
  134. package/DemoForOperator/Sound/Sound/useSound.js +112 -0
  135. package/DemoForOperator/Sprite/App.vue +33 -0
  136. package/DemoForOperator/Sprite/Sprite.vue +147 -0
  137. package/DemoForOperator/Stretch/App.vue +103 -0
  138. package/DemoForOperator/Stretch/Stretch/Item.vue +192 -0
  139. package/DemoForOperator/Stretch/Stretch/Stretch.vue +218 -0
  140. package/DemoForOperator/Swiper/App.vue +101 -0
  141. package/DemoForOperator/Swiper/Item.vue +56 -0
  142. package/DemoForOperator/Swiper/ParallaxSlide.vue +164 -0
  143. package/DemoForOperator/TabContent/App.vue +89 -0
  144. package/DemoForOperator/TabContent/ContentPage.vue +66 -0
  145. package/DemoForOperator/TabContent/Item.vue +85 -0
  146. package/DemoForOperator/TabContent/PageItem.vue +40 -0
  147. package/DemoForOperator/TabContent/TabContent/CreepFocus.vue +160 -0
  148. package/DemoForOperator/TabContent/TabContent/Item.vue +63 -0
  149. package/DemoForOperator/TabContent/TabContent/TabContent.vue +184 -0
  150. package/DemoForOperator/TabContent/TabContent/TabItem.vue +368 -0
  151. package/DemoForOperator/TabContent/TabContent/TabWidget.vue +243 -0
  152. package/DemoForOperator/TabContent/TabContent/Util.js +3 -0
  153. package/DemoForOperator/TabContent/TabContent/ViewSwiper.vue +110 -0
  154. package/DemoForOperator/TabContent/testData.js +241 -0
  155. package/DemoForOperator/TabContentVertical/App.vue +104 -0
  156. package/DemoForOperator/TabContentVertical/ContentPage.vue +67 -0
  157. package/DemoForOperator/TabContentVertical/Item.vue +94 -0
  158. package/DemoForOperator/TabContentVertical/PageItem.vue +40 -0
  159. package/DemoForOperator/TabContentVertical/TabContent/CreepFocus.vue +160 -0
  160. package/DemoForOperator/TabContentVertical/TabContent/Item.vue +63 -0
  161. package/DemoForOperator/TabContentVertical/TabContent/TabContent.vue +184 -0
  162. package/DemoForOperator/TabContentVertical/TabContent/TabItem.vue +368 -0
  163. package/DemoForOperator/TabContentVertical/TabContent/TabWidget.vue +259 -0
  164. package/DemoForOperator/TabContentVertical/TabContent/Util.js +3 -0
  165. package/DemoForOperator/TabContentVertical/TabContent/ViewSwiper.vue +110 -0
  166. package/DemoForOperator/TabContentVertical/assets/children_science.png +0 -0
  167. package/DemoForOperator/TabContentVertical/assets/documentary.png +0 -0
  168. package/DemoForOperator/TabContentVertical/assets/free.png +0 -0
  169. package/DemoForOperator/TabContentVertical/assets/game.png +0 -0
  170. package/DemoForOperator/TabContentVertical/assets/home_selected.png +0 -0
  171. package/DemoForOperator/TabContentVertical/assets/movie_ticket.png +0 -0
  172. package/DemoForOperator/TabContentVertical/assets/my_account.png +0 -0
  173. package/DemoForOperator/TabContentVertical/assets/opera.png +0 -0
  174. package/DemoForOperator/TabContentVertical/assets/sports.png +0 -0
  175. package/DemoForOperator/TabContentVertical/assets/tv_drama.png +0 -0
  176. package/DemoForOperator/TabContentVertical/assets/variety_show.png +0 -0
  177. package/DemoForOperator/TabContentVertical/assets/vip.png +0 -0
  178. package/DemoForOperator/TabContentVertical/testData.js +76 -0
  179. package/DemoForOperator/Vortex/App.vue +78 -0
  180. package/DemoForOperator/Vortex/Vortex/Vortex.vue +180 -0
  181. package/DemoForOperator/Vortex/Vortex/vortexIn.glsl +38 -0
  182. package/DemoForOperator/Vortex/Vortex/vortexOut.glsl +38 -0
  183. package/DemoForOperator/index.js +6 -0
  184. package/DemoForOperator/routeList.js +259 -0
  185. package/DemoHomepage/App.vue +50 -30
  186. package/DemoHomepage/components/Dialog.vue +1 -0
  187. package/DemoHomepage/components/Item.vue +11 -0
  188. package/DemoHomepage/components/TabFrame.vue +7 -0
  189. package/DemoHomepage/router.js +178 -81
  190. package/DemoHomepage/views/Homepage.vue +7 -2
  191. package/DivMetroPerformance/data.js +3 -3
  192. package/DriftScopeTest/App.vue +1 -1
  193. package/FilterDemo/AnimatePic.vue +1 -1
  194. package/FilterDemo/VideoLayer.vue +2 -2
  195. package/FullScreenFlex/TestFrame2.vue +1 -1
  196. package/GiftRain/App.vue +12 -12
  197. package/GiftRain/components/SpriteTranslate.vue +68 -48
  198. package/HashHistory/App.vue +2 -2
  199. package/HashHistory/router.js +1 -1
  200. package/JsvPreDownloader/App.vue +4 -4
  201. package/MediaDemo/components/frames/AudioFrame.vue +1 -1
  202. package/MediaDemo/components/frames/VideoFrame.vue +1 -1
  203. package/MetroWidgetDemos/MassiveItems/ContentItem.vue +1 -1
  204. package/MetroWidgetDemos/MassiveItems/data.js +1 -1
  205. package/MetroWidgetDemos/PerformanceTest/data.js +3 -3
  206. package/MetroWidgetDemos/RefreshDemo/assets/imageList.json +235 -235
  207. package/MetroWidgetDemos/SkeletonDiagram/assets/imageList.json +235 -235
  208. package/MetroWidgetDemos/TripleWidget/App.vue +7 -1
  209. package/MetroWidgetDemos/TripleWidget/Item.vue +16 -2
  210. package/MetroWidgetDemos/TripleWidget/SWidgetItem.vue +7 -1
  211. package/MetroWidgetDemos/TripleWidget/WidgetItem.vue +8 -2
  212. package/MetroWidgetDemos/focusableItemMetroWidget/WidgetItem.vue +3 -1
  213. package/MetroWidgetDemos/routeList.js +34 -17
  214. package/Poster3d/App.vue +69 -0
  215. package/Poster3d/Poster3d.vue +92 -0
  216. package/PosterPacker/App.vue +5 -5
  217. package/PosterPacker/tools/vortexPacker/Vortex.vue +1 -1
  218. package/QrcodeDemo/App.vue +1 -1
  219. package/Ripple/App.vue +1 -1
  220. package/ScaleDownNeon/App.vue +4 -4
  221. package/SceneTransition/App.vue +2 -2
  222. package/SceneTransition/maskConfig/config2.js +12 -12
  223. package/SceneTransition/maskConfig/config3.js +14 -14
  224. package/SprayView/App.vue +96 -51
  225. package/SpringFestival/App.vue +73 -0
  226. package/SpringFestival/SpringFestivalScene/ChunLian.vue +211 -0
  227. package/SpringFestival/SpringFestivalScene/FreeMoveBuilder.js +139 -0
  228. package/SpringFestival/SpringFestivalScene/LanternAnim.js +60 -0
  229. package/SpringFestival/SpringFestivalScene/Rain.vue +137 -0
  230. package/SpringFestival/SpringFestivalScene/Scene.vue +218 -0
  231. package/SpringFestival/SpringFestivalScene/imageConfig.js +87 -0
  232. package/SpringFestival/SpringFestivalScene/index.js +1 -0
  233. package/Swiper/App.vue +28 -29
  234. package/Swiper/Item.vue +19 -0
  235. package/SwiperTest/App.vue +9 -9
  236. package/TestNativeSharedView/AckEventDefine.ts +82 -0
  237. package/TestNativeSharedView/App.vue +4 -6
  238. package/TestNativeSharedView/JsvDemoTester.js +131 -0
  239. package/TextureAnimation/App.vue +16 -6
  240. package/TextureAnimation/App3.vue +100 -0
  241. package/TextureAnimation/utils/FrameCanvasStore.ts +68 -0
  242. package/TextureAnimation/utils/RotateFrame.vue +146 -0
  243. package/TextureAnimation/utils/circleHaloMask.png +0 -0
  244. package/TombSweepingDayTest/Raining/RainScene.vue +4 -4
  245. package/ViewOpacity/App.vue +21 -2
  246. package/package.json +1 -1
@@ -0,0 +1,178 @@
1
+ <template>
2
+ <div
3
+ :style="{
4
+ left: layout.left,
5
+ top: layout.top,
6
+ }"
7
+ >
8
+ <jsv-frag-shader-view
9
+ v-if="showFbo"
10
+ :key="keyCount"
11
+ ref="shaderViewRef"
12
+ :style="{
13
+ width: layout.width,
14
+ height: layout.height,
15
+ }"
16
+ :duration="shaderSetting.duration"
17
+ :shaderStr="shaderSetting.shader"
18
+ :autoplay="true"
19
+ :textures="shaderSetting.textures"
20
+ :onEnd="onAnimEnd"
21
+ ></jsv-frag-shader-view>
22
+
23
+ <div
24
+ v-if="!showOrigin"
25
+ :style="{
26
+ width: 1,
27
+ height: 1,
28
+ overflow: 'hidden',
29
+ }"
30
+ >
31
+ <div
32
+ ref="slotRootRef"
33
+ :style="{
34
+ width: layout.width,
35
+ height: layout.height,
36
+ }"
37
+ >
38
+ <slot></slot>
39
+ </div>
40
+ </div>
41
+ <div
42
+ v-else
43
+ ref="slotRootRef"
44
+ :style="{
45
+ width: layout.width,
46
+ height: layout.height,
47
+ }"
48
+ >
49
+ <slot></slot>
50
+ </div>
51
+ </div>
52
+ </template>
53
+
54
+ <script setup>
55
+ import flipOutShader from "./flipOut.glsl?raw";
56
+ import flipInShader from "./flipIn.glsl?raw";
57
+
58
+ import { onMounted, onUnmounted, shallowRef, ref, computed } from "vue";
59
+ import {
60
+ JsvFragShaderView,
61
+ getKeyFramesGroup,
62
+ JsvTextureStoreApi,
63
+ } from "jsview";
64
+
65
+ const props = defineProps({
66
+ /**
67
+ * 布局配置对象(必填)
68
+ * @type {Object}
69
+ * @property {number} left - 组件左侧位置(单位:px)
70
+ * @property {number} top - 组件顶部位置(单位:px)
71
+ * @property {number} width - 组件宽度(单位:px)
72
+ * @property {number} height - 组件高度(单位:px)
73
+ */
74
+ layout: {
75
+ type: Object,
76
+ required: true,
77
+ },
78
+
79
+ /**
80
+ * 翻页动画持续时间(单位:秒)
81
+ * @type {number}
82
+ * @default 1
83
+ */
84
+ duration: {
85
+ type: Number,
86
+ default: 1,
87
+ },
88
+
89
+ /**
90
+ * 初始显示状态
91
+ * @type {boolean}
92
+ * @default true
93
+ * @description true表示初始显示内容,false表示初始隐藏内容
94
+ */
95
+ initShow: {
96
+ type: Boolean,
97
+ default: true,
98
+ }
99
+ });
100
+
101
+ const showOrigin = shallowRef(props.initShow);
102
+ const showFbo = shallowRef(false);
103
+ const slotRootRef = shallowRef();
104
+ const keyCount = ref(0);
105
+ const shaderViewRef = ref();
106
+ let state = props.initShow ? 1 : 0;
107
+
108
+ let shaderSetting = {
109
+ name: "flipPage",
110
+ shader: "",
111
+ uniforms: [],
112
+ textures: [
113
+ {
114
+ name: "iChannel0",
115
+ resource: "",
116
+ },
117
+ ],
118
+ duration: Math.round(props.duration * 1000),
119
+ };
120
+ let _onEnd = null;
121
+
122
+ function animOut() {
123
+ shaderSetting.shader = flipOutShader;
124
+ _onEnd = () => {
125
+ showOrigin.value = false;
126
+ };
127
+ capture();
128
+ }
129
+
130
+ function animIn() {
131
+ shaderSetting.shader = flipInShader;
132
+ _onEnd = () => {
133
+ showOrigin.value = true;
134
+ };
135
+ capture();
136
+ }
137
+
138
+ function onAnimEnd() {
139
+ showFbo.value = false;
140
+ _onEnd();
141
+ }
142
+
143
+ function capture() {
144
+ JsvTextureStoreApi.capture2Texture(
145
+ slotRootRef.value,
146
+ (textureName, autoRecycle, w, h) => {
147
+ shaderSetting.textures[0].resource = `jsvtexturestore://${textureName}`;
148
+
149
+ if (autoRecycle) {
150
+ // 已经是设置了texture的自动回收,所以不再需要主动调用 JsvTextureStoreApi.deleteTexture 来释放内存
151
+ }
152
+ showOrigin.value = false;
153
+ ++keyCount.value;
154
+ showFbo.value = true;
155
+ },
156
+ true // 自动回收, 不填也行,默认为true
157
+ );
158
+ }
159
+
160
+ defineExpose({
161
+ /**
162
+ * 切换显示/隐藏状态
163
+ * @method
164
+ * @description 触发翻页动画切换:
165
+ * - 当前显示时调用会执行翻出动画
166
+ * - 当前隐藏时调用会执行翻入动画
167
+ */
168
+ switch() {
169
+ if (state == 0) {
170
+ state = 1;
171
+ animIn();
172
+ } else {
173
+ state = 0;
174
+ animOut();
175
+ }
176
+ },
177
+ });
178
+ </script>
@@ -0,0 +1,41 @@
1
+ //https://andrewhungblog.wordpress.com/2018/04/29/page-curl-shader-breakdown/
2
+ #define pi 3.14159265359
3
+ #define radius .1
4
+
5
+ float fastAsin(float x) {
6
+ float x2 = x * x;
7
+ float x3 = x2 * x;
8
+ float x5 = x3 * x2;
9
+ float x7 = x5 * x2;
10
+ return x + (1.0 / 6.0) * x3 + (3.0 / 40.0) * x5 + (5.0 / 112.0) * x7;
11
+ }
12
+
13
+ void mainImage(out vec4 fragColor, in vec2 fragCoord) {
14
+ vec2 aspect = iResolution.xy / iResolution.y;
15
+ vec2 uv = fragCoord * aspect / iResolution.xy;
16
+ vec2 anchor = aspect;
17
+ vec2 mouse = anchor - abs(1. - iTime / iDuration) * anchor;
18
+ vec2 mouseDir = normalize(anchor - mouse);
19
+ vec2 origin = mouse - mouseDir * mouse.x / abs(mouseDir.x);
20
+ float mouseDist = length(mouse - origin);
21
+
22
+ float proj = dot(uv - origin, mouseDir);
23
+ float dist = proj - mouseDist;
24
+ vec2 linePoint = uv - dist * mouseDir;
25
+ if(dist > radius) {
26
+ fragColor = vec4(0.0, 0.0, 0.0, 0.0);
27
+ fragColor.rgb *= pow(clamp(dist - radius, 0., 1.) * 1.5, .2);
28
+ } else if(dist >= 0.) {
29
+ // map to cylinder point
30
+ float theta = fastAsin(dist / radius);
31
+ vec2 p2 = linePoint + mouseDir * (pi - theta) * radius;
32
+ vec2 p1 = linePoint + mouseDir * theta * radius;
33
+ uv = (p2.x <= aspect.x && p2.y <= aspect.y && p2.x > 0. && p2.y > 0.) ? p2 : p1;
34
+ fragColor = jsvTexture2D(iChannel0, uv / aspect);
35
+ fragColor.rgb *= pow(clamp((radius - dist) / radius, 0., 1.), .2);
36
+ } else {
37
+ vec2 p = linePoint + mouseDir * (abs(dist) + pi * radius);
38
+ uv = (p.x <= aspect.x && p.y <= aspect.y && p.x > 0. && p.y > 0.) ? p : uv;
39
+ fragColor = jsvTexture2D(iChannel0, uv / aspect);
40
+ }
41
+ }
@@ -0,0 +1,41 @@
1
+ //https://andrewhungblog.wordpress.com/2018/04/29/page-curl-shader-breakdown/
2
+ #define pi 3.14159265359
3
+ #define radius .1
4
+
5
+ float fastAsin(float x) {
6
+ float x2 = x * x;
7
+ float x3 = x2 * x;
8
+ float x5 = x3 * x2;
9
+ float x7 = x5 * x2;
10
+ return x + (1.0 / 6.0) * x3 + (3.0 / 40.0) * x5 + (5.0 / 112.0) * x7;
11
+ }
12
+
13
+ void mainImage(out vec4 fragColor, in vec2 fragCoord) {
14
+ vec2 aspect = iResolution.xy / iResolution.y;
15
+ vec2 uv = fragCoord * aspect / iResolution.xy;
16
+ vec2 anchor = aspect;
17
+ vec2 mouse = anchor - abs(iTime / iDuration) * anchor;
18
+ vec2 mouseDir = normalize(anchor - mouse);
19
+ vec2 origin = mouse - mouseDir * mouse.x / abs(mouseDir.x);
20
+ float mouseDist = length(mouse - origin);
21
+
22
+ float proj = dot(uv - origin, mouseDir);
23
+ float dist = proj - mouseDist;
24
+ vec2 linePoint = uv - dist * mouseDir;
25
+ if(dist > radius) {
26
+ fragColor = vec4(0.0, 0.0, 0.0, 0.0);
27
+ fragColor.rgb *= pow(clamp(dist - radius, 0., 1.) * 1.5, .2);
28
+ } else if(dist >= 0.) {
29
+ // map to cylinder point
30
+ float theta = fastAsin(dist / radius);
31
+ vec2 p2 = linePoint + mouseDir * (pi - theta) * radius;
32
+ vec2 p1 = linePoint + mouseDir * theta * radius;
33
+ uv = (p2.x <= aspect.x && p2.y <= aspect.y && p2.x > 0. && p2.y > 0.) ? p2 : p1;
34
+ fragColor = jsvTexture2D(iChannel0, uv / aspect);
35
+ fragColor.rgb *= pow(clamp((radius - dist) / radius, 0., 1.), .2);
36
+ } else {
37
+ vec2 p = linePoint + mouseDir * (abs(dist) + pi * radius);
38
+ uv = (p.x <= aspect.x && p.y <= aspect.y && p.x > 0. && p.y > 0.) ? p : uv;
39
+ fragColor = jsvTexture2D(iChannel0, uv / aspect);
40
+ }
41
+ }
@@ -0,0 +1,95 @@
1
+ <template>
2
+ <JsvNinePatch
3
+ :style="layout"
4
+ :imageUrl="`jsvtexturestore://${sourceId}`"
5
+ :imageWidth="sampleImageWidth"
6
+ :centerWidth="2"
7
+ :imageDspWidth="sampleImageWidth"
8
+ :borderOutset="borderWidth"
9
+ :animation="anim"
10
+ />
11
+ </template>
12
+ <script setup>
13
+ import { JsvNinePatch, JsvTextureStoreApi } from "jsview";
14
+ import { onBeforeUnmount, computed } from "vue";
15
+
16
+ const props = defineProps({
17
+ /**
18
+ * 焦点框颜色
19
+ * @type {string}
20
+ */
21
+ color: {
22
+ type: String,
23
+ },
24
+ /**
25
+ * 布局样式对象
26
+ * @type {Object}
27
+ */
28
+ layout: {
29
+ type: Object,
30
+ },
31
+ /**
32
+ * 边框宽度
33
+ * @type {number}
34
+ */
35
+ borderWidth: {
36
+ type: Number,
37
+ },
38
+ /**
39
+ * 呼吸动画周期时长(单位:秒)
40
+ * @type {number}
41
+ */
42
+ duration: {
43
+ type: Number
44
+ },
45
+ /**
46
+ * 圆角半径
47
+ * @type {number}
48
+ * @default 10
49
+ */
50
+ borderRadius: {
51
+ type: Number,
52
+ default: 10,
53
+ }
54
+ });
55
+
56
+ const anim = computed(() => {
57
+ return props.duration ? `breath ${props.duration}s infinite` : 'breath 2s infinite';
58
+ });
59
+
60
+ let canvasRef;
61
+ let circleRadius = props.borderRadius;
62
+ let sampleImageWidth = circleRadius * 2 + props.borderWidth + 2;
63
+ canvasRef = JsvTextureStoreApi.canvasTexture(
64
+ sampleImageWidth,
65
+ sampleImageWidth
66
+ ); // 创建画布
67
+
68
+ let circleLineWidth = props.borderWidth;
69
+ let customPath = canvasRef.circlePath(
70
+ Math.floor(sampleImageWidth / 2),
71
+ Math.floor(sampleImageWidth / 2),
72
+ circleRadius
73
+ ); // 创建圆环绘制路径,圆形在画布的中心点位置
74
+ canvasRef.drawColor("rgba(0,0,0,0)"); // 画布绘制半透明底色
75
+ customPath.stroke(circleLineWidth, props.color); // 以给定线宽绘制圆环
76
+ const sourceId = canvasRef.commit(); // texture和div的textureStore绑定
77
+
78
+ onBeforeUnmount(() => {
79
+ JsvTextureStoreApi.deleteTexture(sourceId);
80
+ });
81
+ </script>
82
+
83
+ <style scopped>
84
+ @keyframes breath {
85
+ 0% {
86
+ opacity: 1;
87
+ }
88
+ 50% {
89
+ opacity: 0.1;
90
+ }
91
+ 100% {
92
+ opacity: 1;
93
+ }
94
+ }
95
+ </style>
@@ -0,0 +1,40 @@
1
+ <template>
2
+ <metro-widget
3
+ name="alpha"
4
+ :left="widgetLayout.left"
5
+ :top="widgetLayout.top"
6
+ :width="widgetLayout.width"
7
+ :height="widgetLayout.height"
8
+ :provideData="provideData"
9
+ :direction="HORIZONTAL"
10
+ :measures="measures"
11
+ :onEdge="onEdge"
12
+ :padding="padding"
13
+ >
14
+ <template #renderItem="{ data, onAction }">
15
+ <item :data="data" :onAction="onAction" />
16
+ </template>
17
+ </metro-widget>
18
+ </template>
19
+
20
+ <script setup>
21
+ import { MetroWidget, HORIZONTAL } from "jsview";
22
+ import Item from "./Item.vue";
23
+ import { widgetLayout, padding, data } from "../CommonPageSetting";
24
+
25
+ const props = defineProps({
26
+ onEdge: Function
27
+ })
28
+ const provideData = () => {
29
+ return data;
30
+ };
31
+
32
+ const measures = (data) => {
33
+ return {
34
+ width: data.width,
35
+ height: data.height,
36
+ marginRight: data.marginRight,
37
+ marginBottom: data.marginBottom,
38
+ };
39
+ };
40
+ </script>
@@ -0,0 +1,64 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-08 14:52:17
4
+ * @Description: file content
5
+ -->
6
+ <script setup>
7
+ import { ref } from "vue";
8
+ import AlphaFocusBox from "./AlphaFocusBox.vue";
9
+
10
+ const props = defineProps({
11
+ data: Object,
12
+ onAction: Object,
13
+ });
14
+ const bgImage = "https://cdn.release.qcast.cn/JsViewFrameworkTester/JsViewVueSampleResources/DemoForOperator/Focus/Alpha/Item/background.png";
15
+
16
+ const focused = ref(false);
17
+
18
+ // 注册回调
19
+ const onFocus = () => {
20
+ focused.value = true;
21
+ };
22
+ const onBlur = () => {
23
+ focused.value = false;
24
+ };
25
+ const onClick = () => {};
26
+ props.onAction.register("onFocus", onFocus);
27
+ props.onAction.register("onBlur", onBlur);
28
+ props.onAction.register("onClick", onClick);
29
+ </script>
30
+
31
+ <template>
32
+ <div
33
+ :style="{
34
+ width: data.width,
35
+ height: data.height,
36
+ transition: 'transform 0.2s',
37
+ transform: focused ? 'scale3d(1.05, 1.05, 1)' : null,
38
+ }"
39
+ >
40
+ <div
41
+ :style="{
42
+ width: data.width,
43
+ height: data.height,
44
+ fontSize: 30,
45
+ color: '#FFFFFF',
46
+ backgroundImage: bgImage,
47
+ lineHeight: data.height,
48
+ textAlign: 'center',
49
+ }"
50
+ >
51
+ 明暗
52
+ </div>
53
+ <alpha-focus-box
54
+ v-if="focused"
55
+ color="#ffffff"
56
+ :layout="{
57
+ width: data.width,
58
+ height: data.height,
59
+ }"
60
+ :borderWidth="5"
61
+ :borderRadius="10"
62
+ />
63
+ </div>
64
+ </template>
@@ -0,0 +1,124 @@
1
+ <template>
2
+ <div :style="{ width: 1280, height: 720, backgroundColor: '#007788' }"></div>
3
+ <div
4
+ :style="{
5
+ left: (1280 - 600) / 2,
6
+ }"
7
+ >
8
+ <normal-page v-if="pageId == 0" :onEdge="pageOnEdge" />
9
+ <light-page v-else-if="pageId == 1" :onEdge="pageOnEdge" />
10
+ <alpha-page v-else-if="pageId == 2" :onEdge="pageOnEdge" />
11
+ <swipe-light-page v-else-if="pageId == 3" :onEdge="pageOnEdge" />
12
+ </div>
13
+
14
+ <div
15
+ :style="{
16
+ left: (1280 - 240) / 2,
17
+ top: 400,
18
+ }"
19
+ >
20
+ <metro-widget
21
+ name="btn"
22
+ :width="widgetLayout.width"
23
+ :height="widgetLayout.height"
24
+ :provideData="provideData"
25
+ :direction="HORIZONTAL"
26
+ :measures="measures"
27
+ :onEdge="onEdge"
28
+ >
29
+ <template #renderItem="{ data, onAction, query }">
30
+ <item
31
+ :data="data"
32
+ :onAction="onAction"
33
+ :onItemFocus="onItemFocus"
34
+ :query="query"
35
+ />
36
+ </template>
37
+ </metro-widget>
38
+ <div
39
+ :style="{
40
+ top: 60,
41
+ fontSize: 25,
42
+ color: '#000000',
43
+ }"
44
+ >
45
+ 切换焦点样式
46
+ </div>
47
+ </div>
48
+ </template>
49
+
50
+ <script setup>
51
+ import NormalPage from "./Normal/NormalPage.vue";
52
+ import LightPage from "./Light/LightPage.vue";
53
+ import AlphaPage from "./Alpha/AlphaPage.vue";
54
+ import SwipeLightPage from "./SwipeLight/SwipeLightPage.vue";
55
+ import Item from "./Item.vue";
56
+ import { useFocusHub, MetroWidget, HORIZONTAL, EdgeDirection } from "jsview";
57
+ import { onMounted, ref } from "vue";
58
+
59
+ const focusHub = useFocusHub();
60
+
61
+ const pageId = ref(0);
62
+
63
+ const provideData = () => {
64
+ const data = [];
65
+ for (let i = 0; i < 4; ++i) {
66
+ data.push({
67
+ width: 50,
68
+ height: 50,
69
+ marginRight: 10,
70
+ content: i,
71
+ });
72
+ }
73
+ return data;
74
+ };
75
+
76
+ const measures = (data) => {
77
+ return {
78
+ width: data.width,
79
+ height: data.height,
80
+ marginRight: data.marginRight,
81
+ marginBottom: data.marginBottom,
82
+ };
83
+ };
84
+
85
+ const pageOnEdge = (edgeInfo) => {
86
+ if (edgeInfo.direction == EdgeDirection.bottom) {
87
+ focusHub.setFocus("btn");
88
+ }
89
+ };
90
+ // callbacks
91
+ const onEdge = (edgeInfo) => {
92
+ if (edgeInfo.direction == EdgeDirection.top) {
93
+ let name = null;
94
+ switch (pageId.value) {
95
+ case 0:
96
+ name = "normal";
97
+ break;
98
+ case 1:
99
+ name = "light";
100
+ break;
101
+ case 2:
102
+ name = "alpha";
103
+ break;
104
+ case 3:
105
+ name = "swipeLight";
106
+ break;
107
+ }
108
+ focusHub.setFocus(name);
109
+ }
110
+ };
111
+ const onItemFocus = (index) => {
112
+ pageId.value = index;
113
+ };
114
+
115
+ const widgetLayout = {
116
+ width: 500,
117
+ height: 50,
118
+ };
119
+
120
+ onMounted(() => {
121
+ //组件mount后设置焦点
122
+ focusHub.setFocus("btn");
123
+ });
124
+ </script>
@@ -0,0 +1,30 @@
1
+
2
+ export const widgetLayout = {
3
+ left: 50,
4
+ top: 50,
5
+ width: 600,
6
+ height: 300,
7
+ };
8
+ export const padding = {
9
+ left: 50,
10
+ right: 50,
11
+ top: 50,
12
+ bottom: 50,
13
+ };
14
+ export const data = [
15
+ {
16
+ width: 100,
17
+ height: 200,
18
+ marginRight: 10,
19
+ },
20
+ {
21
+ width: 200,
22
+ height: 200,
23
+ marginRight: 10,
24
+ },
25
+ {
26
+ width: 100,
27
+ height: 200,
28
+ marginRight: 10,
29
+ },
30
+ ];
@@ -0,0 +1,46 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-08 14:52:17
4
+ * @Description: file content
5
+ -->
6
+ <script setup>
7
+ import { ref } from "vue";
8
+
9
+ const props = defineProps({
10
+ data: Object,
11
+ onAction: Object,
12
+ onItemFocus: Function,
13
+ query: Object,
14
+ });
15
+
16
+ const focused = ref(false);
17
+
18
+ // 注册回调
19
+ const onFocus = () => {
20
+ focused.value = true;
21
+ props.onItemFocus(props.query.index);
22
+ };
23
+ const onBlur = () => {
24
+ focused.value = false;
25
+ };
26
+ const onClick = () => {};
27
+ props.onAction.register("onFocus", onFocus);
28
+ props.onAction.register("onBlur", onBlur);
29
+ props.onAction.register("onClick", onClick);
30
+ </script>
31
+
32
+ <template>
33
+ <div
34
+ :style="{
35
+ width: data.width,
36
+ height: data.height,
37
+ fontSize: 30,
38
+ color: '#000000',
39
+ backgroundColor: focused ? '#00ff00' : '#ff000033',
40
+ lineHeight: data.height,
41
+ textAlign: 'center',
42
+ }"
43
+ >
44
+ {{ data.content }}
45
+ </div>
46
+ </template>