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

Need Help with Mouse control on Shapes.

Help with creating, editing & fixing problems with skins
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Need Help with Mouse control on Shapes.

Post by death.crafter »

Yincognito wrote: August 13th, 2021, 9:58 am It doesn't work that way. The image X and Y are not the image's center point, but the top left point of the image METER. If you meant that the offsets should be subtracted from the center point of the hex's rectangular slot, that would work fine if the image wasn't rotated.

As for the rotation, apart from death.crafter's linked images requiring an "initial" rotation because they are drawn using a different angle than the 0 angle in this skin (this can be ignored if your images are drawn according to the 0 angle in the skin, of course), you have to rotate the image along with the hex so that the image fits the hex properly, if you change the angle along the way.

Currently I'm almost done with the angle thing, only the image rotation left to be done, but I already have the image meter's bounding box for the rotating image and the X and Y should be only a matter of subtracting half of the bounding box' W and H from the rectangular slot's center.
I don't quite follow. Why do you need to rotate an image? I mean I would use suitable icons if I were to use horizontal hexagons :confused:
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: Need Help with Mouse control on Shapes.

Post by Yincognito »

death.crafter wrote: August 13th, 2021, 6:00 pm I don't quite follow. Why do you need to rotate an image? I mean I would use suitable icons if I were to use horizontal hexagons :confused:
No, I meant that if you change the #Angle# at which you draw the hexagon in the skin (your initial method, with #StartingAngle#), then the image will rotate along with the rotated hexagon as well (0,15,30,45,60 and 78 degrees below):
00.png
15.png
30.png
45.png
60.png
78.png
That part is done, however, and as you can see, it behaves well but the hexes are just under each other in an orthogonal manner only for angles multiple of 30. That's good enough though, as for the other cases you'd have to rotate the entire plane (and probably wouldn't be able to have a rectangular "slot" for each hex, though I could be wrong here, anyway, the point is the math would be too complex for my taste).

Now with the angle part done, I'm trying to prevent placing hexes on top of each other at the background margins (your implementation does that too, by the way). The right and bottom background margins are handled already in the #Hidden# variable, but didn't notice that it happens for the left and top on till now. Then, I'll try to resequence hexes - compared to the other parts, that would be easy, but will probably happen tomorrow anyway. ;-)
You do not have the required permissions to view the files attached to this post.
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Need Help with Mouse control on Shapes.

Post by death.crafter »

Yincognito wrote: August 13th, 2021, 6:42 pm Now with the angle part done, I'm trying to prevent placing hexes on top of each other at the background margins (your implementation does that too, by the way). The right and bottom background margins are handled already in the #Hidden# variable, but didn't notice that it happens for the left and top on till now. Then, I'll try to resequence hexes - compared to the other parts, that would be easy, but will probably happen tomorrow anyway. ;-)
Not in my first version without images. I changed that in second, in case the OP didn't want logs. He doesn't want a script anyway lol.
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: Need Help with Mouse control on Shapes.

Post by Yincognito »

death.crafter wrote: August 13th, 2021, 7:04 pm Not in my first version without images. I changed that in second, in case the OP didn't want logs. He doesn't want a script anyway lol.
Ah, didn't notice that - although I tried the 1st version, I only took for comparison the 2nd as it seemed more complete. Regarding scripts, I guess the "issue" with them is that most Rainmeter users would like to modify / tweak / adjust things afterwards, and while they have an understanding of how to do it for native code, it's harder (to put it mildly) with scripts, since not everyone has a programming background. Before the need forced me to do things in Lua and became familiar with the syntax (even made a save game editor in it, LOL), I also avoided it. Even now, I still use Lua only when there's no other way of achieving something - and I couldn't say I haven't programmed or scripted before, having built an (unreleased) "bulk image" scrapper/downloader Javascript extension for Chrome, among other finished/unfinished programming projects.

Anyway, I completed my hex over hex prevention as well, now it works for all the margins. Still happening for the outside the hex corners of the 2R, Sqrt(3)R rectangular slot, but I can live with that since they're basically just a couple of pixels near the background margins. Time for relax now, I'll see how native Rainmeter resequencing goes on afterwards, and tomorrow - I'm just glad the "harder" part is behind me. :D
User avatar
KryptOnyx
Posts: 19
Joined: July 28th, 2021, 10:18 am

Re: Need Help with Mouse control on Shapes.

Post by KryptOnyx »

Hello Everyone, I hope you had a good weekend.
I managed to find some time to play with Yincognitos code and got the Select/Deselect working (and can offer Flat Top or Pointy Hex grid :D ).
I have limited this example code to 10 Tiles for Testing purposes.

Code: Select all

[Rainmeter]
Update=500
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!AutoSelectScreen "1" "#CURRENTCONFIG#"]

[Variables]
ThisTile=-1
Toggle=0
Radius=48
Stroke=4
Gap=5
; Pointy Top Hex
Angle=30
SlotH=(#Radius#*1.5+#Stroke#+#Gap#)
SlotW=(#Radius#*Sqrt(3)+#Stroke#+#Gap#)
SlotY="((#Gap#/2+#Stroke#/2+#Radius#-#SlotH#/2)+Trunc(([$*MouseY*]-(#Gap#/2+#Stroke#/2+#Radius#-#SlotH#/2))/#SlotH#)*#SlotH#)"
SlotX="((#SlotW#/2*((Trunc(([$*MouseY*]-(#Gap#/2+#Stroke#/2+#Radius#-#SlotH#/2))/#SlotH#))%2))+Trunc(([$*MouseX*]-(#SlotW#/2*((Trunc(([$*MouseY*]-(#Gap#/2+#Stroke#/2+#Radius#-#SlotH#/2))/#SlotH#))%2)))/#SlotW#)*#SlotW#)"
; Flat Top Hex
;Angle=0
;SlotW=(#Radius#*1.5+#Stroke#+#Gap#)
;SlotH=(#Radius#*Sqrt(3)+#Stroke#+#Gap#)
;SlotX="((#Gap#/2+#Stroke#/2+#Radius#-#SlotW#/2)+Trunc(([$*MouseX*]-(#Gap#/2+#Stroke#/2+#Radius#-#SlotW#/2))/#SlotW#)*#SlotW#)"
;SlotY="((#SlotH#/2*((Trunc(([$*MouseX*]-(#Gap#/2+#Stroke#/2+#Radius#-#SlotW#/2))/#SlotW#))%2))+Trunc(([$*MouseY*]-(#SlotH#/2*((Trunc(([$*MouseX*]-(#Gap#/2+#Stroke#/2+#Radius#-#SlotW#/2))/#SlotW#))%2)))/#SlotH#)*#SlotH#)"
MaxNext=9
FontSize=20
FontColor=0,0,0,255
HexaStrokeColor=255,0,0,255
SlotStrokeColor=255,255,0,255
NearTransparentColor=0,0,0,1
BackgroundColor=255,0,255,100

---Measures---

[ChangeTile]
Measure=Calc
Formula=((#ThisTile#+#Toggle#) > #MaxNext# ? #MaxNext# : (#ThisTile#+#Toggle#))
OnUpdateAction=[!SetVariable ThisTile [ChangeTile]]
UpdateDivider=-1
DynamicVariables=1

---Styles---

[Hex]
Group=SGroup
Hidden=1
Shape=Path HexaPath | StrokeWidth #Stroke# | StrokeColor #HexaStrokeColor# | Fill Color 0,120,200,255
HexaPath=(#SlotW#/2+#Radius#*Cos(Rad(#Angle#+0))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+0))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+60))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+60))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+120))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+120))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+180))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+180))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+240))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+240))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+300))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+300))) | ClosePath 1
LeftMouseUpAction=[!SetOption S[ChangeTile] Hidden 1][!SetOption S[ChangeTile]T Hidden 1][!UpdateMeterGroup SGroup][!Redraw][!SetVariable Toggle -1][!UpdateMeasure ChangeTile]
UpdateDivider=-1
DynamicVariables=1

[Text]
Group=SGroup
Hidden=1
FontFace=Tahoma
FontWeight=700
FontSize=#FontSize#
FontColor=#FontColor#
StringAlign=CenterCenter
UpdateDivider=-1
DynamicVariables=1

---Meters---

[Background]
Meter=Shape
Shape=Rectangle #WORKAREAX#,#WORKAREAY#,#WORKAREAWIDTH#,#WORKAREAHEIGHT# | Fill Color #BackgroundColor# | StrokeWidth 0
LeftMouseUpAction=[!SetVariable Toggle 1][!UpdateMeasure ChangeTile][!SetOption S[ChangeTile] X #SlotX#][!SetOption S[ChangeTile] Y #SlotY#][!SetOption S[ChangeTile] Hidden (((#SlotX#+#SlotW#+#Radius#*0.25>[Background:W])||(#SlotY#+#SlotH#>[Background:H]))?1:0)][!SetOption S[ChangeTile]T X (#SlotX#+#SlotW#/2)][!SetOption S[ChangeTile]T Y (#SlotY#+#SlotH#/2)][!SetOption S[ChangeTile]T Text "[ChangeTile]"][!SetOption S[ChangeTile]T Hidden (((#SlotX#+#SlotW#+#Radius#*0.25>[Background:W])||(#SlotY#+#SlotH#>[Background:H]))?1:0)][!UpdateMeterGroup SGroup][!UpdateMeter Background][!Redraw]
MiddleMouseUpAction=[!SetVariable ThisTile -1][!SetOptionGroup SGroup Hidden 1][!UpdateMeterGroup SGroup][!Redraw][!UpdateMeter Background]
UpdateDivider=-1
DynamicVariables=1

[S0]
Meter=Shape
MeterStyle=Hex

[S0T]
Meter=String
MeterStyle=Text

[S1]
Meter=Shape
MeterStyle=Hex

[S1T]
Meter=String
MeterStyle=Text

[S2]
Meter=Shape
MeterStyle=Hex

[S2T]
Meter=String
MeterStyle=Text

[S3]
Meter=Shape
MeterStyle=Hex

[S3T]
Meter=String
MeterStyle=Text

[S4]
Meter=Shape
MeterStyle=Hex

[S4T]
Meter=String
MeterStyle=Text

[S5]
Meter=Shape
MeterStyle=Hex

[S5T]
Meter=String
MeterStyle=Text

[S6]
Meter=Shape
MeterStyle=Hex

[S6T]
Meter=String
MeterStyle=Text

[S7]
Meter=Shape
MeterStyle=Hex

[S7T]
Meter=String
MeterStyle=Text

[S8]
Meter=Shape
MeterStyle=Hex

[S8T]
Meter=String
MeterStyle=Text

[S9]
Meter=Shape
MeterStyle=Hex

[S9T]
Meter=String
MeterStyle=Text

[S10]
Meter=Shape
MeterStyle=Hex

[S10T]
Meter=String
MeterStyle=Text

A couple of Questions :
- Can both Skin and Included File have duplicated sections, like [Variables]?
- Is there a way to clear file content before Writing new data (non-Lua)?

All help is much appreciated. :thumbup:
Everything happens for a Reason, and could Not happen any other way.
User avatar
jsmorley
Developer
Posts: 22374
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Need Help with Mouse control on Shapes.

Post by jsmorley »

You can have duplicate [SectionNames] in both the skin .ini and an @Include .inc file. Here are the rules:
If there is a conflict - that is, if the same section exists in more than one file - Rainmeter will treat whichever one comes first in the ordering as the "real" section. Any options on the later instances will be added to the first one, and otherwise the later instances are simply ignored. If there are different values given for the same key, the last value is taken. Unlike new sections, options on pre-existing sections are added in their original order, so the calling section may overwrite values from the included file if they are placed below the @include statement.
https://docs.rainmeter.net/manual-beta/skins/include-option/

[Variables] is probably the only section where this makes much sense, but it certainly does there.

[Variables]
@Include=#@#MyGlobalVariables.inc
MyLocalVariable=1

In this case, there would be a [Variables] section in the MyGlobalVariables.inc file as well.
User avatar
Yincognito
Rainmeter Sage
Posts: 4071
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Need Help with Mouse control on Shapes.

Post by Yincognito »

KryptOnyx wrote: August 16th, 2021, 12:34 pmHello Everyone, I hope you had a good weekend.
Not entirely good - got vaccinated with the 2nd dose, but had a serious toothache that prevented me from roaming the forum, as I was not in a good mood, as you probably expect, LOL. But, with some antibiotics (not a problem along the vaccine), it seems the situation slowly becomes better. :sly:
KryptOnyx wrote: August 16th, 2021, 12:34 pmI managed to find some time to play with Yincognitos code and got the Select/Deselect working (and can offer Flat Top or Pointy Hex grid :D ).
Well, if I knew you just want to hide the last hex no matter which hex you're clicking on, that would have saved from the trouble of "resequencing". The "almost final" version of the hexagonal lattice, with both arbitrary (i.e. with "gaps" in the hidden status) and sequence (i.e. without "gaps" in the hidden status) variants for easy comparison. The latter still has what you would call "bugs", but they are mainly related to me now knowing how the text and the image values should be changed (or not?) when doing the "resequencing". Some of the issues are similar to the ones in death.crafter's Lua version, not sure if for the same reason or another. Anyway, the resequence is (again) possible in native Rainmeter, with the help of regex (you can check the values of the List, Shift measures and Status variable in the Log to see what happens):
HexaLattice_2.0.0.rmskin
P.S. Both variants use conditionals to set the Slot coordinates and dimensions, so there is no need to comment the values for different angles - just change the angle and that's all, Rainmeter will automatically take care of setting the right values (and rotate, in the case of images) for that specific angle (angles multiple of 30 are recommended, for hexes being orthogonally placed compared to each other).
P.S.S. For those curious how the "resequencing" is done in the List measure:
- when I click to show / create a hex, I'm gradually building a List variable having a format that contains parts like (current hex 3 presented) S3:X=...,Y=...,...;3, where X, Y, etc. are the relevant option values for that hex / hex image / hex text
- because I added the ;3-like part above, in the overall List variable, the "previous" hex index is just before the "current" one, like ...;1S2:X=...,Y=...,...;2S3:X=...,Y=...,...;3S4...
- then, in the List measure, I'm:
-- starting with List variable
-- swap the indexes in the ;2S3: parts, discarding the latter one, to be ;S2: (1st regex step)
-- add back the "previous" index to the end of S2:X=...,Y=...,...; parts, to be like S2:X=...,Y=...,...;2 (3rd regex step)
-- I delete the 1st S0:...; part, without touching the very 1st "previous" index, in effect making the 2nd part the 1st (4th regex step)
-- since I now have the "shifted to the left" or "towards 0" list, i.e. the full resequenced list, I concatenate the original List variable with it, so I can eventually get the partly original, partly resequenced desired outcome (5th regex step)
-- I get the desired outcome by removing the part between two successive occurrences of the hex I want to "hide" (i.e. the Hide variable, which is actually the hex being clicked on to "remove") from the original+resequenced concatenated lists, basically leaving the original list up to the clicked hex (exclusive) to the left of the clicked hex and the resequenced one from the clicked hex (inclusive) to the right of the clicked hex (8th regex step)
-- the rest of the regex steps are just cleaning, removing unwanted leftovers from the process
Despite the extensive explanation, this is actually a simple process, like doing 0=A,1=B,2=C,3=D,4=E to the "shifted" 0=B,1=C,2=D,3=E, then to the concatenated 0=A,1=B,2=C,3=D,4=E,0=B,1=C,2=D,3=E, then, if I want to remove the element 1, to the final 0=A,1=B,2=C,3=D,4=E,0=B,1=C,2=D,3=E aka 0=A,1=C,2=D,3=E
KryptOnyx wrote: August 16th, 2021, 12:34 pm - Is there a way to clear file content before Writing new data (non-Lua)?
If you talk about an INI formatted file, I'm afraid complete clearing is not possible in native Rainmeter. But, if you know all the section names and all the option names, you can set the option VALUES to either the empty string ("") or zero (0), using !WriteKeyValue bangs.

EDIT: For the devs / adminstrators, how do you escape a [ListLiteral] string from not being converted to an actual list in the forum? If I do [L i s t] (without the spaces) it becomes a list and not the literal [ List ] (again,without the spaces, for obvious reasons).
You do not have the required permissions to view the files attached to this post.
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Need Help with Mouse control on Shapes.

Post by death.crafter »

Yincognito wrote: August 16th, 2021, 1:52 pm If you talk about an INI formatted file, I'm afraid complete clearing is not possible in native Rainmeter. But, if you know all the section names and all the option names, you can set the option VALUES to either the empty string ("") or zero (0), using !WriteKeyValue bangs.
The forum is excruciatingly slow, not letting me download the skin. So, will let you know after trying it. :D

Did Yincognito just say "not possible"? :jawdrop

Anyway:

Code: Select all

[ClearFile]
Measure=Plugin
Plugin=RunCommand
Program=Powershell
Parameter=Clear-Content -Path '#FilePath#'
UpdateDivider=-1

Code: Select all

<Some>Action=[!CommandMeasure ClearFile Run]
It's non-Lua, as asked.
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: Need Help with Mouse control on Shapes.

Post by Yincognito »

death.crafter wrote: August 16th, 2021, 5:27 pmThe forum is excruciatingly slow, not letting me download the skin. So, will let you know after trying it. :D
Yeah, happened to me too, from time to time, over the years. Here's a MediaFire link, if it helps.

Let me know if you discover any "bugs" besides those mentioned already. Still don't know how things should work out in a resequence scenario: when you remove 2 from 1,2,3,4, are the 3 and 4 supposed to entirely become 2 and 3 (meaning with 2 and 3 images and text), or they should retain the 3 and 4 visual characteristics (again, images and text) but simply leave no gap in the hidden status list? Also, when you continue placing hexes after removing like that, are the text and images supposed to continue from 4 or from 5? :confused: That's mostly the cause for the said "bugs", because I let that thing somewhat in limbo, as I could find flaws (logical or otherwise) to every scenario.
death.crafter wrote: August 16th, 2021, 5:27 pmDid Yincognito just say "not possible"? :jawdrop

Anyway:

Code: Select all

[ClearFile]
Measure=Plugin
Plugin=RunCommand
Program=Powershell
Parameter=Clear-Content -Path '#FilePath#'
UpdateDivider=-1

Code: Select all

<Some>Action=[!CommandMeasure ClearFile Run]
It's non-Lua, as asked.
Haha, well, it only happened because I also included any sort of "external" script-like approach to do it (including PowerShell). But you're right, I should have mentioned the PS way, indeed, as it sorts of qualifies as "native method", given the RunCommand connection. Just enjoy me saying "not possible" (even if by my interpretation of "in the strictest sense") while you can, cause it won't happen too often (if any). :lol:
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Need Help with Mouse control on Shapes.

Post by death.crafter »

Yincognito wrote: August 16th, 2021, 5:48 pm Yeah, happened to me too, from time to time, over the years. Here's a MediaFire link, if it helps.
Personally I would prefer a gdrive or mega link since mediafire doesn't feel safe to me. Just personal opinion. Ofc it helped.
Yincognito wrote: August 16th, 2021, 5:48 pm Let me know if you discover any "bugs" besides those mentioned already. Still don't know how things should work out in a resequence scenario: when you remove 2 from 1,2,3,4, are the 3 and 4 supposed to entirely become 2 and 3 (meaning with 2 and 3 images and text), or they should retain the 3 and 4 visual characteristics (again, images and text) but simply leave no gap in the hidden status list? Also, when you continue placing hexes after removing like that, are the text and images supposed to continue from 4 or from 5? :confused: That's mostly the cause for the said "bugs", because I let that thing somewhat in limbo, as I could find flaws (logical or otherwise) to every scenario.
I don't quite follow. Are both the skin variants different? Because they do the same thing.
Re-sequencing should be something like this:
ezgif-6-f883f3492b6f.gif
Youtube link if gif is not loading:
Yincognito wrote: August 16th, 2021, 5:48 pm Haha, well, it only happened because I also included any sort of "external" script-like approach to do it (including PowerShell). But you're right, I should have mentioned the PS way, indeed, as it sorts of qualifies as "native method", given the RunCommand connection. Just enjoy me saying "not possible" (even if by my interpretation of "in the strictest sense") while you can, cause it won't happen too often (if any). :lol:
:rolmfao:

But the fact is, Lua IS native to Rainmeter. But RunCommand is not.
You do not have the required permissions to view the files attached to this post.
from the Realm of Death
My Current Desktop