ちょっと必要だったので作りました。

ss

CoreGraphicsを使って、指定したCGRectの中に、指定した太さの×印(Cross Sign)を描画するためのPathを生成します。

objective-c>>
void PDPathAddCrossSign(CGMutablePathRef path, CGRect rect, CGFloat thickness)
{
CGFloat diff = rect.size.width - rect.size.height;
rect = CGRectDeflateRect(rect, MAX(0, diff/2), MAX(0, -diff/2));
CGFloat radius = rect.size.width/2;
CGFloat d = sqrt(2)*thickness/2;
CGFloat cx = CGRectGetMidX(rect), cy = CGRectGetMidY(rect);
CGAffineTransform transform = CGAffineTransformMakeTranslation(cx, cy);
CGPathMoveToPoint(path, &transform, d, 0);
for(int i = 0; i < 4; ++i){
CGPathAddLineToPoint(path, &transform, radius, radius - d);
CGPathAddLineToPoint(path, &transform, radius - d, radius);
CGPathAddLineToPoint(path, &transform, 0, d);
transform = CGAffineTransformRotate(transform, M_PI/2.0f);
}
CGPathCloseSubpath(path);
}
<<--

中で呼び出してるCGRectDeflateRectは以下のようなものです。

objective-c>>
CGRect CGRectInflateRect(CGRect rect, CGFloat width, CGFloat height)
{
rect.origin.x -= width;
rect.origin.y -= height;
rect.size.width += width2;
rect.size.height += height
2;
return rect;
}

CGRect CGRectDeflateRect(CGRect rect, CGFloat width, CGFloat height)
{
return CGRectInflateRect(rect, -width, -height);
}
<<--

これを使う事で、任意の大きさ、太さ、色で×印を描画できます。

posted by genki genki on Wed 4 Mar 2009 at 00:06 with 0 comments
Contents rssrss
光ファイバーを二次元振動させて走査するAR用ディスプレイ
因果の取り違え
Swift2's defer for CoffeeScript
mongodb-3.0からcreateIndexのdropDupsが無くなったらしい
mongodb-3.0以降のWiredTigerの設定を動的に変更する方法
一般楕円の高速生成アルゴリズムへの道標
farro mantecatoのレシピ
Droonga関連の記事のまとめ
RuntimeErrorの特定のメッセージに限定してrescueする方法
jQueryでscriptタグを実行せずにappendする
Tags
coffeescriptdefergroongajsmemonodenodejs
Comments rssrss
https://businessrost.ru/bitrix/redirect.php?goto=http%3A%2F%2Feximha.ch%2Fblog%2Findex.php%3Fid%3Dz85yj914%26abuse%3D1636 https://businessrost.ru/bitrix/redirect.php?goto=http%3A%2F%2Feximha.ch%2Fblog%2Findex.php%3Fid%3Dz85yj914%26abuse%3D1636: I have to thank you for the efforts you have put ... 04/26 06:43
http://ldm.sakura.ne.jp/balu+bbbs/album/album.cgi?mode=detail&no=210 http://ldm.sakura.ne.jp/balu+bbbs/album/album.cgi?mode=detail&no=210: Aw, this was an incredibly good post. Taking the t... 04/25 18:19
https://www.bigbeargum.com/2019/02/15/ambrose-redmoon/ https://www.bigbeargum.com/2019/02/15/ambrose-redmoon/: Hello would you mind letting me know which hosting... 04/25 17:39
http://zeroken.jp/1978td/album/album.cgi?mode=detail&no=20 http://zeroken.jp/1978td/album/album.cgi?mode=detail&no=20: Asking questions are genuinely fastidious thing if... 04/25 17:26
https://natucci-estetica.com/?attachment_id=1376 https://natucci-estetica.com/?attachment_id=1376: Hello there, You have done a fantastic job. I wi... 04/25 17:05
https://www.waimaoz.com/23019.html?unapproved=5151&moderation-hash=a14b2a811444fc3059edb7c1441d076e https://www.waimaoz.com/23019.html?unapproved=5151&moderation-hash=a14b2a811444fc3059edb7c1441d076e: Good day! Do you use Twitter? I'd like to follow y... 04/25 16:50
https://bysystem.ru/process-proizvodstva-kartonnyh-korobok-i/ https://bysystem.ru/process-proizvodstva-kartonnyh-korobok-i/: Требовалось производство картонных коробок в сжа... 04/25 15:33
https://marialionsa.ru/proizvodstvo-kartonnyh-korobok-i-upakovki/ https://marialionsa.ru/proizvodstvo-kartonnyh-korobok-i-upakovki/: Документооборот четкий, все закрывающие акты предо... 04/25 15:05