unit graphics_2D; // TODO rename to "graphics" ? or however something that draws on "pixmaps" and uses pixmap units mostly is called anyway. // TODO just rename "pixmap" to "Image". {$MODE OBJFPC} {$M+} interface uses framebuffers, images, colors, type_fixes, fonts, rectangles; type TAngle = Single; { in Radians. } IPen = interface function GetColor() : IColor; property Color : IColor read GetColor; end; IImagePen = interface(IPen) { does not scale the Pixmap before drawing. } property Image : IImage; end; IEmptyPen = interface(IPen) end; ISimplePen = interface(IPen) property Color : IColor; property Strength : Word; end; TBuiltInPenID = (peBox, peCircular, peEmpty); TBLITMode = (blCopy, blBlend); // QuickFiltering, blNearestNeighbourFiltering, blBilinearFiltering); // TODO Think about using TRect. { the default Pen is supposed to be the box pen, width = 1, height = 1. } I2DGraphics = interface function GetPen : IPen; procedure SetPen(const aPen : IPen); { left, top, right, bottom. } procedure DrawLine(aX1, aY1, aX2, aY2 : TCoordinate); procedure DrawRectangle(aX1, aY1, aX2, aY2 : TCoordinate); procedure DrawEllipse(aX1, aY1, aX2, aY2 : TCoordinate); procedure DrawArc(aX1, aY1, aX2, aY2 : TCoordinate; aBeginning : TAngle; aEnd : TAngle); { point array: [ starting_point_1, control_point_1_1, control_point_1_2, ending_point_1=>starting_point_2, control_point_2_1, control_point_2_2, ending_point_2_2... } procedure DrawCubicBezier(const aPoints : TPointArray); // TODO beginning, end offset. procedure ClearBox(aX1, aY1, aX2, aY2 : TCoordinate; const aColor : IColor); // depending on pen, doesn't always actually draw something. function DrawGlyph(const aFont : IFont; aDesiredHeight : TCoordinate; aXLeft, aYBaseline : TCoordinate; aCode : TCardinal{Unicode}) : TRectangle; // FIXME RTL, up-down, context dependency. { this does not take care of the aspect ratio (what would it do?). } // TODO alpha blending? procedure BLIT(const aImage : IImage; aX1, aY1, aX2, aY2 : TCoordinate; aDestinationX1, aDestinationY1 : TCoordinate; aMode : TBLITMode); { TODO text, bezier curve. } property Pen : IPen read GetPen write SetPen; function GetBuiltinPen(aID : TBuiltInPenID; aWidth, aHeight : Cardinal) : IPen; { high-level support for clipping? Not here. } { TODO auto-fill the interior? } // TODO COLOR end; implementation end.