我用vb画了一个三角形,程序是line drawingg.Line(point1x,point1y)-(point1x+50,point1y+5

鐨勭敾绾匡紝鍙互鏇夸唬CAShapeLayer浼樺寲-ios,iphone,objective-c,浼樺寲optimization,cashapelayer-CodeGo.net
鐨勭敾绾匡紝鍙互鏇夸唬CAShapeLayer浼樺寲
鎴戦渶瑕佸湪灞忓箷鍜屼笅鏂圭殑鍑芥暟涓哄畠宸ヤ綔姝e父缁樺埗澶氳锛堝湪50-75鐨勮寖鍥村唴锛夈傜敾杩欎簺绾夸笌涓嬮潰鐨勪唬鐮40-50鍚庯紝搴旂敤绋嬪簭鍦ㄦ垜鐨刬Phone 4鍙樻參鏄庢樉瑕佷紭鍖栨垜璇曠潃鍘绘帀灏辫褰卞瓙瀹冨府鍔╋紝浣嗕粛鐒跺簲鐢ㄧ▼搴忔湭杩愯锛屽洜涓烘垜鎯宠鐨勯偅鏍烽『鍒┿傛垜闇瑕佷紭鍖栦笅闈㈢殑浠g爜锛屾垜鐨勪紭鍏堜釜鎯虫硶鏄笌宸寸航绾挎潯鍥惧儚鏇挎崲cashapelayers銆備絾鏄紝搴旇鏀寔绾挎棆杞紝瀹藉害涓嶅悓闀垮害鐨勭嚎 CodeGo.net锛屽苟缁樺埗鍔ㄧ敾锛堜技涔庡緢澶氫簨鎯呰鍋氫换浣曟兂娉曪紝鍙互
+ (CAShapeLayer *) drawLineOnView:(UIView *) view BetweenPoint1:(CGPoint) point1 Point2:(CGPoint) point2 lineWidth:(CGFloat)lineWidth lineColor:(UIColor *) color Animated:(BOOL) animed
CAShapeLayer *lineShape = [CAShapeLayer layer];
CGMutablePathRef linePath =
linePath = CGPathCreateMutable();
//lineShape.opacity = 0.6;
lineShape.lineWidth = lineW
lineShape.lineCap = kCALineCapR
if(color==nil) color = [UIColor orangeColor]; //Default value
lineShape.shadowColor = [color CGColor];
lineShape.shadowOpacity = 1.0;
lineShape.shadowRadius = 5.0;
lineShape.strokeColor = [color CGColor];
CGPathMoveToPoint(linePath, NULL, point1.x, point1.y);
CGPathAddLineToPoint(linePath, NULL, point2.x, point2.y);
if(animed)
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = 1.0;
pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
[lineShape addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
lineShape.path = lineP
CGPathRelease(linePath);
[view.layer addSublayer:lineShape];
return lineS
閮ㄥ垎瑙e喅锛堜紭鍖栨案杩滀笉浼氱粨鏉燂級
鎴戞墦鐮翠簡鎴戠殑鐢荤嚎鍑芥暟鍒嗕负涓ら儴鍒嗭紝骞剁粯鍒跺琛屾垚涓涓舰鐘跺浘灞傦紝鑰屼笉鏄垱閫犳瘡涓涓柊鐨勫浘灞傚畠鐨勫伐浣滃師鐞嗭紝濡傛灉娌℃湁寰堝ぇ鐨勮濂藉緱澶氥備互涓嬫槸鏇存柊鍚庣殑浠g爜锛
+ (CAShapeLayer *) createNewShapeLayerForDrawingLinesOnView:(UIView *) view lineWidth:(CGFloat)lineWidth lineColor:(UIColor *) color
CAShapeLayer *lineShape = [CAShapeLayer layer];
//lineShape.opacity = 0.6;
lineShape.lineWidth = lineW
lineShape.lineCap = kCALineCapR
if(color==nil) color = [UIColor orangeColor]; //Default value
lineShape.shadowColor = [color CGColor];
lineShape.shadowOpacity = 1.0;
lineShape.shadowRadius = 5.0;
lineShape.strokeColor = [color CGColor];
[view.layer addSublayer:lineShape];
return lineS
+ (void) addNewLineToShapeLayer:(CAShapeLayer *) shapeLayer BetweenPoint1:(CGPoint) point1 Point2:(CGPoint) point2
CGMutablePathRef combinedPath = CGPathCreateMutableCopy(shapeLayer.path);
CGMutablePathRef linePath = CGPathCreateMutable();
CGPathMoveToPoint(linePath, NULL, point1.x, point1.y);
CGPathAddLineToPoint(linePath, NULL, point2.x, point2.y);
//No paths drawn before
if(combinedPath == NULL)
combinedPath = lineP
CGPathAddPath(combinedPath, NULL, linePath);
shapeLayer.path = combinedP
CGPathRelease(linePath);
鏈枃鍦板潃 锛欳odeGo.net/9563382/
-------------------------------------------------------------------------------------------------------------------------
1.鑰屾嵁鎴戞墍鐭ワ紝瑕佸缓绔嬪灞傛锛岃繖灏嗘槸鏇存湁鏁堢殑涓烘墍鏈夌殑绾跨敾鎴愪竴涓紝骞朵粠閭i噷绠$悊琛岀殑鍒楄〃涓殑鍔ㄧ敾鍜屾棆杞傛偍鍙互鍦ㄥ舰鐘跺眰鍍忥紙鏍囨湁缂虹爜鈥......鈥濓級璺緞鍋氬埌杩欎竴鐐癸細
CGMutablePathRef combinedPath = CGPathCreateMutableCopy(path.CGPath);
CGPathAddPath(combinedPath, NULL, [self makeNewPathFrom:...].CGPath);
myLayer.path = combinedP
鏇村揩锛屼綘鍙互鐢荤嚎鐨勫悕鍗曪紝鐩存帴鍒扮殑CALayer鐨勫浘褰笂涓嬫枃銆傝繖涓緥瀛愪腑鐨勮鍥剧殑drawRect:鏂规硶鏄湭缁忔祴璇曪紝浣嗗簲璇ョ粰浣犱竴涓兂娉曪細
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, lineWidth);
CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0); //red
for(MyLine *line in lines)
CGContextMoveToPoint(context, point1.x, point1.y);
CGContextAddLineToPoint(context, point2.x, point2.y);
濡傛灉鎮ㄩ渶瑕佽繘涓姝ョ殑浼樺寲 CodeGo.net锛屼綘搴旇鑰冭檻鐨凮penGL銆
浣犺偗瀹氫笉甯屾湜75灞傦紝姣忎釜閮芥湁鑷繁鐨勭嚎璺備綘纭畾浣犲彲浠ヤ笉鐢讳竴涓紝璺緞鍗曞眰锛
鏈枃鏍囬 锛氱殑鐢荤嚎锛屽彲浠ユ浛浠AShapeLayer浼樺寲
鏈枃鍦板潃 锛欳odeGo.net/9563382/
Copyright 漏 2014 CodeGo.net扫一扫关注官方微信502 Bad Gateway
502 Bad Gateway计算机图形学实验报告1_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
计算机图形学实验报告1
上传于||暂无简介
阅读已结束,如果下载本文需要使用0下载券
想免费下载更多文档?
下载文档到电脑,查找使用更方便
还剩17页未读,继续阅读
你可能喜欢c++程序编写_百度知道
c++程序编写
定义友元函数判断两条线段是否相等等、计算线段长度、Point拷贝构造函数等,用以表示一个线段的两个端点定义一个Line类,包含两个Point类的实例变量、计算线段的中点。定义Point构造函数;定义Line构造函数。最后定义测试类测试之
y=%f&double line2_length = line2.x;线段中间点Line a(Point(0;}double left = 0;/ b,};printf(&两条线是否相等测试Line p(Point(50.y &gt? b,100).y);printf(&}Line(Point xy1, Point(50;bool f=L&#47.center_point();b, q).y -Line q(Point(10.y = fabs(a;}}},re), Point xy2){a = xy1,Point(90;double re =return Point(x.x &中间点坐标为.length(), top = 0;}else{相等&quot, 10),Line line2){double line1_length = line1;y = 0.x) + fabs(a.y)*fabs(a, a.y = 0, double x2;}static bool dengyu(Line line1:Line(){a.y , right = 0:double length(){return sqrt(fabs(a.x); 2.x = 0;x = x + ((a, 100));y = y + ((a:, right = x2, Point(10:%f&quot?/).x - b:Point(){x = 0;a;Point a, double b){x =class Line{ 2.x) &#47, Point(100: a.y - b.y);不相等&quot, 50));}Line(double x1;长度为.y) &#47.y - b, b = xy2;}else{printf(&&#47.x)*fabs(a, double y1.y) ,50);}double x = 0;, y = 0;if (f){printf(&), 0), bottom = y2;y = b,180));线段长度测试Line p(Point(5:dengyu(p;}Point center_point(){x = fabs(a,}Point(double a, y);}&#47.x - b, top = y1;).center_point().y)).x) ;&#47.x -if (line1_length == line2_length){return true.x = 0.length();double xclass Point{b.y = 0,a.length(),10)), double y2){left = x1, bottom = 0
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁}

我要回帖

更多关于 line drawing是什么 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信