Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>three weeks? Seriously?<br> my clock is very fugly but it is a clock, and it looks good enough to guess the current time from it. </p> <pre><code>static inline float PGVmyRadians(double degrees) { return degrees * M_PI / 180; } - (void)drawRect:(CGRect)rect { CGFloat boundsWidth = self.bounds.size.width; CGFloat boundsHeight = self.bounds.size.height; CGPoint center = CGPointMake(boundsWidth/2, boundsHeight/2); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextClearRect(context, self.bounds); CGContextSetFillColorWithColor(context, [UIColor magentaColor].CGColor); CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor); CGContextSetLineWidth(context, 10); CGContextSetLineCap(context, kCGLineCapRound); CGContextAddArc(context, boundsWidth/2, boundsHeight/2, boundsWidth/2, PGVmyRadians(0), PGVmyRadians(360), 0); NSDateComponents *dateComponents = [[NSCalendar currentCalendar] components:(NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:[NSDate date]]; NSInteger seconds = [dateComponents second]; NSInteger minutes = [dateComponents minute]; NSInteger hour = [dateComponents hour]; if (hour &gt; 12) { hour -= 12; } CGFloat angleSec = ((seconds - 15) / 60.0) * 360.0; CGFloat thetaSec = PGVmyRadians(angleSec); CGFloat lengthSec = 0.9 * boundsHeight/2; CGFloat Xsec = center.x + lengthSec * cos(thetaSec); CGFloat Ysec = center.y + lengthSec * sin(thetaSec); CGContextMoveToPoint(context, center.x, center.y); CGContextAddLineToPoint(context, Xsec, Ysec); CGFloat angleMin = ((minutes - 15) / 60.0) * 360.0; CGFloat thetaMin = PGVmyRadians(angleMin); CGFloat lengthMin = 0.7 * boundsHeight/2; CGFloat Xmin = center.x + lengthMin * cos(thetaMin); CGFloat Ymin = center.y + lengthMin * sin(thetaMin); CGContextMoveToPoint(context, center.x, center.y); CGContextAddLineToPoint(context, Xmin, Ymin); CGFloat angleHour = ((hour - 3) / 12.0) * 360.0; CGFloat thetaHour = PGVmyRadians(angleHour); CGFloat lengthHour = 0.5 * boundsHeight/2; CGFloat Xhour = center.x + lengthHour * cos(thetaHour); CGFloat Yhour = center.y + lengthHour * sin(thetaHour); CGContextMoveToPoint(context, center.x, center.y); CGContextAddLineToPoint(context, Xhour, Yhour); CGContextStrokePath(context); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload