简体   繁体   English

在iPad App中绘制带发光效果的线条

[英]Draw lines with Glow effect in iPad App

I have integrate draw line in my application i have not used OpenGL or any other similar framework.我在我的应用程序中集成了画线我没有使用OpenGL或任何其他类似的框架。

So now i want to give glow effect to their lines so how can i give it?所以现在我想给他们的线条带来发光效果,我该如何给它呢?

Thanks in advance.提前致谢。

Set the shadow in your graphics context to have a zero size offset, a blur of around 6-10 (change according to taste) and the same colour as your stroke colour.将图形上下文中的阴影设置为零大小偏移、大约 6-10 的模糊(根据口味更改)和与笔触颜色相同的颜色。 This will give all subsequent drawing a glow effect.这将为所有后续绘图提供发光效果。 The command is命令是

CGContextSetShadowWithColor()

Documented here .记录在这里

-(void)drawRect:(CGRect)rect{

[curImage drawAtPoint:CGPointMake(0, 0)];

 CGPoint mid1 = midPoint(previousPoint1, previousPoint2); 

 CGPoint mid2 = midPoint(currentPoint, previousPoint1);

    CGContextRef context = UIGraphicsGetCurrentContext(); 

    [self.layer renderInContext:context];

    CGContextMoveToPoint(context, mid1.x, mid1.y);
    // Use QuadCurve is the key
    CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y); 

    CGContextSetLineCap(context, kCGLineCapRound);
    CGContextSetLineWidth(context, self.lineWidth);
    CGContextSetStrokeColorWithColor(context, self.lineColor.CGColor);
        //------------  Glow Lines ----------

    if (appDel.BrushType == 201) // (201 is glow brush type)
    {
        CGContextSetLineWidth(context, 7);

        CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();

        CGFloat components[4]={appDel.R_color/255.0,appDel.G_color/255.0,appDel.B_color/255.0,1.0};
        CGColorRef color1 = CGColorCreate(space, components);

        CGContextSetShadowWithColor(context, CGSizeMake( 0.0, 0.0 ), 15, color1);

        CGContextStrokePath(UIGraphicsGetCurrentContext());

    }
    //--------------
    CGContextStrokePath(context);
    [super drawRect:rect];

    [curImage release];


}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM