Login to WatchAwear


math.max() and math.min()

These are good to know about on general principles, and have particular applications in hand movements. The math.max() function simply returns the largest of its arguments, however many there are, and math.min() returns the smallest. This is useful when you want to “cap” a value so it doesn't exceed or fall below a certain value, even when the usual calculation for it would move it past. So for example (a little contrived), if you wanted a smooth second hand that went around the dial in only 55 seconds and then stopped at 12:00 for 5 seconds until the next minute started, you might try setting the rotation to {drss}*60/55, but then the hand wouldn't stop at 12:00, it would carry on for another 5 seconds and then snap back at the top of the minute. But math.min(360, {drss}*60/55) would work: the value would be capped at 360. Using math.max(0, something) is good for making sure the result never goes negative.

Published by Mark Shoulson on 27 August 2015WatchMaker Tips & Tricks Posted

Download the
'WatchAwear - Resources for WatchMaker' App

WatchAwear - Companion for WatchMaker

Download The Best Watch Designing App
for Wear OS, and Tizen:

WatchMaker Beautiful Watches for Android Wear

No smartwatch required!!
Best clock wallpaper for Android!

WatchMaker Live WallPaper