flip
镜像/翻转元素。
关键方法
flip( axis:'x' | 'y', transition?: ITranstion )
在 世界坐标系 中, 按轴方向 镜像/翻转元素。
transition 参数表示是否进行 动画 过渡。
ts
// 按X轴镜像元素
rect.flip('x')
// 动画过渡
rect.flip('x', true)
rect.flip('x', 2) // 过渡 2 秒归属
UI 元素
示例
按 X 轴镜像元素
ts
ts
// #通过 flip() 镜像元素 [无动画过渡 (App)]
import { App, Rect } from 'leafer-ui'
import '@leafer-in/editor' // 导入图形编辑器插件
import '@leafer-in/viewport' // 导入视口插件 (可选)
const app = new App({ view: window, editor: {} })
const rect = Rect.one({ fill: '#32cd79' })
app.tree.add(rect)
setTimeout(() => {
// 按 X 轴镜像元素
rect.flip('x')
}, 1000)按 X 轴镜像元素,有动画过渡
ts
ts
// #通过 flip() 镜像元素 [有动画过渡 (App)]
import { App, Rect } from 'leafer-ui'
import '@leafer-in/editor' // 导入图形编辑器插件
import '@leafer-in/viewport' // 导入视口插件 (可选)
import '@leafer-in/animate' // 导入动画插件
const app = new App({ view: window, editor: {} })
const rect = Rect.one({ fill: '#32cd79' })
app.tree.add(rect)
setTimeout(() => {
// 按 X 轴镜像元素
rect.flip('x', true)
}, 1000)