# TIP #168 Version 1.2: Cubic Bezier Curves on the Canvas

This is not necessarily the current version of this TIP.

 TIP: 168 Title: Cubic Bezier Curves on the Canvas Version: \$Revision: 1.2 \$ Author: Lars Hellström State: Draft Type: Project Tcl-Version: 8.5 Vote: Pending Created: Sunday, 25 January 2004

## Abstract

This document proposes a new -smooth method for line and polygon canvas items that supports cubic Bezier curves and clarifies some of the existing terminology in that area.

## Proposal

A new method for the -smooth canvas item option will be defined. Under this method, the points defining the item will be interpreted as a sequence knot-point control-point control-point knot-point control-point control-point ... of a curve composed of cubic Bezier segments. More precisely, if the list of coordinates is

```  a_0 b_0 a_1 b_1 a_2 b_2 ...
```

then the Nth (counting from zero) segment of the curve consists of points whose coordinates (x,y) satisfies

```  x = a_{3N} (1-t)^3 + 3 a_{3N+1} t (1-t)^2 + 3 a_{3N+2} t^2 (1-t) + a_{3N+3} t^3,
y = b_{3N} (1-t)^3 + 3 b_{3N+1} t (1-t)^2 + 3 b_{3N+2} t^2 (1-t) + b_{3N+3} t^3
```

for some value of t between 0 and 1, inclusive. If there are 3N+1 points then the above defines an N segment curve. In the case that the number of points is 3N or 3N-1 then they shall still define an N segment curve, where in the first case the first knot of the first segment is reused as the last knot in the last segment, and in the second case the first knot and control point in the first segment are reused as the last control point and knot in the last segment respectively.

Straight line segments in the curve can be encoded as a segment where the control points are equal to the neighbouring knot points. While this is not the only way to encode a straight line, it is a case that is recognised and handled more efficiently by code that renders the canvas item.

The name of this new method should be "raw".

The name of the existing -smooth method (as returned by the itemcget widget command) should be changed from "bezier" to "true", and the name "bezier", while at least in Tcl 8.5 still supported, should be deprecated.

## Rationale

Cubic Bezier curves, being for example the native curve format in Postscript and its descendants,