mirror of
https://github.com/lubosz/overte.git
synced 2025-04-27 07:15:30 +02:00
rounded avatar images
This commit is contained in:
parent
1ddfc87396
commit
8a8f599583
4 changed files with 81 additions and 1 deletions
interface/resources/qml/hifi/avatarapp
|
@ -18,6 +18,7 @@ Item {
|
|||
ShadowImage {
|
||||
id: avatarImage
|
||||
anchors.fill: parent
|
||||
radius: 6
|
||||
}
|
||||
|
||||
AvatarWearablesIndicator {
|
||||
|
|
34
interface/resources/qml/hifi/avatarapp/RoundImage.qml
Normal file
34
interface/resources/qml/hifi/avatarapp/RoundImage.qml
Normal file
|
@ -0,0 +1,34 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
|
||||
property alias border: borderRectangle.border
|
||||
property alias source: image.source
|
||||
property alias fillMode: image.fillMode
|
||||
property alias radius: mask.radius
|
||||
|
||||
Image {
|
||||
id: image
|
||||
anchors.fill: parent
|
||||
anchors.margins: borderRectangle.border.width
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: mask
|
||||
anchors.fill: image
|
||||
}
|
||||
|
||||
TransparencyMask {
|
||||
anchors.fill: image
|
||||
source: image
|
||||
maskSource: mask
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: borderRectangle
|
||||
anchors.fill: parent
|
||||
|
||||
radius: mask.radius
|
||||
color: "transparent"
|
||||
}
|
||||
}
|
|
@ -7,11 +7,13 @@ Item {
|
|||
property alias dropShadowRadius: shadow.radius
|
||||
property alias dropShadowHorizontalOffset: shadow.horizontalOffset
|
||||
property alias dropShadowVerticalOffset: shadow.verticalOffset
|
||||
property alias radius: image.radius
|
||||
|
||||
Image {
|
||||
RoundImage {
|
||||
id: image
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
radius: 6
|
||||
}
|
||||
|
||||
DropShadow {
|
||||
|
|
43
interface/resources/qml/hifi/avatarapp/TransparencyMask.qml
Normal file
43
interface/resources/qml/hifi/avatarapp/TransparencyMask.qml
Normal file
|
@ -0,0 +1,43 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
property alias source: sourceImage.sourceItem
|
||||
property alias maskSource: sourceMask.sourceItem
|
||||
|
||||
anchors.fill: parent
|
||||
ShaderEffectSource {
|
||||
id: sourceMask
|
||||
smooth: true
|
||||
hideSource: true
|
||||
}
|
||||
ShaderEffectSource {
|
||||
id: sourceImage
|
||||
hideSource: true
|
||||
}
|
||||
|
||||
ShaderEffect {
|
||||
id: maskEffect
|
||||
anchors.fill: parent
|
||||
|
||||
property variant source: sourceImage
|
||||
property variant mask: sourceMask
|
||||
|
||||
fragmentShader: {
|
||||
"
|
||||
varying highp vec2 qt_TexCoord0;
|
||||
uniform lowp sampler2D source;
|
||||
uniform lowp sampler2D mask;
|
||||
void main() {
|
||||
|
||||
highp vec4 maskColor = texture2D(mask, vec2(qt_TexCoord0.x, qt_TexCoord0.y));
|
||||
highp vec4 sourceColor = texture2D(source, vec2(qt_TexCoord0.x, qt_TexCoord0.y));
|
||||
|
||||
if(maskColor.a > 0.0)
|
||||
gl_FragColor = sourceColor;
|
||||
else
|
||||
gl_FragColor = maskColor;
|
||||
}
|
||||
"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue