import QtQuick 2.0 //import QtQuick.Controls 1.1 //import QtQuick.Window 2.0 //import QtQuick.Controls.Styles 1.1 //import QtGraphicalEffects 1.0 Item { id:mainRect //ADD #137061,#137063,#125817 2016/12/15 begin property string source: "" property string oldSource: "" //ADD #137061,#137063,#125817 2016/12/15 end property color color: "black" property int border: 2 Canvas { id: canvas width: parent.width; height: parent.height property real hue: 0.0 onPaint: { var ctx = getContext("2d") ctx.lineWidth = border //ADD #137061,#137063,#125817 2016/12/15 begin if("" != oldSource) { unloadImage(oldSource); } oldSource = source; //ADD [2016-12-20] #137682 yx begin ctx.clearRect(0,0,canvas.width,canvas.height); //ADD [2016-12-20] #137682 yx end //ADD #137061,#137063,#125817 2016/12/15 end ctx.save() ctx.strokeStyle = color; ctx.beginPath() ctx.arc(mainRect.width/2, mainRect.height/2, mainRect.width/2, 0, Math.PI * 2, true); ctx.closePath() ctx.clip() ctx.drawImage(source, 0, 0,canvas.width,canvas.height) ctx.closePath() ctx.stroke() ctx.restore() } onImageLoaded: { mainRect.repaintUI(); } } function repaintUI() { canvas.requestPaint(); } }