It is currently March 29th, 2024, 11:52 am

[Suggestion] GeometryMeter - For drawing simple geometry

Report bugs with the Rainmeter application and suggest features.
User avatar
theAzack9
Developer
Posts: 522
Joined: March 2nd, 2016, 6:23 pm

[Suggestion] GeometryMeter - For drawing simple geometry

Post by theAzack9 »

Update:

As this suggestion has been thoroughly discussed at this point, i'll update this as development continues with new features and thoughts! ;)

Props to Brian for this structure idea ;) :thumbup:

Some minor modifications might be made, but the meter will most likely look something like this:

Code: Select all

[MeterVector]
Meter=Vector
Shape=Rectangle: 0,0,200,200 | OutlineWidth: 5 | FillColor: 255,255,255 | OutlineColor: 0,0,0
Shape2=Rectangle: 10,10,80,80 | OutlineWidth: 3| FillColor: 255,0,0 | OutlineColor: 0,0,255
Shape3=CustomShape | OutlineWidth: 3| FillColor: 255,0,0 | OutlineColor: 0,0,255
Shape4=CustomShape | OutlineWidth: 10| FillColor:0,0,0 | OutlineColor: 0,0,255
CustomShape = LineTo: 20,20 | ArcTo:45,45,Xradius, Yradius | LineTo: 100,100
This meter let's you define multiple different Shapes, create your own shapes and define how the shapes interact with each other.

A shape is currently defined as either a Rectangle, Circle, Arc, Curve or Custom, and then some options that defines how the finished shape will look.

When choosing the shape, you will need to apply different options to this specific shape, this happens right after the Type is specified, example: Rectangle: X, Y, W, H or Circle: X, Y, Radius
These are dependent on the shape that is chosen.

You would then add options to define how the shape would look, this includes the fill color, outline color, the width of the outline, gradients, offset to the shape, Clip size and possibly other options too (None of the options named are certain to make it into the meter either. They are no promise, but more a goal)

The custom shape lets you refer to another option where the definition of the shape lies. Here is it possible to create any geometry possible using a command based system. You start at a specified point, lets say 0,0, and by using commands like LineTo, ArcTo and CurveTo, is it possible to draw your own custom shapes. This behaves much like drawing in real life, where if you want one continuous shape, you'll have to draw the shape without lifting the pencil.

How each of these commands will work will be specified later, as i can't really tell how they will work at this time (Even though i have a general idea, can't i claim it is possible in code)

There will also be some additional options to the meter:

All general meter options works, except MeasureName! ( If anyone could find a use for it, that'd be awesome ;) )

CombineMode, which lets you define the way Shapes will interact when overlapping. (This might be implemented as a Shape Option!)
You can look at this as a reference:

Image

There might be more options, but i either can't remember them, or i haven't found them yet ;)

I hope that this is a good and understandable description of how the meter should work, and i thought it'd be a good idea to collect it all in one place. This way we can better see how the meter could work as a whole! :)

----------------------------------------------------------------------------------------------------

Original Post:

Hey, i have another suggestion :oops:

I'll split this suggestion into two parts, function and why i think this meter is useful.

Function:

I've was researching how to do this and found this: https://msdn.microsoft.com/en-us/library/windows/desktop/ee264309(v=vs.85).aspx#render_the_path_geometries_onto_the_display

Originally thought of something like a vertex array, but i actually find the path geometry more fitting for rainmeter because it preserves most of the general meter options like SolidColor, Gradients and Padding. I'm not really certain how Measures could be tied into this, but this would be more a drawing meter tbh.

Since the path geometry works with points, have i found two ways for the meter to work. Either by using Point1=X1,Y1, Point2=X2,Y2, etc, similar to how the TransformationMatrix, padding and cropping works, and this is the way i prefer because X, Y, W and H could be used to offset the geometry inside the skin window, similarly to how the roundline meter works. If the meter exceeds the specified width or height it would work similar to the text meter, where it would basically just be cut.

The other way would be using X1=X1, Y1=Y1, X2=X2, Y2=Y2, etc, but this would require more options and would be confusing if there should be an offset if you don't use something like OffsetX and OffsetY. It'd also make it hard to limit the width of the meter, since there are never any width specified. I honestly think the first option is the best, even though it deviates somewhat from the norm of how meters currently works. (This also deviates somewhat, but looks more similar in my opinion)

It would also be possible to add a custom option to decide the type of path, since there are multiple types of geometry that could be added, examples are Bezier, Arcs and simple lines, but i'm not really certain of a good way to implement this yet. The only way i can currently think of is to make a meter only have one type, which could work.

I'll include an example of how the meter could look:

Code: Select all

[MeterGeometry]
Meter=Geometry
X=20
Y=20
W=200
H=200
Point1=111, 17
Point2=80, 32
Point3=56, 0
Point4=156, 95
Point5=190, 95
LineColor=255, 255, 255
Which would look something like this:
Image

Why i think this meter would be useful:

The way of drawing custom shapes currently is using the image meter, which doesn't really scale well. This is a way for skin creators to create custom shapes and geometry that can work on all screens, even 4k resolution without really overloading the cpu trying to load a 5-6+ mb file, which most modern computers can handle, but if a user has multiple skins or skins using DynamiVariables it'll quickly add up.

Another reason is that there are a few requests to be able to draw lines, which this will solve.

One drawback with this meter is that it is quite complex, and it might be difficult for new users to wrap their head around, but i have simplified what's actually in the meter as best i could.

There might also be more drawbacks, since i haven't tried making this meter myself, but i'm willing help and/or make myself if this is something that i know will be an accepted meter. I personally think that this meter would be a great addition to the group of current meters, but i'm looking for the opinion of others.

This shouldn't break any earlier skins, and i think it'd be a great addition to Rainmeter v 4.0 ;)

From what i can see does it support the way Rainmeter currently render the meters, so i don't think that it should be a problem to implement.

I hope that the meter doesn't create too much scepticism, but i'm looking forward to see others opinion ;)

~ theAzack9
Last edited by theAzack9 on May 19th, 2016, 6:25 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Suggestion] GeometryMeter - For drawing simple geometry

Post by jsmorley »

I don't have any issue with this in principle, although I think you might need to factor a LineWidth1, LineWidth2, etc. into things, and then some thought might have to be given then to how you reconcile the "joins" between segments.

I would think that a Solid=1 option, like we have for RoundLine, would be nice. So it can be a segmented line shape or a filled shape. Then you might want LineColor and FillColor or some such.

I also wonder how well received a "geometric shape" meter might be if it doesn't include some kind of support for "curves".
User avatar
theAzack9
Developer
Posts: 522
Joined: March 2nd, 2016, 6:23 pm

Re: [Suggestion] GeometryMeter - For drawing simple geometry

Post by theAzack9 »

jsmorley wrote:I don't have any issue with this in principle, although I think you might need to factor a LineWidth1, LineWidth2, etc. into things, and then some thought might have to be given then to how you reconcile the "joins" between segments. I also wonder how well received a "geometric shape" meter might be if it doesn't include some kind of support for "curves".
From what i understand from the article i linked in the main post is it possible to use multiple line types in one shape, so it might be possible to add another factor to the Point option. It might look something like Point1=X, Y, Type, where the type will affect the next line in the queue. (e.g from point a to point b the type in a will be the type used, while from point b to point c the type in b is the one used, but this is of course mostly speculation)

LineWidth could probably be factored in using either a separate option (this will make all lines the same width, which imho is the only one needed) or through the points the same way i described above.

The points are also automatically joined together, so it won't be possible to "jump" from one place to another, you basically have to draw the whole shape in one go or use multiple meters to draw another geometric figure.

I will probably try to make an example of the meter during the next couple of weeks (when i can find some time to work with it)
User avatar
theAzack9
Developer
Posts: 522
Joined: March 2nd, 2016, 6:23 pm

Re: [Suggestion] GeometryMeter - For drawing simple geometry

Post by theAzack9 »

jsmorley wrote:I don't have any issue with this in principle, although I think you might need to factor a LineWidth1, LineWidth2, etc. into things, and then some thought might have to be given then to how you reconcile the "joins" between segments.

I would think that a Solid=1 option, like we have for RoundLine, would be nice. So it can be a segmented line shape or a filled shape. Then you might want LineColor and FillColor or some such.

I also wonder how well received a "geometric shape" meter might be if it doesn't include some kind of support for "curves".
So, eager as i am, i of course started to create this meter, and i've already got something working ^^

Here you can see an example of how the meter works in use:

Image

With the meter code used:

Code: Select all

 
[MeasureTest]
Measure=Calc
Formula=((Counter%40)/40 * 2 * PI)
 
[MeterGeometry]
Meter=Geometry
Point1=100;(100 - 25*SIN([MeasureTest] - 1 / 4  * PI));0
Point2=200;(100 + 100*SIN([MeasureTest]));2;300;(100 - 100*SIN([MeasureTest] + 1 / 4  * PI));400;(100+ 25*SIN([MeasureTest] + 1/2  * PI))
W=800
H=200
DynamicVariables=1
SolidColor=255, 255, 255
The sad thing i found is that some types needs additional options, which i decided to add at the end of the point. I really wanted a consistent option, but this seems to be the best way as of now.
User avatar
dgrace
Developer
Posts: 265
Joined: June 28th, 2014, 8:32 am
Location: Tokyo, Japan

Re: [Suggestion] GeometryMeter - For drawing simple geometry

Post by dgrace »

I really like the idea of doing vector output for Rainmeter; I didn't realize D2D had vector support so that's pretty awesome. On the downside, the Point1, Point2 syntax is horrible. It might be better to pass the whole list through as a single string, maybe formatted in SVG, and then parse the string. (i.e. M 0 0 L 150 150 L 120 150...) SVG provides support for arcs as well as line segments, colors, fill/stroke options etc.

dave
User avatar
theAzack9
Developer
Posts: 522
Joined: March 2nd, 2016, 6:23 pm

Re: [Suggestion] GeometryMeter - For drawing simple geometry

Post by theAzack9 »

dgrace wrote:I really like the idea of doing vector output for Rainmeter; I didn't realize D2D had vector support so that's pretty awesome. On the downside, the Point1, Point2 syntax is horrible. It might be better to pass the whole list through as a single string, maybe formatted in SVG, and then parse the string. (i.e. M 0 0 L 150 150 L 120 150...) SVG provides support for arcs as well as line segments, colors, fill/stroke options etc.

dave
I like that idea, i'll look into it. I'm always open for ideas ;)
Best case is to implement the SVG format, worst case would be to make a separate Rainmeter format...
User avatar
dgrace
Developer
Posts: 265
Joined: June 28th, 2014, 8:32 am
Location: Tokyo, Japan

Re: [Suggestion] GeometryMeter - For drawing simple geometry

Post by dgrace »

theAzack9 wrote:I like that idea, i'll look into it. I'm always open for ideas ;)
Best case is to implement the SVG format, worst case would be to make a separate Rainmeter format...
By putting it all into one string you should then be able to do the work of assembling the string in Lua, and simplify the .ini code a bunch. ;)

dave
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Suggestion] GeometryMeter - For drawing simple geometry

Post by jsmorley »

I don't believe there are many folks that can hand-code SVG format into a .ini file. Please be careful we don't go off down some rabbit-hole here...

Although, SVG has a lot of potential. I'll be interested to see how we might implement it in Rainmeter'ese...

http://unicorn-ui.com/blog/svg-for-beginners.html
User avatar
dgrace
Developer
Posts: 265
Joined: June 28th, 2014, 8:32 am
Location: Tokyo, Japan

Re: [Suggestion] GeometryMeter - For drawing simple geometry

Post by dgrace »

jsmorley wrote:I don't believe there are many folks that can hand-code SVG format into a .ini file. Please be careful we don't go off down some rabbit-hole here...
It's kind of a tricky tradeoff. If you make it simple, it's useless. I figured SVG might even have an existing MSFT library to parse into D2D, but I haven't searched yet.

dave
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Suggestion] GeometryMeter - For drawing simple geometry

Post by jsmorley »

I think if we keep it pretty compliant with the standard for SVG, so they can use a tutorial / demo guide like I posted above, we might be able to do this... It might be something like:
<svg height="64" width="64">
<circle cx="32" cy="32" r="28" stroke="#2ecc71" stroke-width="4" fill="none" >
<circle cx="32" cy="32" r="20" stroke="#08BCD0" stroke-width="4" fill="none"/>
</svg>
[MeterCircle]
Meter=Vector
VectorW=64
VectorH=64
Shape1=<circle cx=32 cy=32 r=28 stroke=#2ecc71 stroke-width=4 fill=none/>
Shape2=<circle cx=32 cy=32 r=20 stroke=#08BCD0 stroke-width=4 fill=none/>

Image
<svg width="225" height="225">
<line x1="5" y1="5" x2="200" y2="200" stroke="#34495e" stroke-width="10"/>
</svg>
[MeterLine]
Meter=Vector
X=100
Y=20
SolidColor=47,47,47,255
Padding=5,5,5,5
VectorW=225
VectorH=225
Shape1=<line x1=5 y1=5 x2=200 y2=200 stroke=#34495e stroke-width=10/>

Image

And while I doubt there are many that could do it from scratch, maybe even...
<svg width="200" height="150">
<path d="M 10 75 Q 50 10 100 75 T 190 75" stroke="black"
stroke-linecap="round" stroke-dasharray="5,10,5" fill="none"/>
<path d="M 10 75 L 190 75" stroke="red"
stroke-linecap="round" stroke-width="1" stroke-dasharray="5,5" fill="none"/>
</svg>
[Meter2Graph]
Meter=Vector
VectorW=200
VectorH=150
Shape1=<path d=M 10 75 Q 50 10 100 75 T 190 75 stroke=#000000 stroke-linecap=round stroke-dasharray=5,10,5 fill=none/>
Shape2=<path d=M 10 75 L 190 75 stroke=#ff0000 stroke-linecap=round stroke-width=1 stroke-dasharray=5,5 fill=none/>

Image

I took the quotes out, but I'm not sure, we may need them to safely parse the strings.

I suspect there are things we might have to give up. ViewPort and / or ViewBox and / or Groups maybe in the context of a meter, not sure. We would also have to be careful about colors, since while having it be standard'ish SVG has some charm, the "#" character has a special meaning in Rainmeter.

Anyway, I think It needs to be a meter, and obey all the standard options and behaviors for a meter.

I certainly don't want them to HAVE to use Lua, nor to have to code some external XML file that is "loaded".