It is currently April 18th, 2024, 4:39 am

How do classes work with skins?

General topics related to Rainmeter.
RichKat666
Posts: 10
Joined: January 3rd, 2020, 5:43 pm

How do classes work with skins?

Post by RichKat666 »

Say I want to get a few shape meters to act together, using the same rules, but with different variables for each meter.

With other languages I would make a class with all the functions I need, and then create the meters as members of that class.

How does this work with Lua/Rainmeter? In what direction should I google?
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How do classes work with skins?

Post by jsmorley »

RichKat666 wrote: January 3rd, 2020, 5:53 pm Say I want to get a few shape meters to act together, using the same rules, but with different variables for each meter.

With other languages I would make a class with all the functions I need, and then create the meters as members of that class.

How does this work with Lua/Rainmeter? In what direction should I google?
Kinda apples and oranges here really. There are no classes or other object oriented stuff in Rainmeter.

Can you give an example of what you are trying to accomplish?
RichKat666
Posts: 10
Joined: January 3rd, 2020, 5:43 pm

Re: How do classes work with skins?

Post by RichKat666 »

Say I have a few shape meters.

I want them to, for example:
1) Float around in similar ways when idle
2) Wiggle in the same manner when music is played
3) Shrink when they come near the cursor.

This seems like the sort of thing that would be accomplished with classes elsewhere, which is why I brought them up
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How do classes work with skins?

Post by jsmorley »

Might not be really productive to start with a coding approach that doesn't exist in Rainmeter, when I would probably first ask how one moves shapes in a general sense.

There is no really easy answer to that, but you might look at these skins from ecectic-tech that moves shapes in response to music.

https://www.deviantart.com/search/deviations/visual-art/resource/digital-art?order=most-recent&q=rainmeter%20eclectic-tech
https://www.deviantart.com/eclectic-tech/art/Stereo-Optic-Visualizers-805768508
RichKat666
Posts: 10
Joined: January 3rd, 2020, 5:43 pm

Re: How do classes work with skins?

Post by RichKat666 »

Wait, really? With all the stuff you can do to shape meters, as you yourself described here[/https://forum.rainmeter.net/viewtopic.php?t=24292], I would have thought you could just change the position of the transform? Or, failing that, just re-draw the shape at another location? Is it really that implausible?

And does all that mean that if I want a few meters to do the same thing I should just copy-and-paste the code?

Thank you for all your responses.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How do classes work with skins?

Post by jsmorley »

RichKat666 wrote: January 5th, 2020, 12:15 pm Wait, really? With all the stuff you can do to shape meters, as you yourself described here[/https://forum.rainmeter.net/viewtopic.php?t=24292], I would have thought you could just change the position of the transform? Or, failing that, just re-draw the shape at another location? Is it really that implausible?

And does all that mean that if I want a few meters to do the same thing I should just copy-and-paste the code?

Thank you for all your responses.
It is pretty unlimited what you can do with Rainmeter. Sure you can dynamically change any part of a shape meter based on whatever action or reaction you want.

But yes, you would need a different meter for each shape, which can in fact just be a copy-paste of the same stuff. Then you take actions to change the various sizes, positions, colors etc. of each shape meter as you like.
RichKat666
Posts: 10
Joined: January 3rd, 2020, 5:43 pm

Re: How do classes work with skins?

Post by RichKat666 »

Ok, got it. It's kind of sad that if I want to change one thing I have to change each document individually.

Thank you very much for your help.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: How do classes work with skins?

Post by eclectic-tech »

RichKat666 wrote: January 5th, 2020, 12:36 pm Ok, got it. It's kind of sad that if I want to change one thing I have to change each document individually.

Thank you very much for your help.
You don't have to change every document necessarily, you could change an @include file which each skin uses, then refresh the skins to see the change.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2602
Joined: March 23rd, 2015, 5:26 pm

Re: How do classes work with skins?

Post by SilverAzide »

Don't forget about using styles. You can create a style for meter then re-use it as many times as you want with only needing to add in whatever specific unique attributes you need. It's not quite like objects, and inheritance is only 1-level deep (I think), but the effect is similar.
Gadgets Wiki GitHub More Gadgets...