Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
描述
支持动图包浆
暂不支持 GIF 波普。在动图时,我隐藏了界面上的波普按钮
实现逻辑是「拆解」-> 「渲染」-> 「组装 GIF」
运行效率:上述样例完整运行三次
这是在动图只有11帧的情况下。如果一张 GIF 有上百张图片,渲染速度堪忧。这个是一个迭代,是线性的,异步也行不通。硬伤。
或者是我太蠢了(/ω\)静态图片时,一个参数改变,图片会响应式渲染。如果要改多个参数,就需要等渲染很多遍。个人认为这个在 GIF 这种低效的模式下行不通。所以我在且仅在 GIF 时,取消了响应性渲染,改为手动了🥺。
看代码可能更好理解
关于代码格式
和
patina.js
一样,我创建了一个patina-gif.js
文件,挂载了window.patinaGIF()
到全局,专门渲染 GIF。所有的 GIF 图片将这个函数作为入口。这个文件完全不依赖于
patina.js
中定义的变量和函数(如rgb2yuv
,yuv2rgb
等),我对 GIF 的函数进行了一整个闭包。这样就不会定义出冲突的全局变量,扰乱正常patina.js
的运行。不过这么做显然有些啰嗦。因为很多函数明明是一摸一样的(比如
Convolutes
,rgb2yuv()
等)。我觉得可以模块化一下,把这些函数提出一个模块,再在patina.js
和patina-gif.js
里引入。不过那样就要大改原来代码的结构了,那就不能我说了算啦🤣。待讨论