It is currently October 26th, 2021, 11:45 am

[solved] Using Arc For Two Different Scales (F & C) Fahrenheit Is Showing Incorrectly

Help with creating, editing & fixing problems with skins
User avatar
CodeCode
Posts: 708
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

[solved] Using Arc For Two Different Scales (F & C) Fahrenheit Is Showing Incorrectly

Post by CodeCode »

Hello,
I have a little weather skin. It shows a circular measure of temperature. A thin Black Arc Shape to denote the position on the visual scale. There is also a semi-transparent round line that 'blurs' a portion of the scale.

To switch between Fahrenheit and Celsius you right click on the temperature numbers - there is a visual shape that denotes that area. Once inside the "switch" clicking on the "F" or "C" lets you choose which scale the whole thing uses for the circular meter.

Thing is, the Fahrenheit part is messed up.
If someone can see what is going on since the formula is fairly identical to the Celsius formula, I would love to see what I missed in there.

Thanks for any help.
LittleWeather_xx.xx.rmskin
You do not have the required permissions to view the files attached to this post.
Last edited by CodeCode on August 27th, 2021, 2:50 am, edited 1 time in total.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
CodeCode
Posts: 708
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Using Arc For Two Different Scales (F & C) Fahrenheit Is Showing Incorrectly

Post by CodeCode »

Heh, silly me. I know why - the scale is wrong in the Min/Max for Fahrenheit. To match it would only go from -4 to way up to 140 F. If I set the scale like that it works fine.

However, in keeping with the visual parameters of "0" and "32", freezing for C and F. Something would need to be mathematically modified. But that is something I really don't know how to do.

So with that I defer to those with that ability.

Thanks for further assistance.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
CodeCode
Posts: 708
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Using Arc For Two Different Scales (F & C) Fahrenheit Is Showing Incorrectly

Post by CodeCode »

OMG ROFL.

I think I got it. A simple matter of using WriteKeyValue to set the MeasureName to the correct Temperature Format parsed from Weather.com.

So, I am fairly sure I am close to the solution, but there may be persistent scaling issues, since a mere 4 degrees F is about 15-ish degrees for the 360 degree measuring scale. I think it should be a fair bit less than that. Thinking in averages it should be more like half that.

Hmm. My math skills are so meagre. :oops:
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
Yincognito
Rainmeter Sage
Posts: 4071
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Using Arc For Two Different Scales (F & C) Fahrenheit Is Showing Incorrectly

Post by Yincognito »

On mobile now so can't test, but by the look of it you don't only need to change the scale accordingly, but also set the min and max values (if you use that) accordingly to the C or F desired intervals...
User avatar
Yincognito
Rainmeter Sage
Posts: 4071
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Using Arc For Two Different Scales (F & C) Fahrenheit Is Showing Incorrectly

Post by Yincognito »

So, your skin is a little confusing with multiple measures / meters having similar names, not to mention that I'm not even sure the original code gets the Fahrenheit value from somewhere, but here's a similar simpleton, based on the arc "markers" - up to you to adapt it to that skin:

Code: Select all

[Variables]
Radius=97
MinC=-100
MaxC=100
MinMaxCAngle=0
ZeroCAngle=(#MinMaxCAngle#+Abs(#MinC#)/(Abs(#MinC#)+Abs(#MaxC#))*360)

[Rainmeter]
Update=25
DynamicWindowSize=1
AccurateText=1

---Measures---

[TempC]
Measure=Loop
StartValue=#MinC#
EndValue=#MaxC#
Increment=1
MinValue=#MinC#
MaxValue=#MaxC#
DynamicVariables=1

[TempF]
Measure=Calc
Formula=(TempC*9/5+32)
MinValue=(#MinC#*9/5+32)
MaxValue=(#MaxC#*9/5+32)
DynamicVariables=1

---Meters---

[TempCircle]
Meter=Shape
X=3
Y=3
DynamicVariables=1
Shape=Ellipse 97,97,97,97 | Fill Color 0,0,0,1 | StrokeWidth 6 | Stroke Color 255,255,0,255
Shape2=Arc (#Radius#+#Radius#*Cos(Rad(#MinMaxCAngle#-0.1))),(#Radius#+#Radius#*Sin(Rad(#MinMaxCAngle#-0.1))), (#Radius#+#Radius#*Cos(Rad(#MinMaxCAngle#+0.1))),(#Radius#+#Radius#*Sin(Rad(#MinMaxCAngle#+0.1))), #Radius#, #Radius# | StrokeWidth 6 | Stroke Color 0,0,0,255 | StrokeStartCap Square | StrokeEndCap Square
Shape3=Arc (#Radius#+#Radius#*Cos(Rad(#ZeroCAngle#-0.1))),(#Radius#+#Radius#*Sin(Rad(#ZeroCAngle#-0.1))), (#Radius#+#Radius#*Cos(Rad(#ZeroCAngle#+0.1))),(#Radius#+#Radius#*Sin(Rad(#ZeroCAngle#+0.1))), #Radius#, #Radius# | StrokeWidth 6 | Stroke Color 64,64,64,255 | StrokeStartCap Square | StrokeEndCap Square
Shape4=Arc (#Radius#+#Radius#*Cos(Rad(#MinMaxCAngle#+360*[TempC:%]/100-0.3))),(#Radius#+#Radius#*Sin(Rad(#MinMaxCAngle#+360*[TempC:%]/100-0.3))), (#Radius#+#Radius#*Cos(Rad(#MinMaxCAngle#+360*[TempC:%]/100+0.3))),(#Radius#+#Radius#*Sin(Rad(#MinMaxCAngle#+360*[TempC:%]/100+0.3))), #Radius#, #Radius# | StrokeWidth 6 | Stroke Color 0,0,255,255 | StrokeStartCap Round | StrokeEndCap Round
Shape5=Arc (#Radius#+#Radius#*Cos(Rad(#MinMaxCAngle#+360*[TempF:%]/100-0.2))),(#Radius#+#Radius#*Sin(Rad(#MinMaxCAngle#+360*[TempF:%]/100-0.2))), (#Radius#+#Radius#*Cos(Rad(#MinMaxCAngle#+360*[TempF:%]/100+0.2))),(#Radius#+#Radius#*Sin(Rad(#MinMaxCAngle#+360*[TempF:%]/100+0.2))), #Radius#, #Radius# | StrokeWidth 4 | Stroke Color 255,0,0,255 | StrokeStartCap Round | StrokeEndCap Round
LeftMouseUpAction=[!TogglePauseMeasure TempC]
DynamicVariables=1

[TempText]
Meter=String
X=100r
Y=100r
FontFace=Consolas
FontColor=255,255,255,255
FontSize=16
AntiAlias=1
StringAlign=CenterCenter
MeasureName=TempC
MeasureName2=TempF
NumOfDecimals=0
Text="Temperature#CRLF#%1°C#CRLF#%2°F"
DynamicVariables=1
Temps.jpg
Legend:
- Radius = circle radius
- MinC = minimum Celsius temperature that can be displayed on the circle
- MaxC = maximum Celsius temperature that can be displayed on the circle
- MinMaxCAngle = the angle on the circle that indicates where the minimum / maximum Celsius temperatures start / end (the black marker)
- ZeroCAngle= the angle on the circle that indicates where the zero Celsius temperature is placed (the grey marker)

Shape is the circle, Shape2 is the minmax C temp position on the circle, Shape3 is the zero C temp position on the circle, Shape4 (the blue marker) is the C temp, Shape5 (the red marker) is the F temp. Left click toggles pausing the animation. I let the red F temp marker smaller so you can see that both temperatures progress equally.
You do not have the required permissions to view the files attached to this post.
User avatar
CodeCode
Posts: 708
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Using Arc For Two Different Scales (F & C) Fahrenheit Is Showing Incorrectly

Post by CodeCode »

@Yincognito.

Thanks so so much, for naming all of the variables. I know it takes extra effort to do it that way.
That is definitely going into my explanations folder.

What confuses me, is that you could not see the Fahrenheit working properly. The skin is completely self contained, so even with my location code, you should have seen the fahrenheit producing a number, accurate to the celsius value also from its own url.

Currently having both freezing scales be at the left center is what I am trying to have but with the min/max values being -35/120 respectively, for fahrenheit and min/max for celsius be -38/60 respectively. (in relative terms this value is verily similar to the -35 value for fahrenheit, but not really important)

I will take a poke at what I 'think' i need to change: the (97+97*Cos(Rad(#MinMaxCAngle# ..... because zero fahrenheit is -17 Celsius. The thing I am struggling with is your variable MinMaxAngle is considering the full 360 for the max to rotate into, where my goal is only to use a 270 degree arc with, the aforementioned left side being both zero for celsius and 32 for fahrenheit, and the bottom center to be the max.
Ok, so after typing all of this out, I am understanding better what is going on. I will consider closely the standard arc example from the manual Shape=Arc 3,200,203,200,100,100,0,0,0,0 | StrokeWidth 6 and the meaning of all of the values, and try to make the correct adjustments.
This idea I have might be a kludge, and only work for the values hardcoded into my arcs rather than reflect a fixed min at left-center, and max at bottom-center.
I am going to try anyways, since I think that putting the correct values for begin and end for the arcs will actually be dynamin so the enduser can easily change the min max based on their region.
I think i might be looking a a clamp to replace the MinMaxCAngle in you example code. The worst that can happen is a crash rainmeter a few times lol.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
CodeCode
Posts: 708
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Using Arc For Two Different Scales (F & C) Fahrenheit Is Showing Incorrectly

Post by CodeCode »

Hmm, ok. I need more help, since what I 'thought' to be the solution really has weird behaviour.

THis is my arc that I tried to make start and end at the 90 and 0 positions on the full scale:

Code: Select all

Arc (97+(97)*cos(rad(90+360*[*MeasureTempforScalingF:%*]/100))),(97+(97)*sin(rad(90+360*[*MeasureTempforScalingF:%*]/100))), (97+(97)*cos(rad(0+3+360*[*MeasureTempforScalingF:%*]/100))),(97+(97)*sin(rad(0+3+360*[*MeasureTempforScalingF:%*]/100))), 97, 97 | StrokeWidth 6 | Stroke Color 0,0,0,255
I cannot tell if that is right because after that change, the position marker is now seemingly broken into parts.
You can see where I added the "0" into the endx and endy parts of the arc. My reasoning was that position would act as the end would be the lower-center, or the "0" position (also so I think) and (at minimum value) at the left-center or "90" (i think), be the start

Please correct me, since I know that change was either incomplete, or simply wrong.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Using Arc For Two Different Scales (F & C) Fahrenheit Is Showing Incorrectly

Post by death.crafter »

CodeCode wrote: August 26th, 2021, 8:23 am Hmm, ok. I need more help, since what I 'thought' to be the solution really has weird behaviour.

THis is my arc that I tried to make start and end at the 90 and 0 positions on the full scale:

Code: Select all

Arc (97+(97)*cos(rad(90+360*[*MeasureTempforScalingF:%*]/100))),(97+(97)*sin(rad(90+360*[*MeasureTempforScalingF:%*]/100))), (97+(97)*cos(rad(0+3+360*[*MeasureTempforScalingF:%*]/100))),(97+(97)*sin(rad(0+3+360*[*MeasureTempforScalingF:%*]/100))), 97, 97 | StrokeWidth 6 | Stroke Color 0,0,0,255
I cannot tell if that is right because after that change, the position marker is now seemingly broken into parts.
You can see where I added the "0" into the endx and endy parts of the arc. My reasoning was that position would act as the end would be the lower-center, or the "0" position (also so I think) and (at minimum value) at the left-center or "90" (i think), be the start

Please correct me, since I know that change was either incomplete, or simply wrong.

Code: Select all

[Rainmeter]
Update=20
AccurateText=1

[MeasureTempforScalingF]
Measure=Calc
Formula=(#CURRENTSECTION#=99?0:#CURRENTSECTION#+0.5)
MaxValue=99

[MeterString]
Meter=Shape
Shape=Ellipse 100,100,100,100 | StrokeWidth 0
Shape2=Arc (100+97*cos(rad(90-1.5+360*[MeasureTempforScalingF:%]/100))),(100+97*sin(rad(90-3/2+360*[MeasureTempforScalingF:%]/100))), (100+97*cos(rad(90+3/2+360*[MeasureTempforScalingF:%]/100))),(100+97*sin(rad(90+3/2+360*[MeasureTempforScalingF:%]/100))), 97, 97 | StrokeWidth 6 | Stroke Color 0,0,0,255
Shape3=Ellipse (100+90*cos(rad(90+360*[MeasureTempforScalingF:%]/100))),(100+90*sin(rad(90+360*[MeasureTempforScalingF:%]/100))),3,3 | StrokeWidth 0 | Fill Color 255,0,0
DynamicVariables=1
from the Realm of Death
My Current Desktop
User avatar
Yincognito
Rainmeter Sage
Posts: 4071
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Using Arc For Two Different Scales (F & C) Fahrenheit Is Showing Incorrectly

Post by Yincognito »

CodeCode wrote: August 26th, 2021, 7:49 amWhat confuses me, is that you could not see the Fahrenheit working properly. The skin is completely self contained, so even with my location code, you should have seen the fahrenheit producing a number, accurate to the celsius value also from its own url.
Yeah, for me the original code (the RMSKIN you posted initially) yielded the same temp for C and F, and that is incorrect. :confused:
CodeCode wrote: August 26th, 2021, 7:49 amCurrently having both freezing scales be at the left center is what I am trying to have but with the min/max values being -35/120 respectively, for fahrenheit and min/max for celsius be -38/60 respectively. (in relative terms this value is verily similar to the -35 value for fahrenheit, but not really important)
That's achievable just by changing the variables, in the simpleton sample I posted, because I had a feeling the min and max wouldn't be the same in absolute values for your case. In reality is about -90 C to 60 C, considering the googling results for min/max recorded temps on Earth.
CodeCode wrote: August 26th, 2021, 7:49 amI will take a poke at what I 'think' i need to change: the (97+97*Cos(Rad(#MinMaxCAngle# ..... because zero fahrenheit is -17 Celsius. The thing I am struggling with is your variable MinMaxAngle is considering the full 360 for the max to rotate into, where my goal is only to use a 270 degree arc with, the aforementioned left side being both zero for celsius and 32 for fahrenheit, and the bottom center to be the max.
Yep, again, I had a feeling you'd only use a part of the 360 degree circle. The sample I posted only works with Celsius based values when setting angles and temp bounds (sorry, but apart from the C to F formula, I just can't deal with Fahrenheit, let alone understand why some folks still use it in regular life, but that's a different topic), but since the conversion to F is done anyway in the skin, it's no issue. Yeah, I believe the reduction from 360 to 270 degrees of "working arcs" can be done, it's probably just a matter of (properly) replacing 360 with 270 in some formulas (though it could involve a bit more than that).
CodeCode wrote: August 26th, 2021, 7:49 amThe worst that can happen is a crash rainmeter a few times lol.
Exactly. Feel free to experiment. I'll take a look at the raised issues later on (if death.crafter didn't already gave the solution, that is), but adapting it to your skin will be your job (you don't have to keep all the variables, you can hardcode things with the actual values if you want, after setting stuff the way you want, you know). ;-)
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Using Arc For Two Different Scales (F & C) Fahrenheit Is Showing Incorrectly

Post by death.crafter »

CodeCode wrote: August 24th, 2021, 5:28 pm Hello,
I have a little weather skin. It shows a circular measure of temperature. A thin Black Arc Shape to denote the position on the visual scale. There is also a semi-transparent round line that 'blurs' a portion of the scale.

To switch between Fahrenheit and Celsius you right click on the temperature numbers - there is a visual shape that denotes that area. Once inside the "switch" clicking on the "F" or "C" lets you choose which scale the whole thing uses for the circular meter.

Thing is, the Fahrenheit part is messed up.
If someone can see what is going on since the formula is fairly identical to the Celsius formula, I would love to see what I missed in there.

Thanks for any help.
LittleWeather_xx.xx.rmskin
Apart from the mentioned problem, I feel like there are a lot of sections in this skin. Also the meter and measure names are convoluted.

Always try to keep things simple. Like skipping calc measure and use direct formulas. It will increase the efficiency, both in working and visually.
from the Realm of Death
My Current Desktop