It is currently March 29th, 2024, 10:50 am

Rotate an image around its center

Get help with creating, editing & fixing problems with skins
Big
Posts: 19
Joined: February 12th, 2017, 4:19 pm

Rotate an image around its center

Post by Big »

Hello everyone. I'm trying to rotate my fan image with the help of my fan speed measurement of my video card. The image turns and stop same the real one but the problem is that it does not turn as fast as if the measurement it would follow would be that of [MeasureRotate]. Where is my mistake?


FAN.png

Code: Select all

[Rainmeter]

Author=-BIG-
Update=50
DynamicWindowSize=1

[Variables]
@include=#@#SysInfoSettings.ini
ImageW=107
ImageH=107

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

____________________________________________MEASURE

___________________________________FAN

[MEASURE_GPU_RPM]
Measure=Plugin
Plugin=MSIAfterburner.dll
GPU=#GPU#
SourceId=17
MinValue=0
MaxValue=2000

[MeasureRotate]
Measure=Calc
Formula=(MeasureRotate % 360) + 35
MaxValue=360

[MeterRotate]
Meter=Rotator
MeasureName=MEASURE_GPU_RPM
ImageName=#@#IMAGES\FAN.png
OffsetX=(#ImageW# / 2.01)
OffsetY=(#ImageH# / 2.01)
X=400
Y=400
W=#ImageW#
H=#ImageH#
You do not have the required permissions to view the files attached to this post.
Last edited by balala on January 6th, 2019, 6:00 pm, edited 1 time in total.
Reason: Please use [code] tags when posting code snippets. It's the </> button.
Big
Posts: 19
Joined: February 12th, 2017, 4:19 pm

Re: Rotate an image around its center

Post by Big »

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

Re: Rotate an image around its center

Post by jsmorley »

I have to say up front that I'm not a fan of this. Ouch! ;-)

First, it will be very difficult to get any real "speed" to the rotation, while maintaining a sense of "smooth" movement. It will either have to be "slow" or "jerky".

Second, this is going to be a relatively "expensive" skin in terms of the CPU that Rainmeter uses.

So having said that, here is more or less the approach I would suggest:

Code: Select all

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

[Variables]
ImageW=107
ImageH=107

[MeasureFanSpeed]
Measure=Calc
; This is simply to fake the fan speed, from 0 to 2000rpm
; I don't have MSIAfterBurner
Formula=Random
LowBound=0
HighBound=2000
UpdateRandom=1
UpdateDivider=100

[MeasureFanPercent]
Measure=Calc
; This will turn the fan speed into a percentage of 2000, which
; we apply to the UpdateDivider of MeasureLoop to control the speed
Formula=(MeasureFanSpeed / 2000)
MinValue=0
MaxValue=1
IfCondition=MeasureFanSpeed = 0
; If the fan is stopped, stop the loop
IfTrueAction=[!PauseMeasure MeasureLoop]
IfFalseAction=[!UnpauseMeasure MeasureLoop]

[MeasureLoop]
Measure=Loop
StartValue=0
EndValue=360
; Rotating 360 degrees, even with the lowest update of 20, is quite slow
; We really must move the fan more than one degree per update of the loop
Increment=10
DynamicVariables=1
; Slowest speed over zero is once every 50*20 updates or once a second
; Fastest speed is once every update, or every 20ms
UpdateDivider=(50-(50 * [MeasureFanPercent]))

[MeterFan]
Meter=Rotator
MeasureName=MeasureLoop
ImageName=#@#Images\FAN.png
OffsetX=(#ImageW# / 2.01)
OffsetY=(#ImageH# / 2.01)
X=400
Y=400
W=#ImageW#
H=#ImageH#
GIF.gif


Feel free to ask questions....
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Rotate an image around its center

Post by balala »

Big wrote: January 6th, 2019, 4:43 pm I'm trying to rotate my fan image with the help of my fan speed measurement of my video card. The image turns and stop same the real one but the problem is that it does not turn as fast as if the measurement it would follow would be that of [MeasureRotate]. Where is my mistake?
Since I'm not using the MSIAfterburner plugin, I can't say precisely, but what values are returning the [MEASURE_GPU_RPM] measure? It's a quickly changing value or a less or more constant value? Because the value returned by the measure used into the MeasureName option of a Rotator meter (in this case the [MeterRotate] meter) must change quickly, for a quick rotation. As more quickly is it changing, as quicker the image is rotating.
That's why I think you should have to use the value returned by the [MEASURE_GPU_RPM] into the Formula option of the [MeasureRotate] measure, then use the value of this measure into the MeasureName option of the [MeterRotate] meter. Something like this:

Code: Select all

[MeasureRotate]
Measure=Calc
Formula=(( MeasureRotate % 360 ) + MEASURE_GPU_RPM )
MaxValue=360

[MeterRotate]
Meter=Rotator
MeasureName=MeasureRotate
ImageName=#@#IMAGES\FAN.png
OffsetX=(#ImageW# / 2.01)
OffsetY=(#ImageH# / 2.01)
X=400
Y=400
W=#ImageW#
H=#ImageH#
How will this work, depends on which values are returned by the [MEASURE_GPU_RPM] measure. Probably you'll have to adjust them, eventually adding a new Calc measure, to "scale" the values.
So, to not let it go too long, first question would be what values are returned by the [MEASURE_GPU_RPM] measure? Do you know the limits of this value?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Rotate an image around its center

Post by balala »

EDIT: Sorry jsmorley, I again am late a few minutes!
balala wrote: January 6th, 2019, 6:28 pm Since I'm not using the MSIAfterburner plugin, I can't say precisely, but what values are returning the [MEASURE_GPU_RPM] measure? It's a quickly changing value or a less or more constant value? Because the value returned by the measure used into the MeasureName option of a Rotator meter (in this case the [MeterRotate] meter) must change quickly, for a quick rotation. As more quickly is it changing, as quicker the image is rotating.
That's why I think you should have to use the value returned by the [MEASURE_GPU_RPM] into the Formula option of the [MeasureRotate] measure, then use the value of this measure into the MeasureName option of the [MeterRotate] meter. Something like this:

Code: Select all

[MeasureRotate]
Measure=Calc
Formula=(( MeasureRotate % 360 ) + MEASURE_GPU_RPM )
MaxValue=360

[MeterRotate]
Meter=Rotator
MeasureName=MeasureRotate
ImageName=#@#IMAGES\FAN.png
OffsetX=(#ImageW# / 2.01)
OffsetY=(#ImageH# / 2.01)
X=400
Y=400
W=#ImageW#
H=#ImageH#
How will this work, depends on which values are returned by the [MEASURE_GPU_RPM] measure. Probably you'll have to adjust them, eventually adding a new Calc measure, to "scale" the values.
So, to not let it go too long, first question would be what values are returned by the [MEASURE_GPU_RPM] measure? Do you know the limits of this value?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Rotate an image around its center

Post by jsmorley »

balala, I'm not sure that addresses his need.

He is not looking to position the rotated image based on the "value" of the fan speed measure, but in a 360-degree rotation that is always moving from 0-360 degrees, but relatively "faster" or "slower" based on the percentage that the fan speed is from 0 to 2000 rpm...

So in a sense, it is simply in a 0-360 loop, but that loop should run "faster" or "slower" based on the value.

As I said though, with the limitations of Rainmeter as far as Update and animations, I think it is going to be difficult to get something that looks like a real fan.

If you think about it, even at a very low Update value of 20ms, about as low as you can go, to increment the rotation 360 times will take a bit over 7 seconds to fully rotate. (20 * 360 = 7,200ms) That would be if you want the maximum "smoothness", but it will be very, very slow. You can help that by using an Increment option on the loop, which will increment from 0 to 360 at a faster pace than 1 each time, but that will introduce some "jerkiness" to the movement. You won't be able to have it be both "fast" and "smooth" with the limitation of Rainmeter.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Rotate an image around its center

Post by balala »

jsmorley wrote: January 6th, 2019, 6:32 pm balala, I'm not sure that addresses his need.

He is not looking to position the rotated image based on the "value" of the fan speed measure, but in a 360-degree rotation that is always moving from 0-360 degrees, but relatively "faster" or "slower" based on the percentage that the fan speed is from 0 to 2000 rpm...

So in a sense, it is simply in a 0-360 loop, but that loop should run "faster" or "slower" based on the value.

As I said though, with the limitations of Rainmeter as far as Update and animations, I think it is going to be difficult to get something that looks like a real fan.
But this is exactly what I think I did. As I said I don't know what value is returned by the [MEASURE_GPU_RPM] measure, but i supposed it returns a value which grows when the fan speed grows. So if I'm right and it indeed grows as the fan's speed increases, as greater value is added to ( MeasureRotate % 360 ), so it should make the Rotator meter rotates quicker.
Was a thought of mine, as I can't try it out, maybe it can be wrong. I assume this.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Rotate an image around its center

Post by jsmorley »

balala wrote: January 6th, 2019, 6:46 pm But this is exactly what I think I did. As I said I don't know what value is returned by the [MEASURE_GPU_RPM] measure, but i supposed it returns a value which grows when the fan speed grows. So if I'm right and it indeed grows as the fan's speed increases, as greater value is added to ( MeasureRotate % 360 ), so it should make the Rotator meter rotates quicker.
Was a thought of mine, as I can't try it out, maybe it can be wrong. I assume this.
Maybe so, I guess I don't follow this:

Code: Select all

[MeasureRotate]
Measure=Calc
Formula=(( MeasureRotate % 360 ) + MEASURE_GPU_RPM )
MaxValue=360
I don't see how that speeds up or slows down the amount of time that the Calc takes to get from 0 to 360, but rather increments 0 to 360 and then "yanks" it to a particular point based on the value of MEASURE_GPU_RPM.

We know from his original post that that value of MEASURE_GPU_RPM will be a number from 0 to 2000 based on this:

Code: Select all

[MEASURE_GPU_RPM]
Measure=Plugin
Plugin=MSIAfterburner.dll
GPU=#GPU#
SourceId=17
MinValue=0
MaxValue=2000
So if the measure returns 2000, the rotation should be as fast as possible. if it is 1000, it should be at half-speed.

The value of the fan speed can't have anything at all to do with where in the 0-360 degree arc the rotation is. That is just always a simple increment from 0-360 in an endless loop. I don't see any relationship between the value of the fan speed and the value used by the Rotator meter at all, only how quickly the Rotator meter moves in an endless loop from 0 to 360.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Rotate an image around its center

Post by balala »

jsmorley wrote: January 6th, 2019, 6:52 pm Maybe so, I guess I don't follow this:

Code: Select all

[MeasureRotate]
Measure=Calc
Formula=(( MeasureRotate % 360 ) + MEASURE_GPU_RPM )
MaxValue=360
I don't see how that speeds up or slows down the amount of time that the Calc takes to get from 0 to 360, but rather increments 0 to 360 and then "yanks" it to a particular point based on the value of MEASURE_GPU_RPM.
My idea was to add a greater or smaller value to ( MeasureRotate % 360 ), to make it to increase quicker or slower, depending on the value returned by the [MEASURE_GPU_RPM] measure.
But it seems I lost his MinValue and MaxValue options on [MEASURE_GPU_RPM] measure, so I have to admit that this is my mistake!!! Late sorry for this.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Rotate an image around its center

Post by jsmorley »

You could use a Calc measure with a modulus % operator to do the increment, and still control the speed with UpdateDivider, but I prefer the Loop measure in this instance, as you want to count from 0 to 360, not 1 to 360.