简体   繁体   English

内嵌非矩形

[英]Inset for non-rectangular shape

I am wondering is there any functionality in Core Graphics that will let you specify an inset for a non rectangular shape ie something comparable to CGRectInset? 我想知道核心图形中是否有任何功能可以让您为非矩形形状指定插入物,即与CGRectInset相当的东西? I'm creating a path that is comprised of a bunch of quadratic bezier curves which make up a special type of elipse, and I'd like to fit in a smaller type of elipse inside of it. 我正在创建一条由一系列二次贝塞尔曲线组成的路径,这些二次贝塞尔曲线构成特殊类型的椭圆,并且我想在其内部放入较小类型的椭圆。 Yes, I know I could probably do this manually, but wondering if Apple has an easy way to do it? 是的,我知道我可能可以手动执行此操作,但是想知道Apple是否有简单的方法来执行此操作?

CoreGraphics does not specify functions related to shapes other than *rect *angles because it doesn't have to. CoreGraphics没有指定与* rect * angles以外的形状相关的函数,因为它不是必须的。 Any drawing that you do is the own problem, and therefore, your own solution is required. 您所做的任何绘图都是自己的问题,因此,需要您自己的解决方案。 It would be possible to quasi-copy a CGRectMake() -esque element yourself (it's just ac struct). 可以自己复制CGRectMake() esque元素(它只是ac struct)。

struct CFIElipseRect {
   CGPoint origin;
   CGSize size;
   CGFloat arcLength;
   CGFloat vertices;
   CGFloat cornerRadius; //optional, just a thought.
};
typedef struct CFIElipseRect CFIElipseRect;


CFIElipseRect CFIElipseRectMake(CGPoint origin, CGSize size, CGFloat arcLength, CGFloat vertices, CGFloat cornerRadius) {
    CFIElipseRect rect;
    rect.origin = origin;
    rect.size = size;
    rect.arcLength = arcLength;
    rect.vertices = vertices;
    rect.cornerRadius = cornerRadius;
    return rect;
}

CFIElipseRect CFIElipseRectInset(CFIElipseRect rect, float dx, float dy) {
    rect.size.x -= dx;
    rect.size.y -= dy;
    return rect;
}

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

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