任何设置像素的例子?

Any setpixel example?

我正在尝试了解如何使用 PaperJS 代码及其文档中存在但不起作用的 setpixel 方法。

这里是 Sketch example.

此方法用于栅格实例。
摘自 documentation, here is a sketch 演示它的作用。

const width = 100;
const height = 100;

// Create an empty raster placed at view center.
const raster = new Raster(new Size(width, height));
raster.smoothing = false;

// For all of its pixels...
for (let i = 0; i < width; i++) {
    for (let j = 0; j < height; j++) {
        // ...set a random color.
        raster.setPixel(i, j, Color.random());
    }
}

project.activeLayer.fitBounds(view.bounds.scale(0.8));