It is currently April 26th, 2024, 12:42 am

Fill Color to shape programmatically?

Get help with installing and using Rainmeter.
bathman
Posts: 1
Joined: November 22nd, 2021, 10:59 pm

Fill Color to shape programmatically?

Post by bathman »

hi, i am new to coding rainmeter. please forgive me for asking instead of studying first...

i am trying to achieve a kind of dot assembly or 'set theory' clock in rainmeter.
i did this in flash actionscript looooong ago - now loosely following the approach of a Binary_Clock skin i found on deviantart -
https://www.deviantart.com/flyinghyrax/art/Binary-Clock-266686125 - i ran into a problem.
this skin uses Meter=ROUNDLINE for shapes and an elaborate programmatic way of assigning two colours.
Meter=ROUNDLINE
MeterStyle=sCircle | sHour[mHourTensBin2] // the second bit assigns colour 'on' and 'off'

now i want hexagons to do this, i.e. path based shapes and i want to change the color of those shapes similar to what the original script does with ROUNDLINE.
i read that assigning Fill Color to a path shape is not as easy as with ROUNDLINE for example and i also read about !SetOption and Extend here in the forum. due to my non-existent experience with this i may need help.. following is the ini of the binary_clock.
i've already hacked into it and while it now does create hexagons instead of circles - i just can't manage the colour change yet.

Code: Select all

[Rainmeter]
Author=Flying Hyrax
Version=2001000

[Metadata]
Name=Binary Clock - Encoded Sexegecimal - Hours, Minutes, and Seconds
Version=1.0
Information=Binary-coded sexagesimal (base 60) clock. | - The rows from top to bottom are the hours, minutes, and seconds.  The columns from left to right are the binary 32, 16, 8, 4, 2, and 1 place.  How to read: http://en.wikipedia.org/wiki/Binary_clock#Binary_Coded_Sexagesimal | - Colors, circle size, and spacing are changeable in Appearance.txt.
License=Creative Commons Attribution-Non Commercial-Share Alike 3.0

[Variables]
@Include=#CURRENTPATH#Appearance.txt

[mHour]
Measure=TIME
Format=%H

[mMin]
Measure=TIME
Format=%M

[mSec]
Measure=TIME
Format=%S


; =-=-=-=-= Hours =-=-=-=-=

[mHourBin1]
Measure=CALC
Formula=(mHour >= 1) ? (mHour % 2) : 0
DynamicVariables=1

[mHourBin2]
Measure=CALC
Formula=(mHour >= 2) ? ((TRUNC(mHour/2)) % 2) : 0
DynamicVariables=1

[mHourBin4]
Measure=CALC
Formula=(mHour >= 4) ? (TRUNC((TRUNC(mHour/2)) / 2) % 2) : 0
DynamicVariables=1

[mHourBin8]
Measure=CALC
Formula=(mHour >= 8) ? (TRUNC((TRUNC((TRUNC(mHour/2)) / 2)) / 2) % 2) : 0
DynamicVariables=1

[mHourBin16]
Measure=CALC
Formula=(mHour >= 16) ? ((TRUNC((TRUNC((TRUNC((TRUNC(mHour/2)) / 2)) / 2)) / 2)) % 2) : 0
DynamicVariables=1

; =-=-=-=-= Minutes =-=-=-=-=

[mMinBin1]
Measure=CALC
Formula=(mMin >= 1) ? (mMin % 2) : 0
DynamicVariables=1

[mMinBin2]
Measure=CALC
Formula=(mMin >= 2) ? ((TRUNC(mMin/2)) % 2) : 0
DynamicVariables=1

[mMinBin4]
Measure=CALC
Formula=(mMin >= 4) ? (TRUNC((TRUNC(mMin/2)) / 2) % 2) : 0
DynamicVariables=1

[mMinBin8]
Measure=CALC
Formula=(mMin >= 8) ? (TRUNC((TRUNC((TRUNC(mMin/2)) / 2)) / 2) % 2) : 0
DynamicVariables=1

[mMinBin16]
Measure=CALC
Formula=(mMin >= 16) ? ((TRUNC((TRUNC((TRUNC((TRUNC(mMin/2)) / 2)) / 2)) / 2)) % 2) : 0
DynamicVariables=1

[mMinBin32]
Measure=CALC
Formula=(mMin >= 32) ? ((TRUNC((TRUNC((TRUNC((TRUNC((TRUNC(mMin/2)) / 2)) / 2)) / 2)) / 2)) % 2) : 0
DynamicVariables=1

; =-=-=-=-= Seconds =-=-=-=-=
[mSecBin1]
Measure=CALC
Formula=(mSec >= 1) ? (mSec % 2) : 0
DynamicVariables=1

[mSecBin2]
Measure=CALC
Formula=(mSec >= 2) ? ((TRUNC(mSec/2)) % 2) : 0
DynamicVariables=1

[mSecBin4]
Measure=CALC
Formula=(mSec >= 4) ? (TRUNC((TRUNC(mSec/2)) / 2) % 2) : 0
DynamicVariables=1

[mSecBin8]
Measure=CALC
Formula=(mSec >= 8) ? (TRUNC((TRUNC((TRUNC(mSec/2)) / 2)) / 2) % 2) : 0
DynamicVariables=1

[mSecBin16]
Measure=CALC
Formula=(mSec >= 16) ? ((TRUNC((TRUNC((TRUNC((TRUNC(mSec/2)) / 2)) / 2)) / 2)) % 2) : 0
DynamicVariables=1

[mSecBin32]
Measure=CALC
Formula=(mSec >= 32) ? ((TRUNC((TRUNC((TRUNC((TRUNC((TRUNC(mSec/2)) / 2)) / 2)) / 2)) / 2)) % 2) : 0
DynamicVariables=1

; Spacing Calcs
[mSizeCalc]
Measure=CALC
Formula=(#Radius# * 2)

[mHourXCalc]
Measure=CALC
Formula=((#Radius# * 2) + (#SpaceX# * 2))

; =-=-=-=-= STYLES =-=-=-=-=
[sHour0]
FillColor=#Hour0#

[sHour1]
FillColor=#Hour1#

[sMin0]
FillColor=#Min0#

[sMin1]
FillColor=#Min1#

[sSec0]
FillColor=#Sec0#

[sSec1]
FillColor=#Sec1#

[sCircle]
LineWidth=1
LineLength=#Radius#
LineStart=0
StartAngle=0
RotationAngle=6.28
Solid=1
AntiAlias=1
MeasureName=mAlways2
X=#SpaceX#R
Y=r
W=[mSizeCalc]
H=[mSizeCalc]
DynamicVariables=1

[sHexagon]
MyPath=(#SideLength#/2),0 | LineTo (3*#sideLength#/2),0 | LineTo (2*#SideLength#),(0.866*#SideLength#) | LineTo (3*#SideLength#/2),(1.73*#SideLength#) | LineTo (#SideLength#/2),(1.73*#SideLength#) | LineTo 0,(0.866*#SideLength#) | ClosePath 1
Shape=Path MyPath | StrokeWidth 1 | Stroke Color #FillColor# | Fill Color #FillColor#
AntiAlias=1
MeasureName=mAlways1
X=#SpaceX#R
Y=r
W=[mSizeCalc]
H=[mSizeCalc]
DynamicVariables=1

; =-=-=-=-= Meters =-=-=-=-=
[!SetOption Hour16 MyColor "FillColor 0,255,0,255"]
[Hour16]
Meter=Shape
X=[mHourXCalc]
Y=#SpaceY#
MeterStyle=sHexagon
IfCondition=(mHourBin16>0)
Shape=Path MyPath | StrokeWidth 1 | Stroke Color #FillColor# | Extend MyColor
MyColor = FillColor 255,0,0,200
IfCondition2=(mHourBin16<1)
Shape=Path MyPath | StrokeWidth 1 | Stroke Color #FillColor# | Extend MyColor
MyColor = FillColor 180,0,0,100
DynamicVariables=1

[Hour8]
Meter=Shape
MeterStyle=sHexagon | sHour[mHourBin8]
DynamicVariables=1

[Hour4]
Meter=Shape
MeterStyle=sHexagon | sHour[mHourBin4]
DynamicVariables=1

[Hour2]
Meter=Shape
MeterStyle=sHexagon | sHour[mHourBin2]
DynamicVariables=1

[Hour1]
Meter=Shape
MeterStyle=sHexagon | sHour[mHourBin1]
DynamicVariables=1

[Minute32]
Meter=Shape
X=#SpaceX#
Y=#SpaceY#R
MeterStyle=sHexagon | sMin[mMinBin32]
DynamicVariables=1

[Minute16]
Meter=Shape
MeterStyle=sHexagon | sMin[mMinBin16]
DynamicVariables=1

[Minute8]
Meter=Shape
MeterStyle=sHexagon | sMin[mMinBin8]
DynamicVariables=1

[Minute4]
Meter=Shape
MeterStyle=sHexagon | sMin[mMinBin4]
DynamicVariables=1

[Minute2]
Meter=Shape
MeterStyle=sHexagon | sMin[mMinBin2]
DynamicVariables=1

[Minute1]
Meter=Shape
MeterStyle=sHexagon | sMin[mMinBin1]
DynamicVariables=1

[Second32]
Meter=Shape
X=#SpaceX#
Y=#SpaceY#R
MeterStyle=sHexagon | sSec[mSecBin32]
DynamicVariables=1

[Second16]
Meter=Shape
MeterStyle=sHexagon | sSec[mSecBin16]
DynamicVariables=1

[Second8]
Meter=Shape
MeterStyle=sHexagon | sSec[mSecBin8]
DynamicVariables=1

[Second4]
Meter=Shape
MeterStyle=sHexagon | sSec[mSecBin4]
DynamicVariables=1

[Second2]
Meter=Shape
MeterStyle=sHexagon | sSec[mSecBin2]
DynamicVariables=1

[!SetOption Second1 MyColor "FillColor 0,255,0,255"]
[Second1]
Meter=Shape
MeterStyle=sHexagon

IfCondition=([mSecBin1]>0)
MyColor = FillColor 255,0,0,200
Shape=Path MyPath | StrokeWidth 1 | Stroke Color #FillColor# | Extend MyColor

;[sSec[mSecBin1]]
IfCondition2=([mSecBin1]<1)
MyColor = FillColor 180,0,0,100
Shape=Path MyPath | StrokeWidth 1 | Stroke Color #FillColor# | Extend MyColor

;[sSec[mSecBin1]]



DynamicVariables=1

[spacer]
Meter=IMAGE
SolidColor=0,0,0,1
X=R
Y=R
W=#SpaceX#
H=#SpaceY#
a few variables are set in 'appearance.txt'

Code: Select all

[Variables]

Hour0=180,0,0,100
Hour1=255,0,0,200

Min0=180,0,0,100
Min1=250,0,0,200

Sec0=180,0,0,100
Sec1=250,0,0,200

Radius=30
Space=97
SpaceX=97
SpaceY=31
;180,0,0,100
;250,250,250,200

SideLength = 50
FillColor=#Hour0#

my question is - how would i best assign and change the colour of the hexagon shapes based on calculation of either state they can be in?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5406
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Fill Color to shape programmatically?

Post by eclectic-tech »

All that was needed was to correct the hours, minutes, and seconds style sections coding syntax so that the 'Extend MyColor' was correctly set for each style.

Here is the code. I removed all the lines that were not needed...

Code: Select all

[Rainmeter]
Author=Flying Hyrax
; Version=2001000

[Metadata]
Name=Binary Clock - Encoded Sexegecimal - Hours, Minutes, and Seconds
Version=1.0
Information=Binary-coded sexagesimal (base 60) clock. | - The rows from top to bottom are the hours, minutes, and seconds.  The columns from left to right are the binary 32, 16, 8, 4, 2, and 1 place.  How to read: http://en.wikipedia.org/wiki/Binary_clock#Binary_Coded_Sexagesimal | - Colors, circle size, and spacing are changeable in Appearance.txt.
License=Creative Commons Attribution-Non Commercial-Share Alike 3.0

[Variables]
@Include=#CURRENTPATH#Appearance.txt

[mHour]
Measure=TIME
Format=%H

[mMin]
Measure=TIME
Format=%M

[mSec]
Measure=TIME
Format=%S


; =-=-=-=-= Hours =-=-=-=-=

[mHourBin1]
Measure=CALC
Formula=(mHour >= 1) ? (mHour % 2) : 0
DynamicVariables=1

[mHourBin2]
Measure=CALC
Formula=(mHour >= 2) ? ((TRUNC(mHour/2)) % 2) : 0
DynamicVariables=1

[mHourBin4]
Measure=CALC
Formula=(mHour >= 4) ? (TRUNC((TRUNC(mHour/2)) / 2) % 2) : 0
DynamicVariables=1

[mHourBin8]
Measure=CALC
Formula=(mHour >= 8) ? (TRUNC((TRUNC((TRUNC(mHour/2)) / 2)) / 2) % 2) : 0
DynamicVariables=1

[mHourBin16]
Measure=CALC
Formula=(mHour >= 16) ? ((TRUNC((TRUNC((TRUNC((TRUNC(mHour/2)) / 2)) / 2)) / 2)) % 2) : 0
DynamicVariables=1

; =-=-=-=-= Minutes =-=-=-=-=

[mMinBin1]
Measure=CALC
Formula=(mMin >= 1) ? (mMin % 2) : 0
DynamicVariables=1

[mMinBin2]
Measure=CALC
Formula=(mMin >= 2) ? ((TRUNC(mMin/2)) % 2) : 0
DynamicVariables=1

[mMinBin4]
Measure=CALC
Formula=(mMin >= 4) ? (TRUNC((TRUNC(mMin/2)) / 2) % 2) : 0
DynamicVariables=1

[mMinBin8]
Measure=CALC
Formula=(mMin >= 8) ? (TRUNC((TRUNC((TRUNC(mMin/2)) / 2)) / 2) % 2) : 0
DynamicVariables=1

[mMinBin16]
Measure=CALC
Formula=(mMin >= 16) ? ((TRUNC((TRUNC((TRUNC((TRUNC(mMin/2)) / 2)) / 2)) / 2)) % 2) : 0
DynamicVariables=1

[mMinBin32]
Measure=CALC
Formula=(mMin >= 32) ? ((TRUNC((TRUNC((TRUNC((TRUNC((TRUNC(mMin/2)) / 2)) / 2)) / 2)) / 2)) % 2) : 0
DynamicVariables=1

; =-=-=-=-= Seconds =-=-=-=-=
[mSecBin1]
Measure=CALC
Formula=(mSec >= 1) ? (mSec % 2) : 0
DynamicVariables=1

[mSecBin2]
Measure=CALC
Formula=(mSec >= 2) ? ((TRUNC(mSec/2)) % 2) : 0
DynamicVariables=1

[mSecBin4]
Measure=CALC
Formula=(mSec >= 4) ? (TRUNC((TRUNC(mSec/2)) / 2) % 2) : 0
DynamicVariables=1

[mSecBin8]
Measure=CALC
Formula=(mSec >= 8) ? (TRUNC((TRUNC((TRUNC(mSec/2)) / 2)) / 2) % 2) : 0
DynamicVariables=1

[mSecBin16]
Measure=CALC
Formula=(mSec >= 16) ? ((TRUNC((TRUNC((TRUNC((TRUNC(mSec/2)) / 2)) / 2)) / 2)) % 2) : 0
DynamicVariables=1

[mSecBin32]
Measure=CALC
Formula=(mSec >= 32) ? ((TRUNC((TRUNC((TRUNC((TRUNC((TRUNC(mSec/2)) / 2)) / 2)) / 2)) / 2)) % 2) : 0
DynamicVariables=1

; Spacing Calcs
[mSizeCalc]
Measure=CALC
Formula=(#Radius# * 2)

[mHourXCalc]
Measure=CALC
Formula=((#Radius# * 2) + (#SpaceX# * 2))

; =-=-=-=-= STYLES =-=-=-=-=
[sHour0]
MyColor=FillColor #Hour0#

[sHour1]
MyColor=FillColor #Hour1#

[sMin0]
MyColor=FillColor #Min0#

[sMin1]
MyColor=FillColor #Min1#

[sSec0]
MyColor=FillColor #Sec0#

[sSec1]
MyColor=FillColor #Sec1#

[sCircle]
LineWidth=1
LineLength=#Radius#
LineStart=0
StartAngle=0
RotationAngle=6.28
Solid=1
AntiAlias=1
MeasureName=mAlways2
X=#SpaceX#R
Y=r
W=[mSizeCalc]
H=[mSizeCalc]
DynamicVariables=1

[sHexagon]
MyPath=(#SideLength#/2),0 | LineTo (3*#sideLength#/2),0 | LineTo (2*#SideLength#),(0.866*#SideLength#) | LineTo (3*#SideLength#/2),(1.73*#SideLength#) | LineTo (#SideLength#/2),(1.73*#SideLength#) | LineTo 0,(0.866*#SideLength#) | ClosePath 1
Shape=Path MyPath | StrokeWidth 1 | Stroke Color #FillColor# | Extend MyColor
MyColor=Fill Color #FillColor#
AntiAlias=1
X=#SpaceX#R
Y=r
W=[mSizeCalc]
H=[mSizeCalc]
DynamicVariables=1

; =-=-=-=-= Meters =-=-=-=-=
[Hour16]
Meter=Shape
X=[mHourXCalc]
Y=#SpaceY#
MeterStyle=sHexagon | sHour[mHourBin16]
DynamicVariables=1

[Hour8]
Meter=Shape
MeterStyle=sHexagon | sHour[mHourBin8]
DynamicVariables=1

[Hour4]
Meter=Shape
MeterStyle=sHexagon | sHour[mHourBin4]
DynamicVariables=1

[Hour2]
Meter=Shape
MeterStyle=sHexagon | sHour[mHourBin2]
DynamicVariables=1

[Hour1]
Meter=Shape
MeterStyle=sHexagon | sHour[mHourBin1]
DynamicVariables=1

[Minute32]
Meter=Shape
X=#SpaceX#
Y=#SpaceY#R
MeterStyle=sHexagon | sMin[mMinBin32]
DynamicVariables=1

[Minute16]
Meter=Shape
MeterStyle=sHexagon | sMin[mMinBin16]
DynamicVariables=1

[Minute8]
Meter=Shape
MeterStyle=sHexagon | sMin[mMinBin8]
DynamicVariables=1

[Minute4]
Meter=Shape
MeterStyle=sHexagon | sMin[mMinBin4]
DynamicVariables=1

[Minute2]
Meter=Shape
MeterStyle=sHexagon | sMin[mMinBin2]
DynamicVariables=1

[Minute1]
Meter=Shape
MeterStyle=sHexagon | sMin[mMinBin1]
DynamicVariables=1

[Second32]
Meter=Shape
X=#SpaceX#
Y=#SpaceY#R
MeterStyle=sHexagon | sSec[mSecBin32]
DynamicVariables=1

[Second16]
Meter=Shape
MeterStyle=sHexagon | sSec[mSecBin16]
DynamicVariables=1

[Second8]
Meter=Shape
MeterStyle=sHexagon | sSec[mSecBin8]
DynamicVariables=1

[Second4]
Meter=Shape
MeterStyle=sHexagon | sSec[mSecBin4]
DynamicVariables=1

[Second2]
Meter=Shape
MeterStyle=sHexagon | sSec[mSecBin2]
DynamicVariables=1

[Second1]
Meter=Shape
MeterStyle=sHexagon | sSec[mSecBin1]
DynamicVariables=1

[spacer]
Meter=IMAGE
SolidColor=0,0,0,1
X=R
Y=R
W=#SpaceX#
H=#SpaceY#
Click Image to animate...
hex.gif
You do not have the required permissions to view the files attached to this post.