CoreGraphics を使った角丸長方形(RoundRect) を描画するためのメソッドです。

   1  - (void)
   2  drawRoundRect:(CGRect)rect
   3  withRadius:(CGFloat)radius
   4  inContext:(CGContextRef)context
   5  {	
   6    CGFloat lx = CGRectGetMinX(rect);
   7    CGFloat cx = CGRectGetMidX(rect);
   8    CGFloat rx = CGRectGetMaxX(rect);
   9    CGFloat by = CGRectGetMinY(rect);
  10    CGFloat cy = CGRectGetMidY(rect);
  11    CGFloat ty = CGRectGetMaxY(rect);
  12  	
  13    CGContextMoveToPoint(context, lx, cy);
  14    CGContextAddArcToPoint(context, lx, by, cx, by, radius);
  15    CGContextAddArcToPoint(context, rx, by, rx, cy, radius);
  16    CGContextAddArcToPoint(context, rx, ty, cx, ty, radius);
  17    CGContextAddArcToPoint(context, lx, ty, lx, cy, radius);
  18    CGContextClosePath(context);
  19    CGContextDrawPath(context, kCGPathFillStroke);
  20  }

角丸が好きなので多用しそうな気がします。 事前にStrokeやFillの色を設定してお使いください。

posted by Png genki on Wed 22 Oct 2008 at 01:39

研究室で話してたら、驚かれた。

意外と知ってる人少ない??

コード

   1  #include<stdio.h>
   2  
   3  int main(int argc, char *argv[], char *env[])
   4  {
   5  
   6    printf("%d\n", printf("Hello, World.\n"));
   7  
   8    return(0);
   9   
  10  }

実行結果

   1  $ ./printf_return
   2  Hello, World.
   3  14

ってことで、出力された文字列のバイト数が戻り値となります。

また、出力に失敗した場合は、負の値が入るとのことです。

posted by Png y_tsuda on Tue 21 Oct 2008 at 23:51
Contents
CoreGraphics (aka Quartz) で角丸長方形を描画する
printfの戻り値
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
KingofSmack: Here also good reads for this mobile applicatio... '14-5
Spencer: You don't have to re-compile it, this version w... '14-4
staiano: Any chance we can get a recompile for 10.9? '14-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ