It is currently March 28th, 2024, 8:16 pm

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

Post by PigAndante »

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

[Metadata]
Name=Moon Phase
Author=PigAndante
Information=Shows the moon's current phase (roughly; the numbers are handwavey)
Version=1.0
License=Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License

[Variables]
MoonDiameter=120
MoonRadius=(#MoonDiameter#/2)
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
Shape3=Ellipse #MoonRadius#,#MoonRadius#,#MoonRadius#,#MoonRadius#
; Left Portion
Shape4=Combine Shape | Intersect Shape3
; Right Portion
Shape5=Combine Shape2 | Intersect Shape3
; Contested portion
Shape6=Ellipse #MoonRadius#,#MoonRadius#,(#MoonRadius#*cos(2*PI*[MeasureMoonPhaseCompletion])),#MoonRadius# | FillColor #MiddleColor# | StrokeWidth 0
; 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.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: New shape types added to Shape Meter

Post by eclectic-tech »

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! 8-)

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

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! :great:
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New shape types added to Shape Meter

Post by jsmorley »

eclectic-tech wrote:Nice work! 8-)

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

Re: New shape types added to Shape Meter

Post by Aethrios »

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
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New shape types added to Shape Meter

Post by jsmorley »

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.
User avatar
Aethrios
Posts: 50
Joined: February 25th, 2014, 1:45 am

Re: New shape types added to Shape Meter

Post by Aethrios »

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:

Code: Select all

[Rainmeter]
Update=1000

[Metadata]
Title=Clashing Curves
Author=Aethrios

;Meters --------------------

[Background]
Meter=Image
W=200
H=200
SolidColor=0,0,0,100

[Curves]
Meter=Shape
Shape=Path CurveForm | Fill Color 250,250,120
CurveForm= 0,0 | LineTo 0,10 | CurveTo 50,10,25,100 | CurveTo 100,10,75,100 | LineTo 100,0 | ClosePath 1
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
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: New shape types added to Shape Meter

Post by eclectic-tech »

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.
User avatar
Aethrios
Posts: 50
Joined: February 25th, 2014, 1:45 am

Re: New shape types added to Shape Meter

Post by Aethrios »

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