Robota Softwarehouse B.V.
  Home Company Products Projects Developers Contact Search  

Using Bezier curves on Symbian devices

The use of scalable vector graphics gets more and more important. For the new Symbian operating systems Symbian promised the implementation of Adobes SVG. The current Symbian API lacks an easy way to draw bezier curves. Here a short how-to.

For a little application on the Symbian device we needed to draw shapes drawn in vector graphics.

f1(u) = (1 - u)³ f2(u) = 3u(1 - u)² f3(u) = 3u²(1 - u) f4(u) = u³

Draw a Qubic bezier-spline based on four control points:


void DrawBezier(CWindowGc& aGc, TFPoint *pPoints, int nSegments) { aGc.MoveTo(TPoint(pPoints[0].iX, pPoints[0].iY)); float x,y; for(int i = 0; i < nSegments; i++) { BezierComputePoint(i / (float)nSegments, x, y, pPoints); aGc.DrawLineTo(TPoint(x,y)); } aGc.DrawLineTo(TPoint(pPoints[3].iX, pPoints[3].iY)); }

void BezierComputePoint(float fU, float& x, float &y, TFPoint* pSrcPoints) { float fBlend; float f1subu = 1.0f - fU;

// (1-u)^3 fBlend = f1subu * f1subu * f1subu; x = fBlend * pSrcPoints[0].iX; y = fBlend * pSrcPoints[0].iY;

// 3u(1-u)^2 fBlend = 3 * fU * f1subu * f1subu; x += fBlend * pSrcPoints[1].iX; y += fBlend * pSrcPoints[1].iY;

// 3u^2 * (1-u) fBlend = 3 * fU * fU * f1subu; x += fBlend * pSrcPoints[2].iX; y += fBlend * pSrcPoints[2].iY;

// u^3 fBlend = fU * fU * fU; x += fBlend * pSrcPoints[3].iX; y += fBlend * pSrcPoints[3].iY; }

Tags

General conditions (pdf) - Algemene voorwaarden (pdf) - Algemene voorwaarden (html)
Copyright 2005 Robota Softwarehouse B.V.. All rights reserved.

Robota Softwarehouse B.V. - Weth. Driessenstr. 71 - 1107XH - Amsterdam - The Netherlands - KvK 53227115
Email: info@robota.nl - Website: http://www.robota.nl - Telephone: +31203631747 - Tailor-made software since 1990