mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-05 21:29:23 -04:00
Improve code
This commit is contained in:
parent
dcaa4c0458
commit
6190efe28e
1 changed files with 13 additions and 6 deletions
|
@ -16,15 +16,19 @@ Item
|
||||||
id: faceAvatar
|
id: faceAvatar
|
||||||
width: iconSize
|
width: iconSize
|
||||||
height: iconSize
|
height: iconSize
|
||||||
|
visible: true
|
||||||
}
|
}
|
||||||
|
|
||||||
Canvas
|
Canvas
|
||||||
{
|
{
|
||||||
id: faceCanvas
|
id: faceCanvas
|
||||||
width: iconSize
|
width: canvasSizes
|
||||||
height: iconSize
|
height: canvasSizes
|
||||||
visible: false
|
visible: false
|
||||||
|
|
||||||
|
renderStrategy: Canvas.Threaded;
|
||||||
|
renderTarget: Canvas.Image;
|
||||||
|
|
||||||
property var images
|
property var images
|
||||||
property var callback
|
property var callback
|
||||||
|
|
||||||
|
@ -37,14 +41,17 @@ Item
|
||||||
{
|
{
|
||||||
for (y = 0 ; y< nPieces ; y++)
|
for (y = 0 ; y< nPieces ; y++)
|
||||||
{
|
{
|
||||||
ctx.drawImage(images[y], 0, 0, iconSize, iconSize )
|
ctx.drawImage(images[y], 0, 0, canvasSizes, canvasSizes )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
onPainted:
|
||||||
|
{
|
||||||
if (callback)
|
if (callback)
|
||||||
{
|
{
|
||||||
var data = faceCanvas.toDataURL()
|
var data = toDataURL('image/png')
|
||||||
callback(data)
|
callback(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +66,7 @@ Item
|
||||||
property var facesPath: "/icons/faces/"
|
property var facesPath: "/icons/faces/"
|
||||||
|
|
||||||
property var iconSize: 32
|
property var iconSize: 32
|
||||||
property var canvasSize: iconSize > 32 ? 64 : 32;
|
property var canvasSizes: iconSize > 32 ? 64 : 32;
|
||||||
|
|
||||||
property var nPieces: 6
|
property var nPieces: 6
|
||||||
property var pieces: []
|
property var pieces: []
|
||||||
|
@ -77,7 +84,7 @@ Item
|
||||||
var head = gender === 'female' ? 'head' : 'hair';
|
var head = gender === 'female' ? 'head' : 'hair';
|
||||||
var pieces = ['background', 'face', head, 'mouth', 'clothes', 'eye'];
|
var pieces = ['background', 'face', head, 'mouth', 'clothes', 'eye'];
|
||||||
var num = random % total[gender][piece] + 1;
|
var num = random % total[gender][piece] + 1;
|
||||||
return facesPath+gender+canvasSize+'/'+pieces[piece]+num+'.png';
|
return facesPath+gender+canvasSizes+'/'+pieces[piece]+num+'.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
function calcDataFromFingerprint(dataHex)
|
function calcDataFromFingerprint(dataHex)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue