Codebot.Graphics unit

Here is a very small clip of the advanced drawing interface which will be released in the new revision of Cross Codebot. Backends have been implemented for Gdi+ and Direct2D on Windows, Cairo on Linux, and Quartz2D on Macintosh.
Click here to watch an old video made 3 years ago, but still relevant. We are producing some new videos which actually will walk users through not only the new graphic interfaces and some demo programs, but also our new control Library built on top of these interfaces. If you interested in seeing some of the old components they were previously produced for Delphi and are still listed here. The component listing has doubled since the last release listed on

Surface interface listing

{ Create a new matrix }
function NewMatrix: IMatrix;
{ Create a new pen using a brush as the color }
function NewPen(Brush: IBrush; Width: Float = 1): IPen; overload;
{ Create a new solid color pen }
function NewPen(Color: TColorB; Width: Float = 1): IPen; overload;
{ Create a new solid color brush }
function NewBrush(Color: TColorB): ISolidBrush; overload;
{ Create a new bitmap pattern brush }
function NewBrush(Bitmap: IBitmap): IBitmapBrush; overload;
{ Create a new linear gradient brush using four coordinates for endpoints }
function NewBrush(X1, Y1, X2, Y2: Float): ILinearGradientBrush; overload;
{ Create a new linear gradient brush using two points for endpoints }
function NewBrush(const A, B: TPointF): ILinearGradientBrush; overload;
{ Create a new radial gradient brush bounded by a rect }
function NewBrush(const Rect: TRectF): IRadialGradientBrush; overload;
{ Create a new font by copying a regular font object }
function NewFont(Font: TFont): IFont;
{ Create a new canvas using a regular canvas object }
function NewSurface(Canvas: TCanvas): ISurface; overload;
{ Create a new canvas using a window }
function NewSurface(Control: TWinControl): ISurface; overload;
{ Create a new bitmap of width and height size }
function NewBitmap(Width, Height: Integer): IBitmap;
{ Create a new splash screen }
function NewSplash: ISplash;

{ IMatrix }

  IMatrix = interface(ICloneable<IMatrix>)
    procedure Identity;
    procedure Multiply(M: IMatrix);
    procedure Translate(X, Y: Float);
    procedure Scale(X, Y: Float);
    procedure Rotate(Angle: Float);

{ IPen }

  TLinePattern = (pnSolid, pnDash, pnDot, pnDashDot);
  TLineCap = (cpButt, cpRound, cpSquare);
  TLineJoin = (jnMiter, jnRound, jnBevel);

  IPen = interface
    function GetBrush: IBrush;
    procedure SetBrush(Value: IBrush);
    function GetColor: TColorB;
    procedure SetColor(Value: TColorB);
    function GetWidth: Float;
    procedure SetWidth(Value: Float);
    function GetLinePattern: TLinePattern;
    procedure SetLinePattern(Value: TLinePattern);
    function GetLinePatternOffset: Float;
    procedure SetLinePatternOffset(Value: Float);
    function GetLineCap: TLineCap;
    procedure SetLineCap(Value: TLineCap);
    function GetLineJoin: TLineJoin;
    procedure SetLineJoin(Value: TLineJoin);
    function GetMiterLimit: Float;
    procedure SetMiterLimit(Value: Float);
    property Brush: IBrush read GetBrush write SetBrush;
    property Color: TColorB read GetColor write SetColor;
    property Width: Float read GetWidth write SetWidth;
    property LinePattern: TLinePattern read GetLinePattern write SetLinePattern;
    property LinePatternOffset: Float read GetLinePatternOffset write SetLinePatternOffset;
    property LineCap: TLineCap read GetLineCap write SetLineCap;
    property LineJoin: TLineJoin read GetLineJoin write SetLineJoin;
    property MiterLimit: Float read GetMiterLimit write SetMiterLimit;

{ IBrush }

  IBrush = interface
    function GetMatrix: IMatrix;
    procedure SetMatrix(Value: IMatrix);
    function GetOpacity: Byte;
    procedure SetOpacity(Value: Byte);
    property Matrix: IMatrix read GetMatrix write SetMatrix;
    property Opacity: Byte read GetOpacity write SetOpacity;

{ ISolidBrush }

  ISolidBrush = interface(IBrush)
    function GetColor: TColorB;
    procedure SetColor(Value: TColorB);
    property Color: TColorB read GetColor write SetColor;

{ IBitmapBrush }

  IBitmapBrush = interface(IBrush)

{ IGradientBrush }

  TGradientWrap = (gwClamp, gwRepeat, gwReflect);

  IGradientBrush = interface(IBrush)
    function GetWrap: TGradientWrap;
    procedure SetWrap(Value: TGradientWrap);
    procedure AddStop(Color: TColorB; Offset: Float);
    property Wrap: TGradientWrap read GetWrap write SetWrap;

{ ILinearGradientBrush }

  ILinearGradientBrush = interface(IGradientBrush)

{ IRadialGradientBrush }

  IRadialGradientBrush = interface(IGradientBrush)

{ IFont }

  IFont = interface
    function GetName: string;
    function GetColor: TColorB;
    procedure SetColor(Value: TColorB);
    function GetStyle: TFontStyles;
    procedure SetStyle(Value: TFontStyles);
    function GetSize: Float;
    procedure SetSize(Value: Float);
    property Name: string read GetName;
    property Color: TColorB read GetColor write SetColor;
    property Style: TFontStyles read GetStyle write SetStyle;
    property Size: Float read GetSize write SetSize;

{ IPathData }

  IPathData = interface

{ IPath }

  IPath = interface(ICloneable<IPathData>)
    procedure Add;
    procedure Remove;
    procedure Close;
    procedure Join(Path: IPathData);
    procedure Clip;
    procedure Unclip;

{ ISurface is the main interface used to draw high quality fast vector graphics }

  ISurface = interface
    function GetMatrix: IMatrix;
    procedure SetMatrix(Value: IMatrix);
    function GetPath: IPath;
    procedure Flush;
    procedure Clear(Color: TColorB);
    procedure CopyTo(const Source: TRectF; Surface: ISurface; const Dest: TRectF; Alpha: Byte = $FF);
    procedure Save;
    procedure Restore;
    procedure MoveTo(X, Y: Float);
    procedure LineTo(X, Y: Float);
    procedure ArcTo(const Rect: TRectF; BeginAngle, EndAngle: Float);
    procedure CurveTo(X, Y: Float; const C1, C2: TPointF);
    procedure Ellipse(const Rect: TRectF);
    procedure Rectangle(const Rect: TRectF);
    procedure RoundRectangle(const Rect: TRectF; Radius: Float);
    function TextSize(Font: IFont; const Text: string): TPointF;
    function TextHeight(Font: IFont; const Text: string; Width: Float): Float;
    procedure TextOut(Font: IFont; const Text: string; const Rect: TRectF;
      Direction: TDirection; Immediate: Boolean = True);
    procedure Stroke(Pen: IPen; Preserve: Boolean = False);
    procedure Fill(Brush: IBrush; Preserve: Boolean = False);
    procedure StrokeRect(Pen: IPen; const Rect: TRectF);
    procedure FillRect(Brush: IBrush; const Rect: TRectF);
    procedure StrokeRoundRect(Pen: IPen; const Rect: TRectF; Radius: Float);
    procedure FillRoundRect(Brush: IBrush; const Rect: TRectF; Radius: Float);
    property Matrix: IMatrix read GetMatrix write SetMatrix;
    property Path: IPath read GetPath;

{ IBitmap can load and save images as well as allow ISurface drawing in memory }

  TImageFormat = (fmPng, fmJpeg, fmGif, fmBmp, fmIco, fmTiff);
  TResampleQuality = (rqLowest, rqNormal, rqBest);

  IBitmap = interface(ICloneable<IBitmap>)
    function GetEmpty: Boolean;
    function GetSurface: ISurface;
    function GetClientRect: TRectI;
    function GetFormat: TImageFormat;
    procedure SetFormat(Value: TImageFormat);
    function GetHeight: Integer;
    function GetWidth: Integer;
    function GetPixels: PPixel;
    procedure Clear;
    function Resample(Width, Height: Integer; Quality: TResampleQuality = rqNormal): IBitmap;
    procedure LoadFromFile(const FileName: string);
    procedure LoadFromStream(Stream: TStream);
    procedure SaveToFile(const FileName: string);
    procedure SaveToStream(Stream: TStream);
    procedure SetSize(Width, Height: Integer);
    property Empty: Boolean read GetEmpty;
    property Surface: ISurface read GetSurface;
    property ClientRect: TRectI read GetClientRect;
    property Format: TImageFormat read GetFormat write SetFormat;
    property Width: Integer read GetWidth;
    property Height: Integer read GetHeight;
    property Pixels: PPixel read GetPixels;

  TSurfaceOptions = record
    { Use hardware rendering when possbile }
    HardwareRendering: Boolean;
    { Use double buffering if hardware rendering is not supported }
    SoftwareBuffering: Boolean;
    { Correct small render errors with possible degraded performance or loss of
      features. Enabling this causes text to fill the current path immediately,
      which in Windows has the effect of nicer text when unscaled or rotated. }
    ErrorCorrection: Boolean;
    { Use gamma corrected gradients on supported back ends }
    GammaCorrection: Boolean;

  SurfaceOptions: TSurfaceOptions = (
    HardwareRendering: True;
    SoftwareBuffering: False;
    ErrorCorrection: False;
    GammaCorrection: False;