bezier

Finding min/max of quadratic bezier with CoreGraphics

百般思念 提交于 2019-12-08 17:39:58
问题 I am using CoreGraphics to draw a quadratic bezier but want to computer the min/max value of the curve. I am not from a mathematical background so this has become a bit troublesome. Does anyone have any articles or ideas about how to solve this? 回答1: For a quadratic Bezier, this is actually quite simple. Define your three control points as P0 = (x0,y0) , P1 = (x1,y1) and P2 = (x2,y2) . To find the extrema in x , solve this equation: t = (x0 - x1) / (x0 - 2*x1 + x2) If 0 <= t <= 1 , then

how to make a parallel bezier curve heuristically

守給你的承諾、 提交于 2019-12-08 08:15:54
问题 I have only found this blog with a relevant answer http://seant23.wordpress.com/2010/11/12/offset-bezier-curves/ ,but unfortunately i don't know the language and can't understand the maths behind it. What i need is to know how to make a bezier curve parallel to the one that i have. I have a Point, Segment and Path class, but i don't understand how to divide the path into segments. The Point class has the CGPoint location public variable, the Segment class has as properties 4 points, Point

How to determine curvature of a cubic bezier path at an end point

↘锁芯ラ 提交于 2019-12-08 06:19:13
问题 I've been working on a project where I use Bezier paths to draw the curves I need. Each basic shape in my project consists of three cubic Bezier curves arranged end to end so that the slopes match where they meet. The basic problem I need to solve is whether the compound curve made of the three Bezier curves intersects with itself. After thinking about it for a while, I've figured out that given the constraints of the curves, I can simplify the task to something else: The curvature of each of

PaintCode - move object on the path

自闭症网瘾萝莉.ら 提交于 2019-12-08 03:52:37
问题 I would like draw a curved line and attach an object to it. Is it possible to create fraction (from 0.0 to 1.0) which makes move my object on the path? When fraction is 0 then object is on the beginning, when 0.5 is on half way and finally when is on 1.0 it is at the end. Of course i want a curved path, not a straight line :) Is it possible to do in PaintCode? 回答1: If you need it only as a progress bar , it is possible in PaintCode. The trick is to use dashed stroke with very large Gap and

Create a UIView with rounded top edge

此生再无相见时 提交于 2019-12-08 03:30:25
问题 I would like to create an UIView with rounded top edge like this image, how can I do it please? Wanted result Not wanted result 回答1: To repost an answer I posted on a different thread: I can now confirm that this is a bug introduced after iOS 6. I have an old 4s running iOS 6.1. On that machine, this code: path = [UIBezierPath bezierPathWithRoundedRect: bounds byRoundingCorners: UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii: CGSizeMake(bounds.size.width/2, bounds.size.width/6) ];

How to simplify cubic bezier curve?

放肆的年华 提交于 2019-12-08 02:53:49
问题 I have a Cubic Bezier curve comprises of a number of segments (left image). It has some rough curvature and I need to make it smoother like the right image. This problem is somewhat like "noise reduction", how do I achieve this? There's similar thread here, but the input is a set of point and fitting a bezier curve on it using least square, but in my problem the input is already cubic bezier. On image above I don't draw the segments and control points but I hope you get the idea. 回答1: Do you

Cocos2d 2.x: understanding ccBezierConfig beheaviour

浪子不回头ぞ 提交于 2019-12-08 02:29:56
问题 I am on this since a while and time ago I asked a question and a user kindly replied to me explaning that there is this plugin tool that I can use to create quick bezier curves prototypes. I tried and produced this: I thought it would be perfectly translated in this ccBezierConfig: ccBezierConfig bezier; self.position = CGPointMake(-10.0f, 400.0f); bezier.controlPoint_1 = CGPointMake(160, 190.0f); bezier.controlPoint_2 = CGPointMake(200, 190.0f); bezier.endPosition =CGPointMake(340.0f,280.0f)

how to calculate control points on a bezier curve?

倾然丶 夕夏残阳落幕 提交于 2019-12-08 01:18:36
问题 I do have a bezier curve, and at a certain point, I want a second bezier curve "branching off" the first curve in a smooth manner. Together with calculating the intersection point (with a percentage following the Bezier curve), I need also the control point (the tangent and weight). The intersection point is calculated with the following piece of javascript: getBezier = function getBez(percent,p1,cp1,cp2,p2) { function b1(t) { return t*t*t } function b2(t) { return 3*t*t*(1-t) } function b3(t

Jigsaw Puzzle pices using Bezier Curve

ⅰ亾dé卋堺 提交于 2019-12-07 23:37:07
问题 I was trying to make some jigsaw pieces like this - What I have tried till now with lineTo - outside: function (ctx, s, cx, cy) { ctx.lineTo(cx, cy) ctx.lineTo(cx+s*.3, cy) ctx.lineTo(cx+s*.5, cy+s*-.2) ctx.lineTo(cx+s*.7, cy) ctx.lineTo(cx+s, cy) }, inside: function (ctx, s, cx, cy) { ctx.lineTo(cx, cy) ctx.lineTo(cx+s*.3, cy) ctx.lineTo(cx+s*.5, cy+s*+.2) ctx.lineTo(cx+s*.7, cy) ctx.lineTo(cx+s, cy) }, Fiddle Link 回答1: Efficient Jigsaw design is simple and it works like this: The linked

How to draw absolutely custom shape in Java?

只愿长相守 提交于 2019-12-07 18:23:50
问题 The most complex shape, supported by Java2D API is a Bezier segment. Suppose I want to draw rational segment (each control point has a weight and the entire rendering formula is slightly different). How to accomplish that? Is it possible to extend rendering engine to be able to draw more complex shapes? UPDATE Usual way to implement custom shape is implementing Shape interface. This interface has key methods to return PathIterator while PathIterator iterates over segment types. There are only