0
我有一個Image()對象,我需要調整大小。我在canvas
中使用它fill
a shape。調整圖像對象的形狀填充KineticJS
如果我試圖改變它像image.width = 300
,它不會調整大小。如果我console.log
它,它表明只有html屬性已被更改。
有沒有辦法直接編輯Image()的大小?
我有一個Image()對象,我需要調整大小。我在canvas
中使用它fill
a shape。調整圖像對象的形狀填充KineticJS
如果我試圖改變它像image.width = 300
,它不會調整大小。如果我console.log
它,它表明只有html屬性已被更改。
有沒有辦法直接編輯Image()的大小?
您可以使用設置fill.scale
對象與您想要應用於圖像的屬性fill.scale.x
和fill.scale.y
來執行此操作。
在該示例中,可以這樣做,例如像:
var patternPentagon = new Kinetic.RegularPolygon({ x: 220, y: stage.getHeight()/2, sides: 5, radius: 70, fill: { scale: { x:0.5, y:0.5 }, image: images.darthVader, offset: [-220, -70] }, stroke: 'black', strokeWidth: 4, draggable: true
});
你可以看到本作的優秀小提琴,即圖像工作here
+1的例子。 – Gromer
非常好,謝謝。 – mreq