Skip to content
Snippets Groups Projects
Commit d0a1b5e6 authored by dxtwjb's avatar dxtwjb
Browse files

Update canvas if hemisphere or angle change

Request paint if either of the properties change.
Also paint the shadow the opposite way around when southern hemisphere
is set.
parent ed6f41a0
No related branches found
No related tags found
No related merge requests found
......@@ -58,24 +58,33 @@ Item {
id: shadow
width: lunaSvgItem.width
height: lunaSvgItem.height
property int hemisphere: lunaIcon.hemisphere
property int theta: lunaIcon.theta
anchors.centerIn: parent
contextType: "2d"
onHemisphereChanged: requestPaint()
onThetaChanged: requestPaint()
onPaint:
{
context.reset()
context.globalAlpha = 0.9
context.fillStyle = '#000000'
var ct = Math.cos(lunaIcon.theta/180*Math.PI)
var localtheta = (hemisphere==0) ? theta : (360 - theta)
var ct = Math.cos(localtheta/180*Math.PI)
var radius = ShadowCalcs.setup(Math.floor(shadow.height/2))
var cn = Math.floor(shadow.width/2)
// These two determine which side of the centre meridan to draw
// the two arcs enclosing the shadow area.
var terminator = (lunaIcon.theta <= 180) ? 1 : -1
var edge = (lunaIcon.theta <= 180) ? -1 : 1
var terminator = (localtheta <= 180) ? 1 : -1
var edge = (localtheta <= 180) ? -1 : 1
context.beginPath()
context.moveTo(ShadowCalcs.get(-radius) + cn, -radius + cn)
......@@ -89,7 +98,6 @@ Item {
context.closePath()
context.fill()
}
}
}
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