YOUSEFUL / DELPHI / COMPONENTS

TAtlasCanvasSurface

Drawing surface over any VCL TCanvas: screen, bitmap, metafile or printer.

Class Unit Atlas.PlotSurface · Inherits TAtlasPlotSurface · Product Atlas Plot

Description

Implements every TAtlasPlotSurface method with GDI calls on the canvas it was given. The chart uses it for painting, RenderTo, CreateBitmap and bitmap and metafile exports. Create one yourself to draw several charts onto one canvas with TAtlasPlot.Render. The surface does not own the canvas.

Members

MemberKindWhat it does
CreateconstructorWraps Canvas, which must outlive the surface.
DestroydestructorEnds an open clip, restoring the canvas's previous clip region.
UsePenmethodGDI draws dashes only at width 1, so a dashed pen is always one pixel wide and dotted.
BeginClipmethodIntersects the canvas clip with Bounds, keeping any clip the caller had (printing, PaintTo) and restoring it in EndClip.
EndClipmethodRestores the clip region saved by BeginClip.

Constructors

Create constructor

constructor Create(Canvas: TCanvas);

Wraps Canvas, which must outlive the surface.

Destructors

Destroy destructor

destructor Destroy; override;

Ends an open clip, restoring the canvas's previous clip region.

Methods

UsePen method

procedure UsePen(Color: TColor; Width: Integer = 1; Dashed: Boolean = False); override;

GDI draws dashes only at width 1, so a dashed pen is always one pixel wide and dotted. Dashed strokes are drawn with a clear brush so the gaps stay transparent.

BeginClip method

procedure BeginClip(const Bounds: TRect); override;

Intersects the canvas clip with Bounds, keeping any clip the caller had (printing, PaintTo) and restoring it in EndClip.

EndClip method

procedure EndClip; override;

Restores the clip region saved by BeginClip.

Examples

Two charts on one bitmap

Renders two charts side by side into a single image.

pascal
uses
  System.Types, Vcl.Graphics, Atlas.Plot, Atlas.PlotSurface;

function SideBySide(Left, Right: TAtlasPlot): Vcl.Graphics.TBitmap;
var
  Surface: TAtlasCanvasSurface;
begin
  Result := Vcl.Graphics.TBitmap.Create;
  try
    Result.SetSize(1200, 400);
    Surface := TAtlasCanvasSurface.Create(Result.Canvas);
    try
      Left.Render(Surface, Rect(0, 0, 600, 400));
      Right.Render(Surface, Rect(600, 0, 1200, 400));
    finally
      Surface.Free;
    end;
  except
    Result.Free;
    raise;
  end;
  // Render leaves the hit regions of the last render; repaint charts that are on screen.
  if Left.Showing then Left.Repaint;
  if Right.Showing then Right.Repaint;
end;

TAtlasPlotSurface · TAtlasSvgSurface · TAtlasPlot

Also in Atlas Plot

TAtlasPlot