It is currently April 28th, 2024, 12:38 am

Image rotation using mouse actions

Get help with creating, editing & fixing problems with skins
o2r
Posts: 7
Joined: May 6th, 2012, 12:06 am

Image rotation using mouse actions

Post by o2r »

Hi,

I am trying to make a skin where I can rotate some image elements using the mouse actions.

Is it possible to make an image rotate clockwise and counter-clockwise in small increments using MouseScrollDownAction / MouseScrollUpAction adjusting a counter that is used to set the angle of rotation?
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Image rotation using mouse actions

Post by jsmorley »

I would not use the rotation angle and such really, but would rather use the scroll actions to control a measure that is used as the "value" for a Rotator image.

Something like:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
ImageW=195
ImageH=195

[MeasureInc]
Measure=Calc
Formula=0
MinValue=0
MaxValue=360

[MeterKnob]
Meter=Rotator
MeasureName=MeasureInc
ImageName=#@#Images\Knob.png
OffsetX=(#ImageW# / 2)
OffsetY=(#ImageH# / 2)
W=#ImageW#
H=#ImageH#
MouseScrollDownAction=[!SetOption MeasureInc Formula "([MeasureInc] + 10 > 360 ? 360 : ([MeasureInc] + 10))"][!UpdateMeasure MeasureInc][!UpdateMeter *][!Redraw]
MouseScrollUpAction=[!SetOption MeasureInc Formula "([MeasureInc] - 10 < 0 ? 0 : ([MeasureInc] - 10))"][!UpdateMeasure MeasureInc][!UpdateMeter *][!Redraw]
DynamicVariables=1

[MeterValue]
Meter=String
MeasureName=MeasureInc
X=(#ImageW# / 2)
Y=(#ImageH# / 2)
FontFace=Segoe UI
FontSize=22
FontColor=53,105,51,255
StringStyle=Bold
StringAlign=CenterCenter
AntiAlias=1
TestKnob_1.1.rmskin
TestKnob.jpg
http://docs.rainmeter.net/manual-beta/meters/rotator

* Skin requires the latest beta 2.5 of Rainmeter.
You do not have the required permissions to view the files attached to this post.
o2r
Posts: 7
Joined: May 6th, 2012, 12:06 am

Re: Image rotation using mouse actions

Post by o2r »

That's exactly what I was looking for!!!

Thank you so very much. I have been looking this for a long time.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Image rotation using mouse actions

Post by jsmorley »

Glad to help.
o2r
Posts: 7
Joined: May 6th, 2012, 12:06 am

Re: Image rotation using mouse actions

Post by o2r »

BTW, is there a way to make the testknob skin able to rotate continuosly instead of stopping at 360 degrees?
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Image rotation using mouse actions

Post by jsmorley »

o2r wrote:BTW, is there a way to make the testknob skin able to rotate continuosly instead of stopping at 360 degrees?

Code: Select all

MouseScrollDownAction=[!SetOption MeasureInc Formula "([MeasureInc] + 10 > 360 ? 10 : ([MeasureInc] + 10))"][!UpdateMeasure MeasureInc][!UpdateMeter *][!Redraw]
MouseScrollUpAction=[!SetOption MeasureInc Formula "([MeasureInc] - 10 < 10 ? 360 : ([MeasureInc] - 10))"][!UpdateMeasure MeasureInc][!UpdateMeter *][!Redraw]
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Image rotation using mouse actions

Post by moshi »

there would be a small jump from 351 to 10 in the first rotation when scrolling down.

this should be (very little) smoother:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
ImageW=195
ImageH=195

[MeasureInc]
Measure=Calc
Formula=0
MinValue=0
MaxValue=359

[MeterKnob]
Meter=Rotator
MeasureName=MeasureInc
ImageName=#@#Images\Knob.png
OffsetX=(#ImageW# / 2)
OffsetY=(#ImageH# / 2)
W=(SQRT(#ImageW# ** 2 + #ImageH# ** 2))
H=(SQRT(#ImageW# ** 2 + #ImageH# ** 2))
MouseScrollDownAction=[!SetOption MeasureInc Formula "([MeasureInc] + 10 > 350 ? 0 : ([MeasureInc] + 10))"][!UpdateMeasure MeasureInc][!UpdateMeter MeterKnob][!Redraw]
MouseScrollUpAction=[!SetOption MeasureInc Formula "([MeasureInc] - 10 < 0 ? 350 : ([MeasureInc] - 10))"][!UpdateMeasure MeasureInc][!UpdateMeter MeterKnob][!Redraw]
DynamicVariables=1

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

Re: Image rotation using mouse actions

Post by jsmorley »

moshi wrote:there would be a small jump from 351 to 10 in the first rotation when scrolling down.
Moshi,

I think you might be working off of an older version of the code I have since updated. What is there now, with the changes I just posted in the message above, should work ok.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Image rotation using mouse actions

Post by moshi »

you're right.

mine is still (very, very little now) better as:

Code: Select all

[MeasureInc]
Measure=Calc
Formula=0
MinValue=0
MaxValue=360
would divide the circle by 361.

but that's really not visible.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Image rotation using mouse actions

Post by jsmorley »

moshi wrote:you're right.

mine is still (very, very little now) better as:

Code: Select all

[MeasureInc]
Measure=Calc
Formula=0
MinValue=0
MaxValue=360
would divide the circle by 361.

but that's really not visible.
Ah, ok.