bezier

BezierPath and masking

戏子无情 提交于 2020-01-01 14:56:10
问题 I want to set up UIBezierPath as mask into my view: The goal is something like this: So i draw the View with frame: CGFloat round = 80; UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(self.frame.size.width/2-105, 0, 210, 60+round)]; myView.backgroundColor = [UIColor redColor]; And then try to add BezierMask: UIBezierPath *aPath = [UIBezierPath bezierPath]; CGSize viewSize = CGSizeMake(myView.frame.size.width, myView.frame.size.height); //(210,80) CGPoint startPoint = CGPointMake

Produce PDF files, draw polygons with rounded corners

隐身守侯 提交于 2020-01-01 05:33:06
问题 What's the right tool for the job if I want to write a Python script that produces vector graphics in PDF format ? In particular, I need to draw filled polygons with rounded corners (i.e., plane figures that are composed of straight lines and circular arcs ). It seems that matplotlib makes it fairly easy to draw rectangles with rounded corners and general polygons with sharp corners. However, to draw polygons with rounded corners, it seems that I have to first compute a Bézier curve that

Drawing Hermite curves in OpenGL

微笑、不失礼 提交于 2020-01-01 04:46:10
问题 How can I draw Hermite curves using OpenGL, are there any built in functions? I saw some examples on-line that show how to use evaluators to draw Bezier curves but could not find any information for Hermite curves. 回答1: Let the vector of control points for your Bezier be [b0 b1 b2 b3] and those for your Hermite be [h0 h1 v0 v1] (v0 and v1 being the derivative / tangent at points h0 and h1). Then we can use a matrix form to show the conversions: Hermite to Bezier [b0] = 1 [ 3 0 0 0] [h0] [b1]

Drawing a bezier curve between a set of given points

两盒软妹~` 提交于 2020-01-01 04:31:05
问题 What is the best way to draw a bezier curve, in iOS application, that passes through a set of given points 回答1: A little more generic way to do it can be achieved by, for example, looking at the BEMSimpleLineGraph GitHub Project (see here for more info: bemsimplelinegraph). Here I extracted a method to draw a bezier curve through a given list of points. The header file (BezierLine.h): #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import <CoreGraphics/CoreGraphics.h> @interface

Coordinate trigonometry - calculate midpoint in arc for flightpath

こ雲淡風輕ζ 提交于 2019-12-30 07:50:11
问题 I am trying to draw flightpaths on a map using SVGs. I'm using d3 on top of Leaflet, but the frameworks used shouldn't make a difference to my problem - it's trig. http://fiddle.jshell.net/zw8TR/26 The way I'm trying to do this is by creating a quadratic bezier curve (I'm open to other/easier ways if you know of any). What I need to calculate is 1 control point, perpendicular to the midpoint of each line. This point should always bias to a higher y value / latitude than the midpoint, to

Uniform discretization of Bezier curve

眉间皱痕 提交于 2019-12-30 07:25:27
问题 I need to discretise a 3rd order Bezier curve with points equally distributed along the curve. The curve is defined by four points p0, p1, p2, p3 and a generic point p(t) with 0 < t < 1 is given by: point_t = (1 - t) * (1 - t) * (1 - t) * p0 + 3 * (1 - t) * (1 - t) * t * p1 + 3 * (1 - t) * t * t * p2 + t * t * t * p3; My first idea was to discretise t = 0, t_1, ... t_n, ..., 1 This doesn't work as, in general, we don't end up with a uniform distance between the discretised points. To sum up,

Calculating the bounding box of cubic bezier curve

怎甘沉沦 提交于 2019-12-30 06:29:30
问题 I am trying to find an algorithm to calculate the bounding box of a given cubic bezier curve. The curve is in 3D space. Is there a mathematic way to do this except of sampling points on the curve and calculating the bounding box of these points? 回答1: Most of this is addressed in An algorithm to find bounding box of closed bezier curves? except here we have cubic Beziers and there they were dealing with quadratic Bezier curves. Essentially you need to take the derivatives of each of the

calculating parameters for defining subsections of quadratic bezier curves

最后都变了- 提交于 2019-12-30 05:12:06
问题 I have a quadratic bezier curve described as (startX, startY) to (anchorX, anchorY) and using a control point (controlX, controlY). I have two questions: (1) I want to determine y points on that curve based on an x point. (2) Then, given a line-segment on my bezier (defined by two intermediary points on my bezier curve (startX', startY', anchorX', anchorY')), I want to know the control point for that line-segment so that it overlaps the original bezier exactly. Why? I want this information

Find all the points of a cubic bezier curve in javascript

做~自己de王妃 提交于 2019-12-30 03:27:07
问题 I have a cubic bezier with 2 control points. Starting point and control points are known. Need to get all the points of the curve, given the control, starting and ending points. What I wanna to achieve is ..given a value i from 1 to length of curve.. get the X and Y and alpha (angle) of each point in that position. I cannot find a good reference or working code for that. I'm using javascript. 回答1: If I understand correctly, you are trying to determine the position and slope (tangent to the

Which JavaScript library can do boolean operations with bezier curves?

左心房为你撑大大i 提交于 2019-12-28 13:47:08
问题 Does a Javascript library exist which can perform boolean operations on paths (bezier curves)? I know about Paper.js and Raphael.js, but both cannot perform these actions now. 回答1: Paper.js now has boolean operations in its core: https://github.com/paperjs/paper.js/blob/master/src/path/PathItem.Boolean.js And here you can see the operations in action: http://assets.paperjs.org/boolean/ 回答2: If you convert path to polygons (eg. using pathelement.getPointAtLength()), then you can use Javascript