diff options
Diffstat (limited to 'examples/painting/painting.qml')
-rw-r--r-- | examples/painting/painting.qml | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/examples/painting/painting.qml b/examples/painting/painting.qml index d691834..9aa8ee4 100644 --- a/examples/painting/painting.qml +++ b/examples/painting/painting.qml @@ -39,6 +39,7 @@ Rectangle { anchors.fill: parent delegate: idelegate model: model + cacheBuffer: 20 } } @@ -49,12 +50,25 @@ Rectangle { width:120 height:142 anchors.horizontalCenter: parent.horizontalCenter - Image { + Canvas { + width: 140 + height: 140 + canvasWidth:width + canvasHeight:height + color: "#222" smooth:true - width:140 fillMode: Image.PreserveAspectFit anchors.centerIn: parent - source: src + onInit: { + var ctx = getContext("2d"); + // Here we copy contents from drawing and apply drop shaddow + var img = canvas.toImage(); + ctx.shadowOffsetX = 4; + ctx.shadowOffsetY = 4; + ctx.shadowBlur = 20; + ctx.shadowColor = "red"; + ctx.drawImage(img, 25, 25, width-50, height-50); + } } ListView.onAdd:NumberAnimation{target: root; property: "opacity" ; from:0; to:1; duration:500} } @@ -94,8 +108,8 @@ Rectangle { MouseArea { anchors.fill:parent onClicked: { - var name = "canvas" + canvas.count++ +".png"; - canvas.save("examples/painting/"+name); + var name = "canvas" + (++canvas.count) +".png"; + canvas.save(name); model.append({src:name}); view.currentIndex = model.count-1 } |