图片绕某一圆心画圆

//关键帧动画之多边形路径

-(void)keyframeAnimation

{

    

    UIImageView *imgView = (UIImageView *)[self.cycleView viewWithTag:10010];


    UIBezierPath* aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(KeyCycleViewDiameter/2.0, KeyCycleViewDiameter/2.0)

                                                         radius:(KeyCycleViewDiameter-10)/2.0

                                                     startAngle:-M_PI/2.0

                                                       endAngle:3*M_PI/2.0

                                                      clockwise:YES];

    

    aPath.lineWidth = 5.0;

    aPath.lineCapStyle = kCGLineCapRound; //线条拐角

    aPath.lineJoinStyle = kCGLineCapRound; //终点处理

    

    //创建关键帧动画

    CAKeyframeAnimation *keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];

    keyframeAnimation.path = aPath.CGPath;

    keyframeAnimation.fillMode = kCAFillModeForwards;

    keyframeAnimation.removedOnCompletion = NO;

    keyframeAnimation.duration = 3.0;

    [imgView.layer addAnimation:keyframeAnimation forKey:@"keyframe"];

}



江总给我的原来的:

//关键帧动画之多边形路径
-(void)keyframeAnimation{
    
    UIView *animationView = [[UIView alloc] initWithFrame:CGRectMake(10, 5, 30, 30)];
    animationView.backgroundColor = [UIColor grayColor];
    [self.view addSubview:animationView];
    
    //曲线
    UIBezierPath *movePath = [UIBezierPath bezierPath];
    [movePath moveToPoint:CGPointMake(150, 15)];//设置当前起点(必须先设置起始点,再次添加曲线后会自动更新结束点,可添加多个形成波浪形)
    [movePath addCurveToPoint:CGPointMake(150, 200) controlPoint1:CGPointMake(200, 20) controlPoint2:CGPointMake(100, 180)];
    [movePath addCurveToPoint:CGPointMake(150, 400) controlPoint1:CGPointMake(200, 220) controlPoint2:CGPointMake(100, 380)];
    
    //创建关键帧动画
    CAKeyframeAnimation *keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    keyframeAnimation.path = movePath.CGPath;
    keyframeAnimation.fillMode = kCAFillModeForwards;
    keyframeAnimation.removedOnCompletion = NO;
    keyframeAnimation.duration = 3.0;
    [animationView.layer addAnimation:keyframeAnimation forKey:@"keyframe"];
}

vertices[start].coordinate.x = 0; vertices[start].coordinate.y = height / 2.0f; vertices[start].coordinate.z =0; vertices[start].texture.s =0.5f; vertices[start].texture.t =0.5f; vertices[start].color.r =1.0f; vertices[start].color.g =1.0f; vertices[start].color.b =1.0f; ++start; for (int i = 0; i < longSegments + 1; i++) { vertices[i + start].coordinate.x = radius * cos(glm::pi<float>() * 2 - i * fTheta); vertices[i + start].coordinate.y = height / 2.0f; vertices[i + start].coordinate.z = radius * sin(glm::pi<float>() * 2 - i * fTheta); vertices[i + start].texture.s = 0.5f + 0.5f * cos(glm::pi<float>() * 2 - i * fTheta); vertices[i + start].texture.t = 0.5f + 0.5f * sin(glm::pi<float>() * 2 - i * fTheta); vertices[i + start].color.r = 1.0f; vertices[i + start].color.g = 1.0f; vertices[i + start].color.b = 1.0f; } start += longSegments + 1; //生成下底顶点数据,请补充代码 vertices[start].coordinate.x =0; vertices[start].coordinate.y = -height / 2.0f; vertices[start].coordinate.z =0.0f; vertices[start].texture.s = 0.5f; vertices[start].texture.t = 0.5f; vertices[start].color.r = 1.0f; vertices[start].color.g = 1.0f; vertices[start].color.b = 1.0f; ++start; for (int i = 0; i < longSegments + 1; i++) { vertices[i + start].coordinate.x = radius * cosf(i * fTheta); vertices[i + start].coordinate.y = -height / 2.0f; vertices[i + start].coordinate.z = radius * sinf(i * fTheta); vertices[i + start].texture.s = 0.5f + 0.5f * cosf(i * fTheta); vertices[i + start].texture.t = 0.5f + 0.5f * sinf(i * fTheta); vertices[i + start].color.r = 1.0f; vertices[i + start].color.g = 1.0f; vertices[i + start].color.b = 1.0f; } //createBuffer(sizeof(TextureColorVertex), true); verticesSize = numVertices * sizeof(TextureColorVertex); GLsizei stride = sizeof(TextureColorVertex); createBuffer(stride, false); // 不需要 EBO delete[]vertices; revolutionAngle = 0.0f; //公转角度(X轴,在YZ平面环) rotationAngle = 0.0f; //自转角度 revolutionSpeed = 5.0f; //公转角速度 rotationSpeed = 1.0f; //自转角速度 没看懂
最新发布
11-05
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值