It is currently April 26th, 2024, 6:54 pm

Help creating new type of Meter

Get help with creating, editing & fixing problems with skins
User avatar
TweaknFreak
Posts: 217
Joined: July 14th, 2012, 7:26 am

Help creating new type of Meter

Post by TweaknFreak »

This kind of graph is seen almost in every Sci-Fi movies. Now while giving it a thought, I noticed that only the dots act as separate Line like meters which only move vertically to display the value. The line joining the two consecutive dots adjusts its coordinates accordingly to join both of them.

See the image below which has coordinates. Now when the thing updates only the dots translate vertically and the line coordinates follow them. Suppose Dot 2 moves up by 12 pixels, then value of y2 should become y2+10. x2 remains the same.

This is where the trouble began. I cant seem to figure out how to draw those lines joining them and changing their coordinates. I'm pretty sure no normal meters are capable of doing that. Any input in that respect is highly appreciated. :)
You do not have the required permissions to view the files attached to this post.
Be one of the iNEViTABLES - Storm, Earthquake, Lightning, Flood - and the world will bow down to you.

My current desktop
[hsimg]http://i1313.photobucket.com/albums/t559/TweaknFreak/6-22-20149-46-40PM_zps7bcbc1f6.png[/hsimg]
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help creating new type of Meter

Post by jsmorley »

It would be mostly math. I wouldn't touch it with a ten-foot-pole myself, but I suspect you will need to set the X/Y coordinates of the dots based on the measure value(s), then calculate a number of radians (or at least an angle) from one to the other in the Y plane. Then either use Image meters with SolidColor and some nightmarish TransformationMatrix, or Image meters with an image file set with W and ImageRotate. The ImageRotate will impact the W of course. Just keeping track of 5 or 6 historical values for measures will take some work.

You are going to have to REALLY want this, as it won't be trivial.
User avatar
TweaknFreak
Posts: 217
Joined: July 14th, 2012, 7:26 am

Re: Help creating new type of Meter

Post by TweaknFreak »

jsmorley wrote:Image meters with an image file set with W and ImageRotate.
Seems to be the least troublesome of all.
jsmorley wrote:The ImageRotate will impact the W of course.
Thanks for the note, will keep that in mind.
jsmorley wrote:You are going to have to REALLY want this, as it won't be trivial.
I want it really bad.

And above all special thanks for this blazing fast reply. Image
Be one of the iNEViTABLES - Storm, Earthquake, Lightning, Flood - and the world will bow down to you.

My current desktop
[hsimg]http://i1313.photobucket.com/albums/t559/TweaknFreak/6-22-20149-46-40PM_zps7bcbc1f6.png[/hsimg]
User avatar
VasTex
Posts: 407
Joined: September 20th, 2012, 3:17 pm
Location: USA - Montana

Re: Help creating new type of Meter

Post by VasTex »

Well while I'm not sure what you'll be measuring with those points I can say that connecting them shouldn't be too much of an issue assuming that some of the values of the dots remain static and don't change.

The dots, like you said, only move up and down along the Y axis. Their positions along the X axis also remain the same or relatively the same, meaning that each point is static or at least appearing in fixed intervals of each other. That means the only thing you need to adjust for is the starting point of the line, its length and its angle. All of these things can be solved using relatively simple mathematical equations. The starting point of our line, for example, is simply the current coordinate values of whatever point you wish to start from. Let's say that the dot on the far left of your example has current coordinates at (10, 30) or 10 units along the X axis and 30 units along the Y axis. We now have our starting point for our line at (10,30).

The next thing we need to figure out is the length of our line which can be solved using the
Pythagorean Theorem (a2+b2=c2). We only need the length of two of our sides which can be easily obtained if we know the coordinates of two of our dots. We already know that our first dot is at (10,30) so to find the length of our line we simply need to know the coordinates of our second dot. Assuming that the distance between the dots never changes let's say that the dots are spaced 10 units from the previous dot. This means that the X position of our second dot would equal the X position of our first dot plus 10. This Y value for our second dot can be gather from whatever it happens to be measuring at the time. Let's say for my example the value of our second dot is 70.

With this information we now have the locations of two of our dots. Dot 1 is located at (10,30) and Dot 2 is located at (20,70). Using the Pythagorean Theorem we can find the length of our line or the 'Hypotenuse' of our triangle. Using the variables in the Pythagorean Theorem (a,b and c) we simply fill in the blanks. The length of our line (c) is what we don't know, but the length of our other two sides (a & b) is what we can find out. We know that the X positions of Dot 1 and Dot 2 are 10 and 20. This means that they have a horizontal separation of 10 which we'll use for the value of 'a'. All that's left is to find the value of 'b' which is equal to the vertical separation of Dot 1 and Dot 2. We know that the Y position of Dot 1 is 30 and the Y position of Dot 2 is 70. They have a separation of 40 units which we will use in place of 'b'.

Now all we have to do in order to find the length of our line is to plug in the values we found and solve for 'c'. Using the Pythagorean Theorem of (a2+b2=c2) we can fill in the blanks and get something that looks like (102+402=c2). Finally, we simplify that into 100+1600=c2 or c2=1700. Find the square root of both sides to eliminate the exponent on 'c' and we get c=41.23105... It would be best to leave this as its mathematical equivalent (SQRT(1700)) to avoid rounding issues. For the sake of simplicity in this example however, I'll be assume that 'c' is equal to 41.

Now that we have our starting point (The location of Dot 1 or (10,30)) and the length of our line (c) or hypotenuse of 41 the only thing left to find is the angle at which the line needs to be placed.

To do that we can use the point slope formula [y2 – y1 = m(x2 – x1)] where y1 and y2 are equal to the vertical positions of the two dots, x1 and x2 are equal to the horizontal positions of the two dots and 'm' is equal to the slope or angle of our line which is what we need to find. You can think of the slope (m) as Rise over Run [The number of units risen (moved along the Y axis) divided by the number of units run (moved along the X axis)].

While finding the length of our line we already did a lot of this work. The value of y2 - y1 is, using our example coordinates, y2(70) - y1(30) or 40. Next the values of x1 and x2 are, using the same coordinate values as before, x2(20)-x1(10) or 10. Our equation now looks like this after plugging in our values and simplifying: y2 – y1 = m(x2 – x1) (plug in our values) 70 – 30 = m(20 – 10) (simplify) 40 = m(10). All that's left is to solve for our slope (m) which can be done by dividing both sides by 10 in order to 'get (m) alone'. What we're left with is ((40/10) = (m(10) / 10)) or m = 4. This can be interpreted as 4 over 1 or, using our previous analogy of Rise over Run, Rise 4 and Run 1. What's left is to convert that slope into Radians and most likely use this information in a Roundline meter in order to draw a well-rotated straight line.

To convert the value of our slope (m) into Radians we first need to convert our slope into Degrees and then Degrees into Radians. First off, for Slope to Degrees we use the Inverse Tangent, ArcTan or Tan-1 (However you wish to write it) of our Slope. When using our given slope of 4 we get something like Degrees=Tan-1(4) or Degrees=75.96. Then we simply convert that value to Radians by taking our Degrees and multiplying it by 180 over PI or 75.96(180/PI). Simplify that and we get our Angle of 0.01745... Radians.

At the end of the day we have this information at our disposal:

-Line Start Point = (10,30)
-Line End Point = (20,70)
-Line Length (c) = (SQRT(1700))
-Line Angle (RAD) = 0.01745 RAD

With that you can work out your line connections between each dot.

**EDIT** Example Skin Posted below and Additional Information Regarding 'Slope to Radians' Conversion as well as Spelling Corrections.
Last edited by VasTex on July 1st, 2014, 6:20 am, edited 2 times in total.
01010100 01100101 01100011 01101000 01101110 01101111 01101100 01101111 01100111 01101001
01100011 01100001 01101100 00100000 01000010 01100001 01100100 01100001 01110011 01110011
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help creating new type of Meter

Post by jsmorley »

You would have been burned at the stake not that many years ago...

[youtube]zrzMhU_4m-g[/youtube]
User avatar
VasTex
Posts: 407
Joined: September 20th, 2012, 3:17 pm
Location: USA - Montana

Re: Help creating new type of Meter

Post by VasTex »

And, after apparently being burned at the stake, here it is:
LineDot test_1.0.rmskin
*It's very basic, not very pretty, but it does the job.
You do not have the required permissions to view the files attached to this post.
01010100 01100101 01100011 01101000 01101110 01101111 01101100 01101111 01100111 01101001
01100011 01100001 01101100 00100000 01000010 01100001 01100100 01100001 01110011 01110011
User avatar
iNjUST
Posts: 117
Joined: June 20th, 2012, 12:44 am

Re: Help creating new type of Meter

Post by iNjUST »

I think tackling this with Roundlines and a little bit of trigonometry is easier and cleaner.

*EDIT* @VasTex: Took a look at your code and seems like you did things similarly. I decided to avoid Pythagorean or slopes and use straight trig, but yours still works. Cool!

I tend to code rather compactly, but I tried to write comments and make the naming scheme easy to follow and easy to expand and modify to whatever you desire to measure, so long as you have a pretty decent background in Rainmeter basics.

Cheers! Let me know if you have any questions.
linegraphex.PNG
LineGraphEx_0.1.rmskin
You do not have the required permissions to view the files attached to this post.
User avatar
VasTex
Posts: 407
Joined: September 20th, 2012, 3:17 pm
Location: USA - Montana

Re: Help creating new type of Meter

Post by VasTex »

I had wanted to use more Roundline meters to display the dots, but I was in a hurry (Leaving work) and left it as simple as I could. As far your 'compact' math we have essentially done the exact same thing. Our variables and format differ, but we've gathered the same information. You used COS instead of the Pythagorean Theorem, which in essence, is still gathering the Hypotenuse and thus the same measurements.

All in all, we have created the exact same thing aside from your prettier dots and condensed method of gathering the Hypotenuse. The main reason I didn't use COS was to write out, simply, how the concept of making this possible was founded. I do prefer your math, but it doesn't do anyone a lot of good in demonstrating an idea if they don't know how you arrived at that conclusion in the first place.

Long story short, Yours is prettier, yours is more concise and the math is more elaborate - I would use yours over mine. However, I feel that my explanation and 'drawn out math' is better suited for someone who needs to understand the underlying mathematics behind what is going here.

I may edit mine later to clean it up.

**EDIT**
@iNjUST - I noticed your edit - Ignore my above comments regarding the similarity then.
01010100 01100101 01100011 01101000 01101110 01101111 01101100 01101111 01100111 01101001
01100011 01100001 01101100 00100000 01000010 01100001 01100100 01100001 01110011 01110011
User avatar
TweaknFreak
Posts: 217
Joined: July 14th, 2012, 7:26 am

Re: Help creating new type of Meter

Post by TweaknFreak »

Okay, I will check out both of them and if I find anything going over my head I'll be back.
And as always, thanks community for such constructive replies. Image
Be one of the iNEViTABLES - Storm, Earthquake, Lightning, Flood - and the world will bow down to you.

My current desktop
[hsimg]http://i1313.photobucket.com/albums/t559/TweaknFreak/6-22-20149-46-40PM_zps7bcbc1f6.png[/hsimg]
User avatar
TweaknFreak
Posts: 217
Joined: July 14th, 2012, 7:26 am

Re: Help creating new type of Meter

Post by TweaknFreak »

@VasTex - I did understand all the things that you did except one. It would be nice if you could explain to me how you whipped a Roundline in the RotationAngle to show a straight line. I mean RotationAngle is supposedly used to give the magnitude of rotation you want in degrees or radians. It will curl into a circle or arc atleast, however small angle it be. This still remains a mystery to me.

@iNjUST - You code was the same thing but in a more small package. Except for these, I could understand it all-
1. The use of CURRENTSECTION in context to this measure. Now I have never used that variable but after going though the docs its purpose is still blurry:

Code: Select all

[sLine]
MeasureName=cAngle#CURRENTSECTION#
X=(#CURRENTSECTION#*#graph.width#+#pad.X#)
Y=(#graph.height#*(1-[mRandom#CURRENTSECTION#])+#pad.Y#)
LineWidth=#line.size#
LineColor=#line.color#
StartAngle=(PI/2)
RotationAngle=(-PI)
LineLength=[#CURRENTSECTION#.0]
DynamicVariables=1
AntiAlias=1
2. Why did you divide it by 100. On a side note, I edited the measures to show CPU usage, most of the time the graphs weren't appearing and when they did appear they ran out off space. I mean they seem to show points beyond the config's boundaries.

Code: Select all

[mRandom0]
Measure=Calc
Formula=RANDOM/100
UpdateRandom=1
UniqueRandom=1
Be one of the iNEViTABLES - Storm, Earthquake, Lightning, Flood - and the world will bow down to you.

My current desktop
[hsimg]http://i1313.photobucket.com/albums/t559/TweaknFreak/6-22-20149-46-40PM_zps7bcbc1f6.png[/hsimg]