Skip to content
Snippets Groups Projects
Commit 68188cd2 authored by samuel's avatar samuel
Browse files

Extract shadow mask

parent d960da68
No related branches found
No related tags found
No related merge requests found
......@@ -104,44 +104,6 @@ Item {
}
Canvas {
id: shadow
property int theta: lunaIcon.theta
property bool showShadow: lunaIcon.showShadow
width: lunaBackground.width
height: lunaBackground.height
visible: true
anchors.centerIn: parent
contextType: "2d"
onThetaChanged: requestPaint()
onShowShadowChanged: requestPaint()
onWidthChanged: requestPaint()
onPaint: {
context.reset();
if (showShadow) {
var cosTheta = Math.cos(theta / 180 * Math.PI);
var counterclockwisep = (theta < 180);
context.globalAlpha = 0.9;
context.translate(radius, radius);
if (theta != 180) {
context.beginPath();
context.fillStyle = '#000000';
context.strokeStyle = '#000000';
context.arc(0, 0, radius, -0.5 * Math.PI, 0.5 * Math.PI, counterclockwisep);
if ((theta % 180) != 90) {
context.scale(cosTheta, 1);
context.arc(0, 0, radius, 0.5 * Math.PI, -0.5 * Math.PI, counterclockwisep);
}
context.closePath();
context.fill();
context.stroke();
}
}
}
}
Canvas {
id: markers
......@@ -223,6 +185,54 @@ Item {
}
ShaderEffectSource {
id: shadow
anchors.centerIn: parent
width: lunaBackground.width
height: lunaBackground.height
visible: false
antialiasing: false
sourceItem: Canvas {
property int theta: lunaIcon.theta
property bool showShadow: lunaIcon.showShadow
antialiasing: true
width: lunaBackground.width
height: lunaBackground.height
visible: true
anchors.centerIn: parent
contextType: "2d"
onThetaChanged: requestPaint()
onShowShadowChanged: requestPaint()
onWidthChanged: requestPaint()
onPaint: {
context.reset();
if (showShadow) {
var cosTheta = Math.cos(theta / 180 * Math.PI);
var counterclockwisep = (theta < 180);
context.globalAlpha = 0.9;
context.translate(radius, radius);
if (theta != 180) {
context.beginPath();
context.fillStyle = '#ffffff';
context.strokeStyle = '#ffffff';
context.arc(0, 0, radius, -0.5 * Math.PI, 0.5 * Math.PI, counterclockwisep);
if ((theta % 180) != 90) {
context.scale(cosTheta, 1);
context.arc(0, 0, radius, 0.5 * Math.PI, -0.5 * Math.PI, counterclockwisep);
}
context.closePath();
context.fill();
context.stroke();
}
}
}
}
}
ShaderEffectSource {
id: lunaMask
......@@ -230,6 +240,7 @@ Item {
width: lunaBackground.width
height: lunaBackground.height
visible: false
antialiasing: false
sourceItem: Shape {
opacity: 1
......@@ -264,6 +275,7 @@ Item {
property variant mask: lunaMask
property int transparent: transparentShadow
opacity: 1
rotation: latitude - 90
visible: true
antialiasing: true
......
......@@ -11,9 +11,14 @@ layout(binding = 1) uniform sampler2D source;
layout(binding = 2) uniform sampler2D shadow;
layout(binding = 3) uniform sampler2D mask;
void main() { fragColor = texture(source, qt_TexCoord0)
* texture(mask, qt_TexCoord0).a
* (1 - texture(shadow, qt_TexCoord0).a * transparent)
* qt_Opacity ;
void main() {
fragColor = vec4(
((1 - transparent)* texture(source, qt_TexCoord0) * (1- texture(shadow, qt_TexCoord0))
+ transparent * texture(source, qt_TexCoord0)).rgb,
texture(source, qt_TexCoord0).a)
* texture(mask, qt_TexCoord0).a
* (1 - texture(shadow, qt_TexCoord0).a * transparent)
* qt_Opacity ;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment