It is currently April 22nd, 2019, 11:07 am

Help with rotating a meter?

Help with creating, editing & fixing problems with skins
User avatar
jabberwooh
Posts: 2
Joined: February 7th, 2019, 4:18 am

Help with rotating a meter?

jabberwooh » February 7th, 2019, 4:22 am

I'm a total beginner working on my very first skin, and I've been able to solve a surprising amount of problems myself, but I knew early on that I would have to ask for help with a few things.


I'm using a fade code that I found online to layer an image that perfectly lines up with my background wallpaper on top. The black square fades into view when hovering over it with the mouse. The hitbox for the fade commando was originally off to the side and not on top of the actual fade-in image in the code before I modified it. I worked around this by placing it in the same location as my fade-in image and setting the color to 0,0,0,1 to hide it. Given the various tilts of my black squares though, the hitbox of the fade commando is off. This can be seen clearly if I edit the color of the fade commando temporarily to a green. I need to rotate the hitbox so that it is flush with my black squares. How do I do this?

Some additional problems I ran into includes:

I can't seem to put the .ini files for each fade-in in the same folder, or only one will work at a time. I just put them into seperate folders for now, but surely this can be improved?


I would like to launch a program with a click to each black square. I can't work out how to accomplish this within the same code as the fade, and if I put a new .ini file with the launch commando on top of the other skins, it won't acknowledge the fade instead. I want the best of both worlds, y'know?


Imgur album: https://imgur.com/a/Y03Aghm
to hopefully illustrate my problem more clearly.
User avatar
balala
Rainmeter Sage
Posts: 8086
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with rotating a meter?

balala » February 7th, 2019, 9:52 am

In my opinion, the best way to rotate a meter of any kind (String, Image, even Bitmap or Rotator) is the TransformationMatrix. It definitely isn't an easy way to rotate the meter, but nor impossible is. Here is an extremely good description of how this option works: https://docs.rainmeter.net/tips/transformation-matrix-guide/ (read especially the Transformations section of the above description, but not just).
Here is a small code to demonstrate how this option works. It has a yellow rectangle. When you click it it gets rotated with an angle given by the Angle variable (defined into the [Variables] section), then, at next click, it gets unrotated again. Obviously you can freely change the value of the rotation angle.
The code:

Code: Select all

[Rainmeter]
Update=-1

[Variables]
Angle=30
CenterX=100
CenterY=75
Rotate=0

[MeterImage]
Meter=Image
SolidColor=255,240,0
X=150
Y=150
W=200
H=150
TransformationMatrix=(Cos(Rad(#Rotate#*#Angle#)));(-Sin(Rad(#Rotate#*#Angle#)));(Sin(Rad(#Rotate#*#Angle#)));(Cos(Rad(#Rotate#*#Angle#)));((#CenterX#+[#CURRENTSECTION#:X])-(#CenterX#+[#CURRENTSECTION#:X])*Cos(Rad(#Rotate#*#Angle#))-(#CenterY#+[#CURRENTSECTION#:Y])*Sin(Rad(#Rotate#*#Angle#)));((#CenterY#+[#CURRENTSECTION#:Y])+(#CenterX#+[#CURRENTSECTION#:X])*Sin(Rad(#Rotate#*#Angle#))-(#CenterY#+[#CURRENTSECTION#:Y])*Cos(Rad(#Rotate#*#Angle#)))
DynamicVariables=1
LeftMouseUpAction=[!SetVariable Rotate "(1-#Rotate#)"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
As I said, isn't too easy to follow what this TransformationMatrix does. The idea is that beside the rotation angle (Angle variable), you also have to define the center of rotation, through the CenterX and CenterY variables. This rotation center is relative to the meter, which means that if the size of the meter is 200x150 pixels (given by the W and H options), the given CenterX and CenterY values (as they are defined into the
[Variables] section), will rotate the meter around its own center.
jabberwooh wrote:
February 7th, 2019, 4:22 am
I can't seem to put the .ini files for each fade-in in the same folder, or only one will work at a time. I just put them into seperate folders for now, but surely this can be improved?
No, it can't Only one skin from a given config can be loaded at a time. If you want to load more, you have to plece them into different configs (folders).
jabberwooh wrote:
February 7th, 2019, 4:22 am
I would like to launch a program with a click to each black square. I can't work out how to accomplish this within the same code as the fade, and if I put a new .ini file with the launch commando on top of the other skins, it won't acknowledge the fade instead. I want the best of both worlds, y'know?
Using a LeftMouseUpAction option, added to the appropriate meter. For example the LeftMouseUpAction=["calc.exe"] added to any meter, will make that meter to open the Calculator.

For a much more effective help, we'd need a code. Please post it.