It is currently September 29th, 2024, 7:25 pm

Rotating text around central point

General topics related to Rainmeter.
User avatar
Fuzzybat23
Posts: 44
Joined: May 10th, 2013, 1:21 am

Rotating text around central point

Post by Fuzzybat23 »

Basically, I want to make a clock where the minute hand and hour hand are circles with text for the current minute and hour in the day, that rotate around a central point. Here's a picture for reference. The small circle is the hour hand, "2", and the big circle is the minute hand, "51" If anyone has any ideas, I'd greatly appreciate it!
You do not have the required permissions to view the files attached to this post.
User avatar
iNjUST
Posts: 117
Joined: June 20th, 2012, 12:44 am

Re: Rotating text around central point

Post by iNjUST »

I made a skin like this some time ago, and I'd be happy to share my method. The only screenshot I have at the moment is of a bunch of clock skins, but the one I'm referencing is green, red, and purple in the bottom, 2nd from the right here: http://imgur.com/a/LMz5B#0

Here's a run-down of how it works, since I don't have the skin compiled or released anywhere at the moment. You can use any of this code, I just ask if you share it or publish it anywhere to add me to the author information.

Define some variables for sizing the clock. The ClockRad is the overall radius (half the diameter) of the clock, and some fraction of this is used for all the other radii of the time divisions. The "Size" variables are the radii or half the width/height of each "dot" where the string is drawn:

Code: Select all

[Variables]
; radius of clock
ClockRad=100
; sizes of time orbits
HourRad=(#ClockRad#*0.4)
MinRad=(#ClockRad#*0.75)
SecRad=(#ClockRad#)
; sizes of time dots
HourSize=(#ClockRad#*0.2)
MinSize=(#ClockRad#*0.15)
SecSize=(#ClockRad#*0.1)
Measure the time, as per usual:

Code: Select all

;---Time---
[mTime]
Measure=Time
[mHour]
Measure=Time
Format=%#I
[mMin]
Measure=Time
Format=%M
[mSec]
Measure=Time
Format=%S
Here's the key part--calculating positions of each time "dot" or string around the clock, using a little math:

Code: Select all

;---Position---
[cHourX]
Measure=Calc
Formula=(#HourRad#*SIN(2*PI*FRAC(mTime/43200))-#HourSize#+#ClockRad#+#SecSize#)
[cHourY]
Measure=Calc
Formula=(-#HourRad#*COS(2*PI*FRAC(mTime/43200))-#HourSize#+#ClockRad#+#SecSize#)
[cMinX]
Measure=Calc
Formula=(#MinRad#*SIN(2*PI*FRAC(mTime/3600))-#MinSize#+#ClockRad#+#SecSize#)
[cMinY]
Measure=Calc
Formula=(-#MinRad#*COS(2*PI*FRAC(mTime/3600))-#MinSize#+#ClockRad#+#SecSize#)
[cSecX]
Measure=Calc
Formula=(#SecRad#*SIN(2*PI*FRAC(mTime/60))-#SecSize#+#ClockRad#+#SecSize#)
[cSecY]
Measure=Calc
Formula=(-#SecRad#*COS(2*PI*FRAC(mTime/60))-#SecSize#+#ClockRad#+#SecSize#)
Style your text how you see fit; use the manual for more string options:

Code: Select all

[sText]
FontFace=Tahoma
FontColor=255,255,255
StringAlign=CENTERCENTER
AntiAlias=1
Draw the Hours dot; use the same idea for minutes (and seconds if you wish). Create an image to be drawn behind the string (such as a circle, or nothing if you choose) and include it here:

Code: Select all

[HourCircle]
Meter=IMAGE
ImageName=INSERT_YOUR_BACKGROUND_IMAGE
X=[cHourX:]
Y=[cHourY:]
W=(#HourSize#*2)
H=(#HourSize#*2)
AntiAlias=1
DynamicVariables=1

[HourLabel]
MeasureName=mHour
Meter=STRING
MeterStyle=sText
X=(#HourSize#)r
Y=(#HourSize#)r
FontSize=(#HourSize#*0.67)
This should give you a good start. You can probably build off of this into a full functioning skin like you're aiming for. Let me know if you have any questions.
User avatar
Fuzzybat23
Posts: 44
Joined: May 10th, 2013, 1:21 am

Re: Rotating text around central point

Post by Fuzzybat23 »

Oh wow. I'm deffinitely going to have to digest that code when I'm actually awake, being as how I just rolled out of bed ;D Thanks dude!
User avatar
Fuzzybat23
Posts: 44
Joined: May 10th, 2013, 1:21 am

Re: Rotating text around central point

Post by Fuzzybat23 »

I'm keeping the meters along one edge of the monitor, haven't really figured out the overall circuit wall paper yet, but this is it so far. http://fuzzybat23.deviantart.com/art/Circuitry-Skins-390493727?ga_submit_new=10%253A1375784294&ga_type=edit&ga_changes=1