Here is the end result
It is currently September 20th, 2024, 12:25 pm
Thread for help with the Shape meter
-
- Posts: 23
- Joined: October 8th, 2018, 4:38 pm
-
- Posts: 660
- Joined: June 25th, 2015, 7:02 pm
- Location: The Sky, USA
Re: Thread for help with the new Shape meter
Never mind (AGAIN), as usual, asking for help helps me to figure it out. The solution ended up being to flip the second shape upside down (make it come up from the bottom instead of down from the top), then in the rotate modifier, add 180 to the angle, and set the rotation point to the middle of the background ellipse. This perfectly aligns the path shape with the background ellipse and allows me to rotate the moon to any angle I wish. I have updated the code to include the solution.
Hey all. I am taking my first real deep foray into shapes by creating a moon phase diagram. I already worked out the math necessary to convert a moon phase value (0.0 at new, 1.0 at full) into an arc radius, and applied that to a path shape on top of an ellipse. There appears to be a minor bug when the path sweep direction inverts, as you can see in the gif, an extra line appears on the bottom side.
Anyway, my question is, how do I rotate the shape without causing the problems you see in the gif? The issue is that the size of the path shape changes, so the center of rotation changes. I considered trying to combine the shapes, but that caused even more issues. Can anyone help me?
For reference, when using the ActionTimer debug, the moon starts at new, goes to full, then back to new again.
EDIT: Managed to get rid of the extra line by setting the StrokeLineJoin option to round.
Edit: Here's what it looks like without any rotation - it works perfectly, aside from that extra line on the right...
Hey all. I am taking my first real deep foray into shapes by creating a moon phase diagram. I already worked out the math necessary to convert a moon phase value (0.0 at new, 1.0 at full) into an arc radius, and applied that to a path shape on top of an ellipse. There appears to be a minor bug when the path sweep direction inverts, as you can see in the gif, an extra line appears on the bottom side.
Anyway, my question is, how do I rotate the shape without causing the problems you see in the gif? The issue is that the size of the path shape changes, so the center of rotation changes. I considered trying to combine the shapes, but that caused even more issues. Can anyone help me?
For reference, when using the ActionTimer debug, the moon starts at new, goes to full, then back to new again.
EDIT: Managed to get rid of the extra line by setting the StrokeLineJoin option to round.
Code: Select all
[Rainmeter]
MiddleMouseUpAction=[!Refresh]
AccurateText=1
[Variables]
; Moon phase value: 0.0 (new) - 0.5 (full) - 1.0 (new)
moonPhase=0
; Radius of moon shape
moonRadius=30
moonIlluminationAngle=90
moonColor=150,150,150
bgColor=15,15,15
; Converts the moon phase value into a radius value usable by the arc shape
[MeasureMoonShapePhaseCalc]
Measure=Calc
Formula=clamp(abs((#moonRadius# * 4 * ((#moonPhase# > 0.5) ? (0.5 - (#moonPhase# - 0.5)) : #moonPhase#)) - #moonRadius#),0,#moonRadius#)
DynamicVariables=1
[MeterMoonShape]
Meter=Shape
Shape=Ellipse #moonRadius#,#moonRadius#,#moonRadius#,#moonRadius# | StrokeWidth 2 | Stroke Color #moonColor# | Fill Color #moonColor#
; Shape2=Arc 0,#moonRadius#,(#moonRadius# * 2),#moonRadius#,#moonRadius#,[MeasureMoonShapePhaseCalc:],0,((#moonPhase# > 0.5) ? 1 : 0) | StrokeWidth 2 | Stroke Color #moonColor#
Shape2=Path MoonArc | StrokeWidth 2 | Stroke Color #moonColor# | Fill Color #bgColor# | Rotate (-#moonIlluminationAngle# + 180),(#moonRadius# + 1),(#moonRadius# + 1) | StrokeLineJoin Round
MoonArc=0,#moonRadius# | ArcTo (#moonRadius# * 2),#moonRadius#,#moonRadius#,[MeasureMoonShapePhaseCalc:],0,(((#moonPhase# > 0.25) && (#moonPhase# < 0.75)) ? 0 : 1) | ArcTo 0,#moonRadius#,#moonRadius#,#moonRadius#,0,1
SolidColor=#bgColor#
Padding=10,10,10,10
X=50
Y=50
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure MeasureMoonShapeActionTimer "Execute 1"]
; Temporary measure for debug purposes - animates between new moon and full moon, then back
[MeasureMoonShapeActionTimer]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Increase, 16, 100 | Wait 1000 | Repeat Increase, 16, 100 | Reset
Increase=[!SetVariable moonPhase "(#moonPhase# + 0.005)"][!UpdateMeasure MeasureMoonShapePhaseCalc][!UpdateMeter MeterMoonShape][!UpdateMeasure MeasureMoonShapeActionTimer][!Redraw]
Reset=[!SetVariable moonPhase 0][!UpdateMeasure MeasureMoonShapePhaseCalc][!UpdateMeter MeterMoonShape][!UpdateMeasure MeasureMoonShapeActionTimer][!Redraw]
DynamicVariables=1
You do not have the required permissions to view the files attached to this post.
-
- Rainmeter Sage
- Posts: 16564
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Thread for help with the new Shape meter
Actually there is a small inconsistency with the real Moon phases (at least for the northern hemisphere). When the Moon goes from the New Moon to Full Moon, the clear half is the other one than that shown by your code.
I modified a bit your code. The only modified option is the Shape2 option of the [MeterMoonShape] meter. I used the following option: Shape2=Path MoonArc | StrokeWidth 2 | Stroke Color #moonColor# | Fill Color #bgColor# | Rotate (-#moonIlluminationAngle# + 180*((#moonPhase#>=0.5)?1:0)),(#moonRadius# + 1),(#moonRadius# + 1) | StrokeLineJoin Round (see the difference in the attachement).
You do not have the required permissions to view the files attached to this post.
-
- Posts: 660
- Joined: June 25th, 2015, 7:02 pm
- Location: The Sky, USA
Re: Thread for help with the new Shape meter
Yeah, I know about that. The final version I posted here wasn't the actual final form of the meter. Here is the final code:balala wrote: ↑October 14th, 2018, 6:06 pm Actually there is a small inconsistency with the real Moon phases (at least for the northern hemisphere). When the Moon goes from the New Moon to Full Moon, the clear half is the other one than that shown by your code.
I modified a bit your code. The only modified option is the Shape2 option of the [MeterMoonShape] meter. I used the following option: Shape2=Path MoonArc | StrokeWidth 2 | Stroke Color #moonColor# | Fill Color #bgColor# | Rotate (-#moonIlluminationAngle# + 180*((#moonPhase#>=0.5)?1:0)),(#moonRadius# + 1),(#moonRadius# + 1) | StrokeLineJoin Round (see the difference in the attachement).
Code: Select all
[MeterMoonShape]
Meter=Shape
Shape=Ellipse #moonRadius#,#moonRadius#,#moonRadius#,#moonRadius# | StrokeWidth 2 | Stroke Color #colorMoon# | Fill Color #colorMoon#
; Shape2=Arc 0,#moonRadius#,(#moonRadius# * 2),#moonRadius#,#moonRadius#,[MeasureMoonShapePhaseCalc:],0,(([&MeasureSunCalcScript:GetData('moonPhase')] > 0.5) ? 1 : 0) | StrokeWidth 2 | Stroke Color #colorMoon#
Shape2=Path MoonArc | StrokeWidth 2 | Stroke Color #colorMoon# | Fill Color #colorBg# | Rotate ((#showMoonAngle# = 1) ? (-[&MeasureSunCalcScript:GetData('moonViewAngle')] + 180) : (([&MeasureSunCalcScript:GetData('moonPhase')] > 0.5) ? 90 : -90)),(#moonRadius# + 1),(#moonRadius# + 1) | StrokeLineJoin Round
MoonArc=0,#moonRadius# | ArcTo (#moonRadius# * 2),#moonRadius#,#moonRadius#,[MeasureMoonShapePhaseCalc:],0,((([&MeasureSunCalcScript:GetData('moonPhase')] > 0.25) && ([&MeasureSunCalcScript:GetData('moonPhase')] < 0.75)) ? 0 : 1) | ArcTo 0,#moonRadius#,#moonRadius#,#moonRadius#,0,1
X=(#contentMarginRight# - (#moonRadius# * 2) - 8)
Y=10R
DynamicVariables=1
Group=Weather
Edit: here's the meter integrated into my weather gadget:
You do not have the required permissions to view the files attached to this post.
-
- Rainmeter Sage
- Posts: 16564
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Thread for help with the new Shape meter
This would be great! Could you please post the whole updated code AND the .lua code, too? Or even better, please pack the Config and upload it. If the Moon shown in the skin is rotated accordingly to the real one, the phase would be shown properly even in the southern hemisphere, I suppose. But the geographical coordinates would be needed in this case, right?raiguard wrote: ↑October 14th, 2018, 6:28 pm The moon simply points in the other direction when the phase is waning. In addition, it supports my SunCalc script's parallactic angle calculation, meaning that the moon icon can point in the same direction that the moon would be facing if you were to step outside and look at it IRL.
-
- Posts: 660
- Joined: June 25th, 2015, 7:02 pm
- Location: The Sky, USA
Re: Thread for help with the new Shape meter
Yeah, it's all very complicated. If you want to check it out in its full glory, you'll have to download the master branch of my ModernGadgets repository on GitHub. It's in weather meter, and the script in question is SunCalc.lua. I haven't been able to really test the script yet so it might not work correctly in all cases.balala wrote: ↑October 14th, 2018, 6:37 pm This would be great! Could you please post the whole updated code AND the .lua code, too? Or even better, please pack the Config and upload it. If the Moon shown in the skin is rotated accordingly to the real one, the phase would be shown properly even in the southern hemisphere, I suppose. But the geographical coordinates would be needed in this case, right?
I can create a simpler sample skin for you if you wish, but that will have to wait until I get home (~3 hours).
-
- Rainmeter Sage
- Posts: 16564
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Thread for help with the new Shape meter
No, thanks, not needed. Knowing I find it in ModernGadgets, is all I need. I'll check it. Thanks.
-
- Rainmeter Sage
- Posts: 16564
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Thread for help with the new Shape meter
Thank you raiguard, I just downloaded the ModernGadgets (again) and started to check how does it work, especially the Moon icon. I hope it does well.
-
- Posts: 660
- Joined: June 25th, 2015, 7:02 pm
- Location: The Sky, USA
Re: Thread for help with the new Shape meter
Can you actually let me know if it works for you? There are issues with the moon icon and sky dial when I give it any coordinates that are outside my timezone. I just want to be sure that it's not specifically tied to MY timezone, rather than the one that the computer is in. Thanks in advance!
-
- Rainmeter Sage
- Posts: 16564
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Thread for help with the new Shape meter
Yes, sure, but had no time today to take a deeper look. Unfortunately today I had a "full" day. I will check it tomorrow and will come back with an answer. Sorry...