TweetFollow Us on Twitter

Bezier Curve
Volume Number:5
Issue Number:1
Column Tag:C Workshop

Related Info: Quickdraw

Bezier Curve Ahead!

By David W. Smith, Los Gatos, CA

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

David W. Smith (no known relation to the Editor) is a Sr. Software Engineer at ACM Research, Inc., in Los Gatos.

There comes a time in the development of some applications when arcs and wedges just don’t cut the mustard. You want to draw a pretty curve from point A to point B, and QuickDraw isn’t giving you any help. It seems like a good time to reach for a computer graphics text, blow the dust off of your college math, and try to decipher their explanation of splines. Stop. All is not lost. The Bezier curve may be just what you need.

Bezier Curves

Bezier curves (pronounced “bez-yeah”, after their inventor, a French mathematician) are well suited to graphics applications on the Macintosh for a number of reasons. First, they’re simple to describe. A curve is a function of four points. Second, the curve is efficient to calculate. From a precomputed table, the segments of the curve can be produced using only fixed-point multiplication. No trig, no messy quadratics, and no inSANEity. Third, and, to some, the most important, the Bezier curve is directly supported by the PostScript curve and curveto operators, and is one of the components of PostScript’s outlined fonts. The Bezier curve is also one of the principle drawing elements of Adobe Illustrator™. (Recently, they’ve shown up in a number of other places.)

Bezier curves have some interesting properties. Unlike some other classes of curves, they can fold over on themselves. They can also be joined together to form smooth (continuous) shapes. Figure 1 shows a few Bezier curves, including two that are joined to form a smooth shape.

The Gruesome Details

The description of Bezier curves below is going to get a bit technical. If you’re not comfortable with the math, you can trust that the algorithm works, and skip ahead to the implementation. However, if you’re curious about how the curves work and how to optimize their implementation, or just don’t trust using code that you don’t understand, read on.

The Bezier curve is a parametric function of four points; two endpoints and two “control” points. The curve connects the endpoints, but doesn’t necessarily touch the control points. The general form Bezier equation, which describes each point on the curve as a function of time, is:

where P1 and P4 are the endpoints, P2 and P3 are the control points, and the wn’s are weighting functions, which blend the four points to produce the curve. (The weights are applied to the h and v components of each point independently.) The single parameter t represents time, and varies from 0 to 1. The full form of the Bezier curve is:

We know that the curve touches each endpoint, so it isn’t too surprising that at t=0 the first weighting function is 1 and all others are 0 (i.e., the initial point on the curve is the first endpoint). Likewise, at t=1, the fourth weighting function is 1 and the rest are 0. However, it’s what happens between 0 and 1 that’s really interesting. A quick side-trip into calculus to take some first derivatives tells us that the second weighting function is maximized (has its greatest impact on the curve) at t=1/3, and the third weight is maximized at t=2/3. But the clever part--the bit that the graphics books don’t bother to mention--run the curve backwards by solving the equation for 1-t, and you find that w1(t)=w4(1-t) and w2(t)=w3(1-t). As we’ll see below, this symmetry halves the effort needed to compute values for the weights.

Figure 1. Some Beizer Curves and Shapes

Implementing Bezier Curves

One strategy for implementing Bezier curves is to divide the curve into a fixed number of segments and then to pre-compute the values of the weighting functions for each of the segments. The greater the number of segments, the smoother the curve. (I’ve found that 16 works well for display purposes, but 32 is better for hardcopy.) Computing any given curve becomes a simple matter of using the four points and the precomputed weights to produce the end-points of the curve segments. Fixed-point math yields reasonable accuracy, and is a hands down winner over SANE on the older (pre-Mac II) Macs, so we’ll use it.

We can optimize the process a bit. The curve touches each endpoint, so we can assume weights of 0 or 1 and needn’t compute weights for these points. Another optimization saves both time and space. By taking advantage of the symmetric nature of the Bezier equation, we can compute arrays of values for the first two of the weighting functions, and obtain values for the other two weights by indexing backwards into the arrays.

Drawing the curve, given the endpoints of the segments, is the duty of QuickDraw (or of PostScript, if you’re really hacking).

The listing below shows a reasonably efficient implementation of Bezier curves in Lightspeed C™. A few reminders about fixed-point math: an integer times a fixed-point number yields a fixed-point number, and a fixed by fixed multiplication uses a trap. The storage requirement for the algorithm, assuming 16 segments, (32 fixed-point values), is around 32*4*4, or 512 bytes. The algorithm computes all of the segments before drawing them so that the drawing can be done at full speed. (Having all of the segments around at one time can be useful for other reasons.)

More Fun With Curves

Given an implementation for Bezier curves, there are some neat things that fall out for almost free. Drawing a set of joined curves within an OpenPoly/ClosePoly or an OpenRgn/CloseRgn envelope yields an object that can be filled with a pattern. (Shades of popular illustration packages?) For that matter, lines, arcs, wedges, and Bezier curves can be joined to produce complicated shapes, such as outlined fonts. Given the direct mapping to PostScript’s curve and curveto operators, Bezier curves are a natural for taking better advantage of the LaserWriter.

As mentioned above, Bezier curves can be joined smoothly to produce more complicated shapes (see figure 1). The catch is that the point at which two curves are joined, and the adjacent control points, must be colinear (i.e., the three points must lay on a line). If you take a close look at Adobe Illustrator’s drawing tool, you’ll see what this means.

One nonobvious use of Bezier curves is in animation. The endpoints of the segments can be used as anchor-points for redrawing an object, giving it the effect of moving smoothly along the curve. One backgammon program that I’ve seen moves the tiles along invisible Bezier curves, and the effect is very impressive. For animation, you would probably want to vary the number of segments. Fortunately, the algorithm below is easily rewritten to produce the nth segment of an m segment curve given the the end and control points.

Further Optimizations

If you’re really tight on space or pressed for speed, there are a few things that you can do to tighten up the algorithm. A bit of code space (and a negligible amount of time) can be preserved by eliminating the setup code in favor of statically initializing the weight arrays with precomputed constant values. Drawing can be optimized by using GetTrapAddress to find the address in ROM of lineto, and then by calling it directly from inline assembly language, bypassing the trap mechanism. I’ve found that neither optimization is necessary for reasonable performance.

/*
**  Bezier  --  Support for Bezier curves
** Herein reside support routines for drawing Bezier curves.
**  Copyright (C) 1987, 1988 David W. Smith
**  Submitted to MacTutor for their source-disk.
*/

#include <MacTypes.h>
/*
   The greater the number of curve segments, the smoother the curve, 
and the longer it takes to generate and draw.  The number below was pulled 
out of a hat, and seems to work o.k.
 */
#define SEGMENTS 16

static Fixedweight1[SEGMENTS + 1];
static Fixedweight2[SEGMENTS + 1];

#define w1(s)  weight1[s]
#define w2(s)  weight2[s]
#define w3(s)  weight2[SEGMENTS - s]
#define w4(s)  weight1[SEGMENTS - s]

/*
 *  SetupBezier  --  one-time setup code.
 * Compute the weights for the Bezier function.
 *  For the those concerned with space, the tables can be precomputed. 
Setup is done here for purposes of illustration.
 */
void
SetupBezier()
{
 Fixed  t, zero, one;
 int    s;

 zero  = FixRatio(0, 1);
 one   = FixRatio(1, 1);
 weight1[0] = one;
 weight2[0] = zero;
 for ( s = 1 ; s < SEGMENTS ; ++s ) {
 t = FixRatio(s, SEGMENTS);
 weight1[s] = FixMul(one - t, FixMul(one - t, one - t));
 weight2[s] = 3 * FixMul(t, FixMul(t - one, t - one));
 }
 weight1[SEGMENTS] = zero;
 weight2[SEGMENTS] = zero;
}

/*
 *  computeSegments  --  compute segments for the Bezier curve
 * Compute the segments along the curve.
 *  The curve touches the endpoints, so don’t bother to compute them.
 */
static void
computeSegments(p1, p2, p3, p4, segment)
 Point  p1, p2, p3, p4;
 Point  segment[];
{
 int    s;
 
 segment[0] = p1;
 for ( s = 1 ; s < SEGMENTS ; ++s ) {
 segment[s].v = FixRound(w1(s) * p1.v + w2(s) * p2.v +
 w3(s) * p3.v + w4(s) * p4.v);
 segment[s].h = FixRound(w1(s) * p1.h + w2(s) * p2.h +
 w3(s) * p3.h + w4(s) * p4.h);
 }
 segment[SEGMENTS] = p4;
}

/*
 *  BezierCurve  --  Draw a Bezier Curve
 * Draw a curve with the given endpoints (p1, p4), and the given 
 * control points (p2, p3).
 *  Note that we make no assumptions about pen or pen mode.
 */
void
BezierCurve(p1, p2, p3, p4)
 Point  p1, p2, p3, p4;
{
 int    s;
 Point  segment[SEGMENTS + 1];

 computeSegments(p1, p2, p3, p4, segment);
 MoveTo(segment[0].h, segment[0].v);

 for ( s = 1 ; s <= SEGMENTS ; ++s ) {
 if ( segment[s].h != segment[s - 1].h ||
  segment[s].v != segment[s - 1].v ) {
 LineTo(segment[s].h, segment[s].v);
 }
 }
}

/*
**  CurveLayer.c  
** These routines provide a layer of support between my bare-  
 bones application skeleton and the Bezier curve code.   
  There’s little here of interest outside of the mouse 
  tracking and the curve drawing.
**  David W. Smith
*/

#include “QuickDraw.h”
#include “MacTypes.h”
#include “FontMgr.h”
#include “WindowMgr.h”
#include “MenuMgr.h”
#include “TextEdit.h”
#include “DialogMgr.h”
#include “EventMgr.h”
#include “DeskMgr.h”
#include “FileMgr.h”
#include “ToolboxUtil.h”
#include “ControlMgr.h”

/*
 *  Tracker objects.  Similar to MacAPP trackers, but much,
 much simpler.
 */
struct Tracker
{
 void (*track)();
 int    thePoint;
};

static struct Tracker aTracker;
static struct Tracker bTracker;

/*
 *  The Bezier curve control points.
 */
Point   control[4] = {{144,72}, {72,144}, {216,144}, {144,216}};


/*
 *  Draw
 *  Called from the skeleton to update the window.  Draw the   
 initial curve.
 */
Draw()
{
 PenMode(patXor);
 DrawTheCurve(control, true);
}

/*
 *  DrawTheCurve
 * Draw the given Bezier curve in the current pen mode.Draw 
   the control points if requested.
 */
DrawTheCurve(c, drawPoints)
 Point  c[];
{
 if ( drawPoints )
 DrawThePoints(c);
 BezierCurve(c[0], c[1], c[2], c[3]);
}

/*
 *  DrawThePoints
 *  Draw all of the control points.
 */
DrawThePoints(c)
 Point  c[];
{
 int    n;
 
 for ( n = 0 ; n < 4 ; ++n ) {
 DrawPoint(c, n);
 }
}

/*
 *  DrawPoint
 *  Draw a single control point
 */
DrawPoint(c, n)
 Point  c[];
 int    n;
{
 PenSize(3, 3);
 MoveTo(c[n].h - 1, c[n].v - 1);
 LineTo(c[n].h - 1, c[n].v - 1);
 PenSize(1, 1);
}

/*
 * GetTracker
 * Produce a tracker object
 * Called by the skeleton to handle mouse-down events.
 * If the mouse touches a control point, return a tracker for
 that point. Otherwise, return a tracker that drags a gray 
 rectangle.
 */
struct Tracker *
GetTracker(point)
 Point  point;
{
 void   TrackPoint(), TrackSelect();
 int    i;

 aTracker.track = TrackPoint;

 for ( i = 0 ; i < 4 ; ++i ) {
 if ( TouchPoint(control[i], point) ) {
 aTracker.thePoint = i;
 return (&aTracker);
 }
 }
 bTracker.track = TrackSelect;
 return (&bTracker);
}

/*
 *  TouchPoint
 *  Do the points touch?
 */
#define abs(a) (a < 0 ? -(a) : (a))

TouchPoint(target, point)
 Point  target;
 Point  point;
{
 SubPt(point, &target);
 if ( abs(target.h) < 3 && abs(target.v) < 3 )
 return (1);
 return (0);
}

/*
 *  TrackPoint
 *  Called while dragging a control point.
 */
void
TrackPoint(tracker, point, phase)
 struct Tracker  *tracker;
 Point  point;
 int    phase;
{
 Point  savePoint;

 switch ( phase ) {
 case 1:
 /* initial click - XOR out the control point */
 DrawPoint(control, tracker->thePoint);
 break;
 case 2:
 /* drag - undraw the original curve and draw the new one */
 DrawTheCurve(control, false);
 control[tracker->thePoint] = point;
 DrawTheCurve(control, false);
 break;
 case 3:
 /* release - redraw the control point */
 DrawPoint(control, tracker->thePoint);
 break;
 }
}

/*
 *  TrackSelect
 *  Track a gray selection rectangle
 */
static Pointfirst;
static Rect r;

void
TrackSelect(tracker, point, phase)
 struct Tracker  *tracker;
 Point  point;
 int    phase;
{
 switch ( phase ) {
 case 1:
 PenPat(gray);
 first = point;
 SetupRect(&r, first, point);
 FrameRect(&r);
 break;
 case 2:
 FrameRect(&r);
 SetupRect(&r, first, point);
 FrameRect(&r);
 break;
 case 3:
 FrameRect(&r);
 PenPat(black);
 break;
 }
}

/*
 *  SetupRect
 *  Setup the rectangle for tracking.
 */
#define min(x, y) (((x) < (y)) ? (x) : (y))
#define max(x, y) (((x) > (y)) ? (x) : (y))

SetupRect(rect, point1, point2)
 Rect   *rect;
 Point  point1;
 Point  point2;
{
 SetRect(rect,
 min(point1.h, point2.h),
 min(point1.v, point2.v),
 max(point1.h, point2.h),
 max(point1.v, point2.v));
}

/*
**  Skeleton.c  --  A bare-bones skeleton.
** This has been hacked up to demonstrate Bezier curves.  
    Other than the tracking technique, there’s little here of 
    interest.
**  David W. Smith
*/

#include “QuickDraw.h”
#include “MacTypes.h”
#include “FontMgr.h”
#include “WindowMgr.h”
#include “MenuMgr.h”
#include “TextEdit.h”
#include “DialogMgr.h”
#include “EventMgr.h”
#include “DeskMgr.h”
#include “FileMgr.h”
#include “ToolboxUtil.h”
#include “ControlMgr.h”

WindowRecordwRecord;
WindowPtr myWindow;

/*
 *  main
 *  Initialize the world, then handle events until told to quit.
 */
main() 
{
 InitGraf(&thePort);
 InitFonts();
 FlushEvents(everyEvent, 0);
 InitWindows();
 InitMenus();
 InitDialogs(0L);
 InitCursor();
 MaxApplZone();

 SetupMenus();
 SetupWindow();
 SetupBezier();

 while ( DoEvent(everyEvent) )
 ;
}

/*
 *  SetupMenus
 *  For the purpose of this demo, we get somewhat non-standard and use 
no menus.  Closing the window quits.
 */
SetupMenus()
{
 DrawMenuBar();
}

/*
 *  SetupWindow
 *  Setup the window for the Bezier demo.
 */
SetupWindow()
{
 Rect   bounds;

 bounds = WMgrPort->portBits.bounds;
 bounds.top += 36;
 InsetRect(&bounds, 5, 5);

 myWindow = NewWindow(&wRecord, &bounds, “\pBezier Sampler - Click and 
Drag”, 1, noGrowDocProc, 0L, 1, 0L);
 
 SetPort(myWindow);
}

/*
 *  DoEvent
 *  Generic event handling.
 */
DoEvent(eventMask)
 int    eventMask;
{
 EventRecordmyEvent;
 WindowPtrwhichWindow;
 Rect   r;
 
 SystemTask();
 if ( GetNextEvent(eventMask, &myEvent) )
 {
 switch ( myEvent.what )
 {
 case mouseDown:
 switch ( FindWindow( myEvent.where, &whichWindow ) )
 {
 case inDesk: 
 break;
 case inGoAway:
 if ( TrackGoAway(myWindow, myEvent.where) )
 {
 HideWindow(myWindow);
 return (0);
 }
 break;
 case inMenuBar:
 return (DoCommand(MenuSelect(myEvent.where)));
 case inSysWindow:
 SystemClick(&myEvent, whichWindow);
 break;
 case inDrag:
 break;
 case inGrow:
 break;
 case inContent:
 DoContent(&myEvent);
 break;
 default:
 break;;
 }
 break;
 case keyDown:
 case autoKey: 
 break;
 case activateEvt:
 break;
 case updateEvt:
 DoUpdate();
 break;
 default:
 break;
 }
 }
 return(1);
}

/*
 *  DoCommand
 *  Command handling would normally go here.
 */
DoCommand(mResult)
 long   mResult;
{
 int    theItem, temp;
 Str255 name;
 WindowPeek wPtr;
 
 theItem = LoWord(mResult);

 switch ( HiWord(mResult) )
 {
 }

 HiliteMenu(0);
 return(1);
}

/*
 *  DoUpdate
 *  Generic update handler.
 */
DoUpdate()
{
 BeginUpdate(myWindow);
 Draw();
 EndUpdate(myWindow);
}

/*
 *  DoContent
 *  Handle mouse-downs in the content area by asking the application 
to produce a tracker object.  We then call the tracker repeatedly to 
track the mouse. This technique came originally (as nearly as I can tell) 
from Xerox, and is used in a modified form in MacApp.
 */
struct Tracker
{
 int    (*Track)();
};

int
DoContent(pEvent)
 EventRecord*pEvent;
{
 struct Tracker  *GetTracker();
 struct Tracker  *t;
 Point  point, newPoint;
 
 point = pEvent->where;
 GlobalToLocal(&point);
 t = GetTracker(point);
 if ( t ) {
 (*t->Track)(t, point, 1);
 while ( StillDown() ) {
 GetMouse(&newPoint);
 if ( newPoint.h != point.h || newPoint.v != point.v ) {
 point = newPoint;
 (*t->Track)(t, point, 2);
 }
 }
 (*t->Track)(t, point, 3);
 }
}

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Tokkun Studio unveils alpha trailer for...
We are back on the MMORPG news train, and this time it comes from the sort of international developers Tokkun Studio. They are based in France and Japan, so it counts. Anyway, semantics aside, they have released an alpha trailer for the upcoming... | Read more »
Win a host of exclusive in-game Honor of...
To celebrate its latest Jujutsu Kaisen crossover event, Honor of Kings is offering a bounty of login and achievement rewards kicking off the holiday season early. [Read more] | Read more »
Miraibo GO comes out swinging hard as it...
Having just launched what feels like yesterday, Dreamcube Studio is wasting no time adding events to their open-world survival Miraibo GO. Abyssal Souls arrives relatively in time for the spooky season and brings with it horrifying new partners to... | Read more »
Ditch the heavy binders and high price t...
As fun as the real-world equivalent and the very old Game Boy version are, the Pokemon Trading Card games have historically been received poorly on mobile. It is a very strange and confusing trend, but one that The Pokemon Company is determined to... | Read more »
Peace amongst mobile gamers is now shatt...
Some of the crazy folk tales from gaming have undoubtedly come from the EVE universe. Stories of spying, betrayal, and epic battles have entered history, and now the franchise expands as CCP Games launches EVE Galaxy Conquest, a free-to-play 4x... | Read more »
Lord of Nazarick, the turn-based RPG bas...
Crunchyroll and A PLUS JAPAN have just confirmed that Lord of Nazarick, their turn-based RPG based on the popular OVERLORD anime, is now available for iOS and Android. Starting today at 2PM CET, fans can download the game from Google Play and the... | Read more »
Digital Extremes' recent Devstream...
If you are anything like me you are impatiently waiting for Warframe: 1999 whilst simultaneously cursing the fact Excalibur Prime is permanently Vault locked. To keep us fed during our wait, Digital Extremes hosted a Double Devstream to dish out a... | Read more »
The Frozen Canvas adds a splash of colou...
It is time to grab your gloves and layer up, as Torchlight: Infinite is diving into the frozen tundra in its sixth season. The Frozen Canvas is a colourful new update that brings a stylish flair to the Netherrealm and puts creativity in the... | Read more »
Back When AOL WAS the Internet – The Tou...
In Episode 606 of The TouchArcade Show we kick things off talking about my plans for this weekend, which has resulted in this week’s show being a bit shorter than normal. We also go over some more updates on our Patreon situation, which has been... | Read more »
Creative Assembly's latest mobile p...
The Total War series has been slowly trickling onto mobile, which is a fantastic thing because most, if not all, of them are incredibly great fun. Creative Assembly's latest to get the Feral Interactive treatment into portable form is Total War:... | Read more »

Price Scanner via MacPrices.net

Early Black Friday Deal: Apple’s newly upgrad...
Amazon has Apple 13″ MacBook Airs with M2 CPUs and 16GB of RAM on early Black Friday sale for $200 off MSRP, only $799. Their prices are the lowest currently available for these newly upgraded 13″ M2... Read more
13-inch 8GB M2 MacBook Airs for $749, $250 of...
Best Buy has Apple 13″ MacBook Airs with M2 CPUs and 8GB of RAM in stock and on sale on their online store for $250 off MSRP. Prices start at $749. Their prices are the lowest currently available for... Read more
Amazon is offering an early Black Friday $100...
Amazon is offering early Black Friday discounts on Apple’s new 2024 WiFi iPad minis ranging up to $100 off MSRP, each with free shipping. These are the lowest prices available for new minis anywhere... Read more
Price Drop! Clearance 14-inch M3 MacBook Pros...
Best Buy is offering a $500 discount on clearance 14″ M3 MacBook Pros on their online store this week with prices available starting at only $1099. Prices valid for online orders only, in-store... Read more
Apple AirPods Pro with USB-C on early Black F...
A couple of Apple retailers are offering $70 (28%) discounts on Apple’s AirPods Pro with USB-C (and hearing aid capabilities) this weekend. These are early AirPods Black Friday discounts if you’re... Read more
Price drop! 13-inch M3 MacBook Airs now avail...
With yesterday’s across-the-board MacBook Air upgrade to 16GB of RAM standard, Apple has dropped prices on clearance 13″ 8GB M3 MacBook Airs, Certified Refurbished, to a new low starting at only $829... Read more
Price drop! Apple 15-inch M3 MacBook Airs now...
With yesterday’s release of 15-inch M3 MacBook Airs with 16GB of RAM standard, Apple has dropped prices on clearance Certified Refurbished 15″ 8GB M3 MacBook Airs to a new low starting at only $999.... Read more
Apple has clearance 15-inch M2 MacBook Airs a...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs now available starting at $929 and ranging up to $410 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at... Read more
Apple drops prices on 13-inch M2 MacBook Airs...
Apple has dropped prices on 13″ M2 MacBook Airs to a new low of only $749 in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, now available for $679 for 8-Core CPU/7-Core GPU/256GB models. Apple’s one-year warranty is included, shipping is free, and each... Read more

Jobs Board

Seasonal Cashier - *Apple* Blossom Mall - J...
Seasonal Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Seasonal Fine Jewelry Commission Associate -...
…Fine Jewelry Commission Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) Read more
Seasonal Operations Associate - *Apple* Blo...
Seasonal Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.