Giter VIP home page Giter VIP logo

Comments (4)

vitoziv avatar vitoziv commented on May 16, 2024

确实是有提供设置 frame 的设置比较方便。我重新思考了一下对 frame 的支持,你的建议提醒了我。在 videoConfiguration 里的 baseContentMode 其实会和 frame 有设置上的冲突,只有在 baseContentMode 为 custom 的时候才适合设置 frame。

所以我重构了一下 frame 的位置,ImageOverlayItem 里面不再有 frame 属性,而是在 videoConfiguration 的 baseContentMode 里设置 frame。

代码大概是这样

let frame = CGRect()
videoConfiguration.baseContentMode = .custom(frame)

这样,无论是视频还是图片都可以设置 frame 了

你可以拉最新的代码试试

from cabbage.

xuzhenhao avatar xuzhenhao commented on May 16, 2024

确实是有提供设置 frame 的设置比较方便。我重新思考了一下对 frame 的支持,你的建议提醒了我。在 videoConfiguration 里的 baseContentMode 其实会和 frame 有设置上的冲突,只有在 baseContentMode 为 custom 的时候才适合设置 frame。

所以我重构了一下 frame 的位置,ImageOverlayItem 里面不再有 frame 属性,而是在 videoConfiguration 的 baseContentMode 里设置 frame。

代码大概是这样

let frame = CGRect()
videoConfiguration.baseContentMode = .custom(frame)

这样,无论是视频还是图片都可以设置 frame 了

你可以拉最新的代码试试

给效率点赞。另外请教一个问题,目前frame的效果是和CompositionGenerator的renderSize强关联的。不知道在实际项目中,是如何处理这种问题的。如果用户导出时,选择的尺寸改变了,是遍历一遍配置,进行相应的缩放修改还是有更好的方案。
另外,我参考了videoleap的交互体验,似乎也不是很理想,像从16:9调整成1:1,不是等比例的,所有的layer就会错位,需要用户重新手动修改一遍。

from cabbage.

vitoziv avatar vitoziv commented on May 16, 2024

frame 是基于原始图像的大小进行缩放的,和 renderSize 没关系。只是 frame 的位置是基于 renderSize 的画布设置的,位置可能不是想要的。有想到可能可以引入对齐方式、anchorPoint 之类的东西,但是这种功能在 UI 上会比较复杂,现在我也还没有想到更好的方案哈。

from cabbage.

xuzhenhao avatar xuzhenhao commented on May 16, 2024

frame 是基于原始图像的大小进行缩放的,和 renderSize 没关系。只是 frame 的位置是基于 renderSize 的画布设置的,位置可能不是想要的。有想到可能可以引入对齐方式、anchorPoint 之类的东西,但是这种功能在 UI 上会比较复杂,现在我也还没有想到更好的方案哈。

感谢解答

from cabbage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.