首页 > 解决方案 > Paperjs group.pivot 未设置为新坐标

问题描述

我正在尝试将包含光栅图像的组的轴心点设置为屏幕中心,但无济于事。

请在此处查看我当前的代码:condesandbox 示例

任何帮助都感激不尽

标签: javascriptpaperjs

解决方案


根据您的代码示例,我猜您只需将栅格的位置设置为视图中心,默认情况下其轴心点将自动相同。
这是一个演示可能解决方案的草图。

// Create the raster.
const raster = new Raster({
    source: 'http://assets.paperjs.org/images/marilyn.jpg',
    // When image is loaded...
    onLoad: () => {
        // ...place it at center.
        raster.position = view.center;
    }
});

// Include raster in a group.
const group = new Group(raster);

// Mark center with a circle.
new Path.Circle({
    center: view.center,
    radius: 10,
    fillColor: 'blue'
});

// Scale the group (the pivot point is bounds center by default).
group.scale(0.5);

推荐阅读