It is currently June 26th, 2019, 2:53 pm

## Thread for help with the new Shape meter

Help with creating, editing & fixing problems with skins
Slim08
Posts: 23
Joined: October 8th, 2018, 4:38 pm

### Re: Thread for help with the new Shape meter

Here is the end result

raiguard
Posts: 631
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.
moon.gif
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
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
; 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
SolidColor=#bgColor#
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
``````
Edit: Here's what it looks like without any rotation - it works perfectly, aside from that extra line on the right...
moon2.gif
You do not have the required permissions to view the files attached to this post.
”We are pretty sure that r2922 resolves the regression in resolution caused by a reversion to a revision.” - jsmorley, 2017
balala
Rainmeter Sage
Posts: 8317
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: Thread for help with the new Shape meter

raiguard wrote:
October 14th, 2018, 2:48 am
For reference, when using the ActionTimer debug, the moon starts at new, goes to full, then back to new again.
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.
raiguard
Posts: 631
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA

### Re: Thread for help with the new Shape meter

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).
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:

Code: Select all

``````[MeterMoonShape]
Meter=Shape
; 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
X=(#contentMarginRight# - (#moonRadius# * 2) - 8)
Y=10R
DynamicVariables=1
Group=Weather``````
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.

Edit: here's the meter integrated into my weather gadget:
IMG_20181014_123025.jpg
You do not have the required permissions to view the files attached to this post.
”We are pretty sure that r2922 resolves the regression in resolution caused by a reversion to a revision.” - jsmorley, 2017
balala
Rainmeter Sage
Posts: 8317
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: Thread for help with the new Shape meter

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.
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
Posts: 631
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA

### Re: Thread for help with the new Shape meter

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?
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.

I can create a simpler sample skin for you if you wish, but that will have to wait until I get home (~3 hours).
”We are pretty sure that r2922 resolves the regression in resolution caused by a reversion to a revision.” - jsmorley, 2017
balala
Rainmeter Sage
Posts: 8317
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: Thread for help with the new Shape meter

raiguard wrote:
October 14th, 2018, 6:41 pm
I can create a simpler sample skin for you if you wish, but that will have to wait until I get home (~3 hours).
No, thanks, not needed. Knowing I find it in ModernGadgets, is all I need. I'll check it. Thanks.
balala
Rainmeter Sage
Posts: 8317
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: Thread for help with the new Shape meter

raiguard wrote:
October 14th, 2018, 6:41 pm
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.
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.
raiguard
Posts: 631
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA

### Re: Thread for help with the new Shape meter

balala wrote:
October 14th, 2018, 7:43 pm
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.
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!
”We are pretty sure that r2922 resolves the regression in resolution caused by a reversion to a revision.” - jsmorley, 2017
balala
Rainmeter Sage
Posts: 8317
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: Thread for help with the new Shape meter

raiguard wrote:
October 15th, 2018, 4:07 pm
Can you actually let me know if it works for you?
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...