It is currently December 7th, 2022, 7:23 pm

Radar Chart Template

Skins that control functions in Windows or Rainmeter
User avatar
XANCI
Posts: 104
Joined: September 18th, 2011, 6:37 am
Location: Nanjing, China

Radar Chart Template

Post by XANCI »

This is my newest toy, and I'm excited to share these ingenious LUA codes with you :)

skin .ini:

Code: Select all

[Rainmeter]
Author=XANCI

[Variables]
CenterX=150
CenterY=150
Radius=100
Tag1=Tag1
Tag2=Tag2
Tag3=Tag3
Tag4=Tag4
Tag5=Tag5
Tag6=Tag6
Color1=FF0000
Color2=FFFF00
Color3=00FF00
Color4=00FFFF
Color5=0000FF
Color6=FF00FF

[MeasureScript]
Measure=Script
ScriptFile="#CURRENTPATH#Radar.lua"

[MeasureCalc1]
Measure=Calc
Formula=0.4
DynamicVariables=1

[MeasureCalc2]
Measure=Calc
Formula=0.7
DynamicVariables=1

[MeasureCalc3]
Measure=Calc
Formula=0.5
DynamicVariables=1

[MeasureCalc4]
Measure=Calc
Formula=0.8
DynamicVariables=1

[MeasureCalc5]
Measure=Calc
Formula=0.9
DynamicVariables=1

[MeasureCalc6]
Measure=Calc
Formula=0.8
DynamicVariables=1

[MeterB]
Meter=IMAGE
W=300
H=300
SolidColor=00000060

[MeterR1]
Meter=IMAGE
X=#CenterX#
Y=(#CenterY#-1)
W=#Radius#
H=2
SolidColor=FFFFFF
AntiAlias=1

[MeterR2]
Meter=IMAGE
X=#CenterX#
Y=(#CenterY#-1)
W=#Radius#
H=2
SolidColor=FFFFFF
AntiAlias=1

[MeterR3]
Meter=IMAGE
X=#CenterX#
Y=(#CenterY#-1)
W=#Radius#
H=2
SolidColor=FFFFFF
AntiAlias=1

[MeterR4]
Meter=IMAGE
X=#CenterX#
Y=(#CenterY#-1)
W=#Radius#
H=2
SolidColor=FFFFFF
AntiAlias=1

[MeterR5]
Meter=IMAGE
X=#CenterX#
Y=(#CenterY#-1)
W=#Radius#
H=2
SolidColor=FFFFFF
AntiAlias=1

[MeterR6]
Meter=IMAGE
X=#CenterX#
Y=(#CenterY#-1)
W=#Radius#
H=2
SolidColor=FFFFFF
AntiAlias=1

[MeterL1]
Meter=IMAGE
W=1
H=2
SolidColor=#Color1#
AntiAlias=1

[MeterL2]
Meter=IMAGE
W=1
H=2
SolidColor=#Color2#
AntiAlias=1

[MeterL3]
Meter=IMAGE
W=1
H=2
SolidColor=#Color3#
AntiAlias=1

[MeterL4]
Meter=IMAGE
W=1
H=2
SolidColor=#Color4#
AntiAlias=1

[MeterL5]
Meter=IMAGE
W=1
H=2
SolidColor=#Color5#
AntiAlias=1

[MeterL6]
Meter=IMAGE
W=1
H=2
SolidColor=#Color6#
AntiAlias=1

[MeterT1]
Meter=STRING
X=255
Y=145
FontColor=FFFFFF
FontSize=8
StringStyle=BOLD
Text="#Tag1#"
AntiAlias=1

[MeterT2]
Meter=STRING
X=200
Y=50
FontColor=FFFFFF
FontSize=8
StringStyle=BOLD
StringAlign=CENTER
Text="#Tag2#"
AntiAlias=1

[MeterT3]
Meter=STRING
X=100
Y=50
FontColor=FFFFFF
FontSize=8
StringStyle=BOLD
StringAlign=CENTER
Text="#Tag3#"
AntiAlias=1

[MeterT4]
Meter=STRING
X=45
Y=145
FontColor=FFFFFF
FontSize=8
StringStyle=BOLD
StringAlign=RIGHT
Text="#Tag4#"
AntiAlias=1

[MeterT5]
Meter=STRING
X=100
Y=240
FontColor=FFFFFF
FontSize=8
StringStyle=BOLD
StringAlign=CENTER
Text="#Tag5#"
AntiAlias=1

[MeterT6]
Meter=STRING
X=200
Y=240
FontColor=FFFFFF
FontSize=8
StringStyle=BOLD
StringAlign=CENTER
Text="#Tag6#"
AntiAlias=1
Radar.lua:

Code: Select all

function Initialize()
	iCX=tonumber(SKIN:GetVariable("CenterX"))
	iCY=tonumber(SKIN:GetVariable("CenterY"))
	iR=tonumber(SKIN:GetVariable("Radius"))
	msC={}
	iC={}
	iRA={}
	iX={}
	iY={}
	iW={}
	iA={}
	for i=1,6 do
		msC[i]=SKIN:GetMeasure("MeasureCalc"..i)
		iRA[i]=(i-1)*math.pi/3
		SKIN:Bang("!SetOption MeterR"..i.." TransformationMatrix "..math.cos(iRA[i])..";"..-math.sin(iRA[i])..";"..math.sin(iRA[i])..";"..math.cos(iRA[i])..";"..iCX*(1-math.cos(iRA[i]))-iCY*math.sin(iRA[i])..";"..iCY*(1-math.cos(iRA[i]))+iCX*math.sin(iRA[i]))
	end
end

function Update()
	for i=1,6 do
		iC[i]=msC[i]:GetValue()
		iX[i]=iCX+iC[i]*iR*math.cos(iRA[i])
		iY[i]=iCY-iC[i]*iR*math.sin(iRA[i])
	end
	for i=1,6 do
		iW[i]=((iX[i%6+1]-iX[i])^2+(iY[i%6+1]-iY[i])^2)^0.5
		if (iX[i%6+1]-iX[i])<0 then
			iA[i]=math.atan((iY[i]-iY[i%6+1])/(iX[i%6+1]-iX[i]))+math.pi
		else
			iA[i]=math.atan((iY[i]-iY[i%6+1])/(iX[i%6+1]-iX[i]))
		end
		SKIN:Bang("!MoveMeter "..iX[i].." "..iY[i].." MeterL"..i)
		SKIN:Bang("!SetOption MeterL"..i.." W "..iW[i])
		SKIN:Bang("!SetOption MeterL"..i.." TransformationMatrix "..math.cos(iA[i])..";"..-math.sin(iA[i])..";"..math.sin(iA[i])..";"..math.cos(iA[i])..";"..iX[i]*(1-math.cos(iA[i]))-iY[i]*math.sin(iA[i])..";"..iY[i]*(1-math.cos(iA[i]))+iX[i]*math.sin(iA[i]))
	end
end
20120118092828.jpg
How to mess with it:
1.Add your own measures and use "MeasureCalc1"-"MeasureCalc6" to process them to values range 0.0-1.0
2.Change your chart's position, size, tags, colors in [Variables]
3.If you are good at LUA and math, you can even change the number of parameters and angles between each two parameters
You do not have the required permissions to view the files attached to this post.
Last edited by XANCI on January 18th, 2012, 3:50 am, edited 1 time in total.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Radar Chart Template

Post by smurfier »

FYI: Lua has a constant called math.pi
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
User avatar
XANCI
Posts: 104
Joined: September 18th, 2011, 6:37 am
Location: Nanjing, China

Re: Radar Chart Template

Post by XANCI »

smurfier wrote:FYI: Lua has a constant called math.pi
oops
User avatar
MaroonED
Posts: 61
Joined: November 6th, 2011, 4:50 pm
Location: Germany

Re: Radar Chart Template

Post by MaroonED »

XANCI,
this is really cool. Should come handy if I one day attempt to draw a static chart.
Thanks!
MaroonED
JayVodka
Posts: 9
Joined: January 14th, 2012, 5:37 am

Re: Radar Chart Template

Post by JayVodka »

Thanks again for answering my question!

Not only did you answer my question, but by doing so you were also able to create something new for the community to use.

Not satisfied with other skins, I decided to create my own and believed that a radar chart would be a fresh look. I hope to see more creations with this or similar code. :thumbup: