1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
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();
}
}
|