It is currently February 25th, 2020, 12:26 am

## New shape types added to Shape Meter

Changes made during the Rainmeter 4.0 beta cycle.
PigAndante
Posts: 3
Joined: March 31st, 2015, 9:25 pm

### Re: New shape types added to Shape Meter

Made a moon phase generator with Ellipses. Because who wouldn't want a live view of the moon's current phase on their desktop?

Not too clear on the math (not a rocket scientist), so it's accurate to within... I dunno, 2%?

Code: Select all

``````[Rainmeter]
; Uncomment (with loop formula below) for fast demo
;Update=20
Update=3600

Name=Moon Phase
Author=PigAndante
Information=Shows the moon's current phase (roughly; the numbers are handwavey)
Version=1.0

[Variables]
MoonDiameter=120
BrightColor=077d9bff
DarkColor=115161ff

RightColor=#BrightColor#
MiddleColor=#DarkColor#
LeftColor=#BrightColor#

; from http://astropixels.com/ephemeris/phasescat/phases1601.html
MoonCycleLengthInSeconds=2551442.803200
; from empirical research
MoonCycleOffset=1537695

[MeasureTime]
Measure=Time
Timezone=0

[MeasureMoonPhaseCompletion]
; percentage from full moon (0.0) to full moon (1.0)
Measure=Calc
; Uncomment this formula for demo mode
;Formula=([MeasureLoop]/300)
Formula=(([MeasureTime:]-#MoonCycleOffset#)/#MoonCycleLengthInSeconds#)%1
DynamicVariables=1
; If waning, right side bright; otherwise, right side dark
IfCondition   =([MeasureMoonPhaseCompletion] < 0.5)
IfTrueAction  =[!SetVariable RightColor #DarkColor#][!SetVariable LeftColor #BrightColor#]
IfFalseAction =[!SetVariable RightColor #BrightColor#][!SetVariable LeftColor #DarkColor#]
; If crescent (25%-75%), middle section is dark; otherwise (gibbous) middle section is light
IfCondition2  =(0.25 < [MeasureMoonPhaseCompletion]) && ([MeasureMoonPhaseCompletion] < 0.75)
IfTrueAction2 =[!SetVariable MiddleColor #DarkColor#]
IfFalseAction2=[!SetVariable MiddleColor #BrightColor#]
; Optimization to get down to two shapes drawn: join the middle with the correct side of the moon
IfCondition3  =([MeasureMoonPhaseCompletion] <= 0.25) || ((0.5 <= [MeasureMoonPhaseCompletion]) && ([MeasureMoonPhaseCompletion] < 0.75))
IfTrueAction3 =[!SetVariable ShapeToUnionWith Shape4]
IfFalseAction3=[!SetVariable ShapeToUnionWith Shape5]

[MeasureLoop]
Measure=Loop
StartValue=0
EndValue=300
Increment=1

[ProgressCircle]
H=(#MoonDiameter#)
W=(#MoonDiameter#)
Meter=Shape
DynamicVariables=1
; Left side
Shape =Rectangle 0,0,#MoonRadius#,(#MoonDiameter#) | FillColor #LeftColor# | StrokeWidth 0
; Right side
Shape2=Rectangle #MoonRadius#,0,(#MoonDiameter#),(#MoonDiameter#) | FillColor #RightColor# | StrokeWidth 0
; Moon outline
; Left Portion
Shape4=Combine Shape | Intersect Shape3
; Right Portion
Shape5=Combine Shape2 | Intersect Shape3
; Contested portion
; Optimization: Join the middle with the correct side
Shape7=Combine Shape6 | Union #ShapeToUnionWith#``````
RainmeterMoonPhase.gif
You do not have the required permissions to view the files attached to this post.
eclectic-tech
Rainmeter Sage
Posts: 3762
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

### Re: New shape types added to Shape Meter

PigAndante wrote:Made a moon phase generator with Ellipses. Because who wouldn't want a live view of the moon's current phase on their desktop?
Nice work!

I had to eliminate the spaces in your IfCondition statements to make it work for me.

Code: Select all

``````[MeasureMoonPhaseCompletion]
; percentage from full moon (0.0) to full moon (1.0)
Measure=Calc
; Uncomment this formula for demo mode
;Formula=([MeasureLoop]/300)
; Comment this formula for demo mode
Formula=(([MeasureTime:]-#MoonCycleOffset#)/#MoonCycleLengthInSeconds#)%1
DynamicVariables=1
; If waning, right side bright; otherwise, right side dark
IfCondition=([MeasureMoonPhaseCompletion] < 0.5)
IfTrueAction=[!SetVariable RightColor #DarkColor#][!SetVariable LeftColor #BrightColor#]
IfFalseAction=[!SetVariable RightColor #BrightColor#][!SetVariable LeftColor #DarkColor#]
; If crescent (25%-75%), middle section is dark; otherwise (gibbous) middle section is light
IfCondition2=(0.25 < [MeasureMoonPhaseCompletion]) && ([MeasureMoonPhaseCompletion] < 0.75)
IfTrueAction2=[!SetVariable MiddleColor #DarkColor#]
IfFalseAction2=[!SetVariable MiddleColor #BrightColor#]
; Optimization to get down to two shapes drawn: join the middle with the correct side of the moon
IfCondition3=([MeasureMoonPhaseCompletion] <= 0.25) || ((0.5 <= [MeasureMoonPhaseCompletion]) && ([MeasureMoonPhaseCompletion] < 0.75))
IfTrueAction3=[!SetVariable ShapeToUnionWith Shape4]
IfFalseAction3=[!SetVariable ShapeToUnionWith Shape5]
``````
After doing that, the demo matched your posted image!

Thanks for sharing!
jsmorley
Developer
Posts: 20280
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

### Re: New shape types added to Shape Meter

eclectic-tech wrote:Nice work!

I had to eliminate the spaces in your IfCondition statements to make it work for me.
Thanks for sharing!
People who use tabs in .ini files to "line things up" should be whipped like a rented mule..
Aethrios
Posts: 50
Joined: February 25th, 2014, 1:45 am

### Re: New shape types added to Shape Meter

Any chance we'll see something like a Quadratic Bezier that allows for n sets of pairs? I understand that the path allows us to do something similar, but there are still a lot of jagged connections between sets of CurveTos (even with StrokeWidth increased, and StrokeLineJoin Round.
Minimalist Enthusiast
jsmorley
Developer
Posts: 20280
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

### Re: New shape types added to Shape Meter

Aethrios wrote:Any chance we'll see something like a Quadratic Bezier that allows for n sets of pairs? I understand that the path allows us to do something similar, but there are still a lot of jagged connections between sets of CurveTos (even with StrokeWidth increased, and StrokeLineJoin Round.
I resist the description as "jagged connections", as I don't think that is possible. If you have an example with an image and code, I'd be interested to see it.

I think what you might be describing is the fact that the "end point" of a CurveTo segment is not a "control point", but a fixed end point. Then the next CurveTo segment starts at the end point of the first. So you can get some rather "abrupt" changes of direction with two CurveTo segments. This can create more of an "angle" between the end of the first and the start of the second, rather than a smooth seamless curve. While this can be addressed by using more CurveTo segments to "smooth out" the change of direction, there may be something we can look at to do some kind of "spline" segment that might simplify this.

No promises at all, but we will look into this.
Aethrios
Posts: 50
Joined: February 25th, 2014, 1:45 am

### Re: New shape types added to Shape Meter

You're right, the connections are necessarily jagged, and you have a good grasp on what I was trying to describe. Here's an image of a simple mock-up:
ClashingCurves.png
... and code, though it is simple:
So like you described, the sharper connection between the two curves is what I'm looking to eliminate. Approaching this from a mathematical perspective, I believe what I'm trying to describe would be a polynomial regression, with the ability to specify more points than are allowed in the quadratic bezier. Ultimately, what brought me to ask about this is trying to put together an audiolevel-dependant polynomial regression, which I don't think is possible at this point (hence why I'm not including a mess of code that doesn't actually produce anything that looks pretty!).

And please don't get me wrong, that I even get the time of day is great; I don't expect anything just because I'm curious on the forums!
You do not have the required permissions to view the files attached to this post.
Minimalist Enthusiast
eclectic-tech
Rainmeter Sage
Posts: 3762
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

### Re: New shape types added to Shape Meter

Aethrios wrote:Any chance we'll see something like a Quadratic Bezier that allows for n sets of pairs? I understand that the path allows us to do something similar, but there are still a lot of jagged connections between sets of CurveTos (even with StrokeWidth increased, and StrokeLineJoin Round.
I had a similar thought when I was learning about the curve shape and ended up using 12 Bezier curve shapes driven by 24 alternating audio measures. Matching the start/end points and control points for each shape determine how jagged the transition from one curve to the next will be, and some sort of 'spline' may help.

Here's what I ended up with: WaveMusic
You do not have the required permissions to view the files attached to this post.
Aethrios
Posts: 50
Joined: February 25th, 2014, 1:45 am

### Re: New shape types added to Shape Meter

Man, that's a great skin you put together, nicely done. Totally beat me to the punch, that's awfully close to what I was trying to pull off. I'll try overlapping beziers, it was on my list of ideas but I was running into some issues with defining a filled shape, though I'm sure it'll smooth out with some polish. Thanks for sharing!
Minimalist Enthusiast