Difference between revisions of "BGRABitmap Geometry types"

From Lazarus wiki
Jump to navigationJump to search
(category)
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Here are all the basic geometry types used in [[BGRABitmap]] library.
+
[[Category: BGRABitmap]]
 +
Here are all the basic geometry types used in [[BGRABitmap]] library. They are provided by ''BGRABitmapTypes'' unit.
  
 
=== Geometry types ===
 
=== Geometry types ===
<table style="border-collapse: collapse;"><tr style="background: white;"><td colspan="3">''EmptySingle'': single = -3.402823e38;</td></tr>
+
<table style="border-collapse: collapse;">
 +
<tr style="background: white;"><td colspan="3">''EmptySingle'': single = -3.402823e38;</td></tr>
 
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Value indicating that there is nothing in the single-precision floating point value. It is also used as a separator in lists</td></tr>
 
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Value indicating that there is nothing in the single-precision floating point value. It is also used as a separator in lists</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
Line 60: Line 62:
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="background: #f0f0ff;"><td colspan="3">''TBGRAPenStyle'' = '''array''' '''of''' Single;</td></tr>
 
<tr style="background: #f0f0ff;"><td colspan="3">''TBGRAPenStyle'' = '''array''' '''of''' Single;</td></tr>
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">A pen style can be dashed, dotted, etc. It is defined as a list of floating point number. The first number is the length of the first dash, the second number is the length of the first gap, the third number is the length of the second dash... It must have an even number of values</td></tr>
+
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">A pen style can be dashed, dotted, etc. It is defined as a list of floating point number. The first number is the length of the first dash, the second number is the length of the first gap, the third number is the length of the second dash... It must have an even number of values. This is used as a complement to [[BGRABitmap Types imported from Graphics|TPenStyle]]</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' BGRAPenStyle(dash1, space1: single; dash2: single=0; space2: single = 0; dash3: single=0; space3: single = 0; dash4 : single = 0; space4 : single = 0): TBGRAPenStyle;</td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' BGRAPenStyle(dash1, space1: single; dash2: single=0; space2: single = 0; dash3: single=0; space3: single = 0; dash4 : single = 0; space4 : single = 0): TBGRAPenStyle;</td></tr>
Line 92: Line 94:
 
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Definition of a Bézier curve of order 3. It has two control points ''c1'' and ''c2''. Those are not reached by the curve</td></tr>
 
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Definition of a Bézier curve of order 3. It has two control points ''c1'' and ''c2''. Those are not reached by the curve</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''p''1: TPointF;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''p1'': TPointF;</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Starting point (reached)</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Starting point (reached)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''c''1: TPointF;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''c1'': TPointF;</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">First control point (not reached by the curve)</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">First control point (not reached by the curve)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''c''2: TPointF;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''c2'': TPointF;</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Second control point (not reached by the curve)</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Second control point (not reached by the curve)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''p''2: TPointF;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''p2'': TPointF;</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Ending point (reached)</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Ending point (reached)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
Line 122: Line 124:
 
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Definition of a Bézier curve of order 2. It has one control point</td></tr>
 
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Definition of a Bézier curve of order 2. It has one control point</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''p''1: TPointF;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''p1'': TPointF;</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Starting point (reached)</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Starting point (reached)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
Line 128: Line 130:
 
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Control point (not reached by the curve)</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Control point (not reached by the curve)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr><td width="10%"></td><td colspan="2" style="background: white;">''p''2: TPointF;</td></tr>
+
<tr><td width="10%"></td><td colspan="2" style="background: white;">''p2'': TPointF;</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Ending point (reached)</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Ending point (reached)</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
Line 188: Line 190:
 
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Set of options for drawing an arc</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Set of options for drawing an arc</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
<tr style="background: white;"><td colspan="3">''TPoint''3D = '''record''' x,y,z: single;</td></tr>
+
<tr style="background: white;"><td colspan="3">''TPoint3D'' = '''record''' x,y,z: single;</td></tr>
 
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Point in 3D with single-precision floating point coordinates</td></tr>
 
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Point in 3D with single-precision floating point coordinates</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
Line 282: Line 284:
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' getCursor: TBGRACustomPathCursor;</td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' getCursor: TBGRACustomPathCursor;</td></tr>
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns a cursor to go through the path. The cursor must be freed by calling Free.</td></tr>
+
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns a cursor to go through the path. The cursor must be freed by calling ''Free''.</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr style="background: white;"><td colspan="3">''TBGRACustomPathCursor'' = '''class'''</td></tr>
 +
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Class that contains a cursor to browse an existing path</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' MoveForward(ADistance: single; ACanJump: boolean = true): single; '''virtual'''; '''abstract''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Go forward in the path, increasing the value of ''Position''. If ''ADistance'' is negative, then it goes backward instead. ''ACanJump'' specifies if the cursor can jump from one shape to another without a line or an arc. Otherwise, the cursor is stuck, and the return value is less than the value ''ADistance'' provided.  If all the way has been travelled, the return value is equal to ''ADistance''</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' MoveBackward(ADistance: single; ACanJump: boolean = true): single; '''virtual'''; '''abstract''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Go backward, decreasing the value of ''Position''. If ''ADistance'' is negative, then it goes forward instead. ''ACanJump'' specifies if the cursor can jump from one shape to another without a line or an arc. Otherwise, the cursor is stuck, and the return value is less than the value ''ADistance'' provided. If all the way has been travelled, the return value is equal to ''ADistance''</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''property''' CurrentCoordinate: TPointF '''read''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the current coordinate in the path</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''property''' CurrentTangent: TPointF '''read''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the tangent vector. It is a vector of length one that is parallel to the curve at the current point. A normal vector is easily deduced as PointF(y,-x)</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''property''' Position: single '''read''' '''write''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Current position in the path, as a distance along the arc from the starting point of the path</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''property''' PathLength: single '''read''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Full arc length of the path</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''property''' StartCoordinate: TPointF '''read''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Starting coordinate of the path</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''property''' LoopClosedShapes: boolean '''read''' '''write''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Specifies if the cursor loops when there is a closed shape</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''property''' LoopPath: boolean '''read''' '''write''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Specifies if the cursor loops at the end of the path. Note that if it needs to jump to go to the beginning, it will be only possible if the parameter ''ACanJump'' is set to True when moving along the path</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="background: white;"><td colspan="3">''EmptyRect'' : TRect = (left:0; top:0; right:0; bottom: 0);</td></tr>
 
<tr style="background: white;"><td colspan="3">''EmptyRect'' : TRect = (left:0; top:0; right:0; bottom: 0);</td></tr>
Line 319: Line 351:
 
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''poLastOnTop'');</td></tr>
 
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''poLastOnTop'');</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Last polygon is on top</td></tr>
 
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Last polygon is on top</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr style="background: white;"><td colspan="3">''TIntersectionInfo'' = '''class'''</td></tr>
 +
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Contains an intersection between an horizontal line and any shape. It is used when filling shapes</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''ArrayOfTIntersectionInfo'' = '''array''' '''of''' TIntersectionInfo;</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">An array of intersections between an horizontal line and any shape</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr style="background: white;"><td colspan="3">''TBGRACustomFillInfo'' = '''class'''</td></tr>
 +
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Abstract class defining any shape that can be filled</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' SegmentsCurved: boolean; '''virtual'''; '''abstract''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns true if one segment number can represent a curve and thus cannot be considered exactly straight</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' GetBounds: TRect; '''virtual'''; '''abstract''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns integer bounds for the shape</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' IsPointInside(x,y: single; windingMode: boolean): boolean; '''virtual'''; '''abstract''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Check if the point is inside the shape</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' CreateIntersectionArray: ArrayOfTIntersectionInfo; '''virtual'''; '''abstract''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Create an array that will contain computed intersections. To augment that array, use ''CreateIntersectionInfo'' for new items</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' CreateIntersectionInfo: TIntersectionInfo; '''virtual'''; '''abstract''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Create a structure to define one single intersection</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''procedure''' FreeIntersectionArray('''var''' inter: ArrayOfTIntersectionInfo); '''virtual'''; '''abstract''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Free an array of intersections</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''procedure''' ComputeAndSort(cury: single; '''var''' inter: ArrayOfTIntersectionInfo; '''out''' nbInter: integer; windingMode: boolean); '''virtual'''; '''abstract''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Fill an array ''inter'' with actual intersections with the shape at the y coordinate ''cury''. ''nbInter'' receives the number of computed intersections. ''windingMode'' specifies if the winding method must be used to determine what is inside of the shape</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr style="background: white;"><td colspan="3">''TGradientType'' = (</td></tr>
 +
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Shape of a gradient</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''gtLinear'',</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The color changes along a certain vector and does not change along its perpendicular direction</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: white;">''gtReflected'',</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The color changes like in ''gtLinear'' however it is symmetrical to a specified direction</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''gtDiamond'',</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The color changes along a diamond shape</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: white;">''gtRadial'');</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">The color changes in a radial way from a given center</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">''GradientTypeStr'' : '''array'''[TGradientType] '''of''' '''string'''</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">List of string to represent gradient types</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' StrToGradientType(str: '''string'''): TGradientType;</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the gradient type represented by the given string</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr style="background: #f0f0ff;"><td colspan="3">''TBGRACustomGradient'' = '''class'''</td></tr>
 +
<tr style="background: #f0f0ff;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">Defines a gradient of color, not specifying its shape but only the series of colors</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' GetColorAt(position: integer): TBGRAPixel; '''virtual'''; '''abstract''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the color at a given ''position''. The reference range is from 0 to 65535, however values beyond are possible as well</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''function''' GetColorAtF(position: single): TBGRAPixel; '''virtual''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the color at a given ''position''. The reference range is from 0 to 1, however values beyond are possible as well</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: white;">'''function''' GetAverageColor: TBGRAPixel; '''virtual'''; '''abstract''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the average color of the gradient</td></tr>
 +
<tr style="height: 8px;"><td colspan="3"></td></tr>
 +
<tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''property''' Monochrome: boolean '''read''';</td></tr>
 +
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">This property is True if the gradient contains only one color, and thus is not really a gradient</td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
<tr style="height: 8px;"><td colspan="3"></td></tr>
 
</table>
 
</table>

Revision as of 11:47, 1 May 2015

Here are all the basic geometry types used in BGRABitmap library. They are provided by BGRABitmapTypes unit.

Geometry types

EmptySingle: single = -3.402823e38;
Value indicating that there is nothing in the single-precision floating point value. It is also used as a separator in lists
PPointF = ^TPointF;
Pointer to a TPointF structure
TPointF = packed record x, y: single;
Contains a point with single-precision floating point coordinates
EmptyPointF: TPointF = (x: -3.402823e38; y: -3.402823e38);
Value indicating that there is an empty TPointF structure. It is also used as a separator in lists of points
function PointF(x, y: single): TPointF;
Creates a new structure with values x and y
function isEmptyPointF(pt: TPointF): boolean;
Checks if the structure is empty (equal to EmptyPointF)
operator = (const pt1, pt2: TPointF): boolean; inline;
Checks if both x and y are equal
operator + (const pt1, pt2: TPointF): TPointF; inline;
Adds x and y components separately. It is like adding vectors
operator - (const pt1, pt2: TPointF): TPointF; inline;
Subtract x and y components separately. It is like subtracting vectors
operator - (const pt2: TPointF): TPointF; inline;
Returns a point with opposite values for x and y components
operator * (const pt1, pt2: TPointF): single; inline;
Scalar product: multiplies x and y components and returns the sum
operator * (const pt1: TPointF; factor: single): TPointF; inline;
Multiplies both x and y by factor. It scales the vector represented by (x,y)
operator * (factor: single; const pt1: TPointF): TPointF; inline;
Multiplies both x and y by factor. It scales the vector represented by (x,y)
function VectLen(dx,dy: single): single; overload;
Returns the length of the vector (dx,dy)
function VectLen(v: TPointF): single; overload;
Returns the length of the vector represented by (x,y)
ArrayOfTPointF = array of TPointF;
Contains an array of points with single-precision floating point coordinates
function PointsF(const pts: array of TPointF): ArrayOfTPointF;
Creates an array of TPointF
function ConcatPointsF(const APolylines: array of ArrayOfTPointF): ArrayOfTPointF;
Concatenates arrays of TPointF
function PolylineLen(const pts: array of TPointF; AClosed: boolean = false): single;
Compute the length of the polyline contained in the array. AClosed specifies if the last point is to be joined to the first one
TBGRAPenStyle = array of Single;
A pen style can be dashed, dotted, etc. It is defined as a list of floating point number. The first number is the length of the first dash, the second number is the length of the first gap, the third number is the length of the second dash... It must have an even number of values. This is used as a complement to TPenStyle
function BGRAPenStyle(dash1, space1: single; dash2: single=0; space2: single = 0; dash3: single=0; space3: single = 0; dash4 : single = 0; space4 : single = 0): TBGRAPenStyle;
Creates a pen style with the specified length for the dashes and the spaces
TSplineStyle = (
Different types of spline. A spline is a series of points that are used as control points to draw a curve. The first point and last point may or may not be the starting and ending point
ssInside,
The curve is drawn inside the polygonal envelope without reaching the starting and ending points
ssInsideWithEnds,
The curve is drawn inside the polygonal envelope and the starting and ending points are reached
ssCrossing,
The curve crosses the polygonal envelope without reaching the starting and ending points
ssCrossingWithEnds,
The curve crosses the polygonal envelope and the starting and ending points are reached
ssOutside,
The curve is outside the polygonal envelope (starting and ending points are reached)
ssRoundOutside,
The curve expands outside the polygonal envelope (starting and ending points are reached)
ssVertexToSide);
The curve is outside the polygonal envelope and there is a tangeant at vertices (starting and ending points are reached)
TCubicBezierCurve = object
Definition of a Bézier curve of order 3. It has two control points c1 and c2. Those are not reached by the curve
p1: TPointF;
Starting point (reached)
c1: TPointF;
First control point (not reached by the curve)
c2: TPointF;
Second control point (not reached by the curve)
p2: TPointF;
Ending point (reached)
function ComputePointAt(t: single): TPointF;
Computes the point at time t, varying from 0 to 1
procedure Split(out ALeft, ARight: TCubicBezierCurve);
Split the curve in two such that ALeft.p2 = ARight.p1
function ComputeLength(AAcceptedDeviation: single = 0.1): single;
Compute an approximation of the length of the curve. AAcceptedDeviation indicates the maximum orthogonal distance that is ignored and approximated by a straight line.
function ToPoints(AAcceptedDeviation: single = 0.1; AIncludeFirstPoint: boolean = true): ArrayOfTPointF;
Computes a polygonal approximation of the curve. AAcceptedDeviation indicates the maximum orthogonal distance that is ignored and approximated by a straight line. AIncludeFirstPoint indicates if the first point must be included in the array
function BezierCurve(origin, control1, control2, destination: TPointF) : TCubicBezierCurve; overload;
Creates a structure for a cubic Bézier curve
TQuadraticBezierCurve = object
Definition of a Bézier curve of order 2. It has one control point
p1: TPointF;
Starting point (reached)
c: TPointF;
Control point (not reached by the curve)
p2: TPointF;
Ending point (reached)
function ComputePointAt(t: single): TPointF;
Computes the point at time t, varying from 0 to 1
procedure Split(out ALeft, ARight: TQuadraticBezierCurve);
Split the curve in two such that ALeft.p2 = ARight.p1
function ComputeLength: single;
Compute the exact length of the curve
function ToPoints(AAcceptedDeviation: single = 0.1; AIncludeFirstPoint: boolean = true): ArrayOfTPointF;
Computes a polygonal approximation of the curve. AAcceptedDeviation indicates the maximum orthogonal distance that is ignored and approximated by a straight line. AIncludeFirstPoint indicates if the first point must be included in the array
function BezierCurve(origin, control, destination: TPointF) : TQuadraticBezierCurve; overload;
Creates a structure for a quadratic Bézier curve
function BezierCurve(origin, destination: TPointF) : TQuadraticBezierCurve; overload;
Creates a structure for a quadratic Bézier curve without curvature
PArcDef = ^TArcDef;
Pointer to an arc definition
TArcDef = record
Definition of an arc of an ellipse
center: TPointF;
Center of the ellipse
radius: TPointF;
Horizontal and vertical of the ellipse before rotation
xAngleRadCW: single;
Rotation of the ellipse
startAngleRadCW, endAngleRadCW: single;
Start and end angle, in radian and clockwise. See angle convention in BGRAPath
anticlockwise: boolean
Specifies if the arc goes anticlockwise
function ArcDef(cx, cy, rx,ry, xAngleRadCW, startAngleRadCW, endAngleRadCW: single; anticlockwise: boolean) : TArcDef;
Creates a structure for an arc definition
TArcOption = (
Possible options for drawing an arc of an ellipse (used in BGRACanvas)
aoClosePath,
Close the path by joining the ending and starting point together
aoPie,
Draw a pie shape by joining the ending and starting point to the center of the ellipse
aoFillPath);
Fills the shape
TArcOptions = set of TArcOption;
Set of options for drawing an arc
TPoint3D = record x,y,z: single;
Point in 3D with single-precision floating point coordinates
function Point3D(x,y,z: single): TPoint3D;
Creates a new structure with values (x,y,z)
operator = (const v1,v2: TPoint3D): boolean; inline;
Checks if all components x, y and z are equal
operator + (const v1,v2: TPoint3D): TPoint3D; inline;
Adds components separately. It is like adding vectors
operator - (const v1,v2: TPoint3D): TPoint3D; inline;
Subtract components separately. It is like subtracting vectors
operator - (const v: TPoint3D): TPoint3D; inline;
Returns a point with opposite values for all components
operator * (const v1,v2: TPoint3D): single; inline;
Scalar product: multiplies components and returns the sum
operator * (const v1: TPoint3D; const factor: single): TPoint3D; inline;
Multiplies components by factor. It scales the vector represented by (x,y,z)
operator * (const factor: single; const v1: TPoint3D): TPoint3D; inline;
Multiplies components by factor. It scales the vector represented by (x,y,z)
procedure VectProduct3D(u,v: TPoint3D; out w: TPoint3D);
Computes the vectorial product w. It is perpendicular to both u and v
procedure Normalize3D(var v: TPoint3D); inline;
Normalize the vector, i.e. scale it so that its length be 1
TLineDef = record
Defition of a line in the euclidian plane
origin: TPointF;
Some point in the line
dir: TPointF;
Vector indicating the direction
function IntersectLine(line1, line2: TLineDef): TPointF;
Computes the intersection of two lines. If they are parallel, returns the middle of the segment between the two origins
function IntersectLine(line1, line2: TLineDef; out parallel: boolean): TPointF;
Computes the intersection of two lines. If they are parallel, returns the middle of the segment between the two origins. The value parallel is set to indicate if the lines were parallel
function IsConvex(const pts: array of TPointF; IgnoreAlign: boolean = true): boolean;
Checks if the polygon formed by the given points is convex. IgnoreAlign specifies that if the points are aligned, it should still be considered as convex
function DoesQuadIntersect(pt1,pt2,pt3,pt4: TPointF): boolean;
Checks if the quad formed by the 4 given points intersects itself
function DoesSegmentIntersect(pt1,pt2,pt3,pt4: TPointF): boolean;
Checks if two segment intersect
IBGRAPath = interface
A path is the ability to define a contour with moveTo, lineTo... Even if it is an interface, it must not implement reference counting.
procedure closePath;
Closes the current path with a line to the starting point
procedure moveTo(const pt: TPointF);
Moves to a location, disconnected from previous points
procedure lineTo(const pt: TPointF);
Adds a line from the current point
procedure polylineTo(const pts: array of TPointF);
Adds a polyline from the current point
procedure quadraticCurveTo(const cp,pt: TPointF);
Adds a quadratic Bézier curve from the current point
procedure bezierCurveTo(const cp1,cp2,pt: TPointF);
Adds a cubic Bézier curve from the current point
procedure arc(const arcDef: TArcDef);
Adds an arc. If there is a current point, it is connected to the beginning of the arc
procedure openedSpline(const pts: array of TPointF; style: TSplineStyle);
Adds an opened spline. If there is a current point, it is connected to the beginning of the spline
procedure closedSpline(const pts: array of TPointF; style: TSplineStyle);
Adds an closed spline. If there is a current point, it is connected to the beginning of the spline
procedure copyTo(dest: IBGRAPath);
Copy the content of this path to the specified destination
function getPoints: ArrayOfTPointF;
Returns the content of the path as an array of points
function getCursor: TBGRACustomPathCursor;
Returns a cursor to go through the path. The cursor must be freed by calling Free.
TBGRACustomPathCursor = class
Class that contains a cursor to browse an existing path
function MoveForward(ADistance: single; ACanJump: boolean = true): single; virtual; abstract;
Go forward in the path, increasing the value of Position. If ADistance is negative, then it goes backward instead. ACanJump specifies if the cursor can jump from one shape to another without a line or an arc. Otherwise, the cursor is stuck, and the return value is less than the value ADistance provided. If all the way has been travelled, the return value is equal to ADistance
function MoveBackward(ADistance: single; ACanJump: boolean = true): single; virtual; abstract;
Go backward, decreasing the value of Position. If ADistance is negative, then it goes forward instead. ACanJump specifies if the cursor can jump from one shape to another without a line or an arc. Otherwise, the cursor is stuck, and the return value is less than the value ADistance provided. If all the way has been travelled, the return value is equal to ADistance
property CurrentCoordinate: TPointF read;
Returns the current coordinate in the path
property CurrentTangent: TPointF read;
Returns the tangent vector. It is a vector of length one that is parallel to the curve at the current point. A normal vector is easily deduced as PointF(y,-x)
property Position: single read write;
Current position in the path, as a distance along the arc from the starting point of the path
property PathLength: single read;
Full arc length of the path
property StartCoordinate: TPointF read;
Starting coordinate of the path
property LoopClosedShapes: boolean read write;
Specifies if the cursor loops when there is a closed shape
property LoopPath: boolean read write;
Specifies if the cursor loops at the end of the path. Note that if it needs to jump to go to the beginning, it will be only possible if the parameter ACanJump is set to True when moving along the path
EmptyRect : TRect = (left:0; top:0; right:0; bottom: 0);
A value for an empty rectangle
function PtInRect(const pt: TPoint; r: TRect): boolean; overload;
Checks if a point is in a rectangle. This follows usual convention: r.Right and r.Bottom are not considered to be included in the rectangle.
function RectWithSize(left,top,width,height: integer): TRect;
Creates a rectangle with the specified width and height
TRoundRectangleOption = (
Possible options for a round rectangle
rrTopLeftSquare,rrTopRightSquare,rrBottomRightSquare,rrBottomLeftSquare,
specify that a corner is a square (not rounded)
rrTopLeftBevel,rrTopRightBevel,rrBottomRightBevel,rrBottomLeftBevel,
specify that a corner is a bevel (cut)
rrDefault);
default option, does nothing particular
TRoundRectangleOptions = set of TRoundRectangleOption;
A set of options for a round rectangle
TPolygonOrder = (
Order of polygons when rendered using TBGRAMultiShapeFiller (in unit BGRAPolygon)
poNone,
No order, colors are mixed together
poFirstOnTop,
First polygon is on top
poLastOnTop);
Last polygon is on top
TIntersectionInfo = class
Contains an intersection between an horizontal line and any shape. It is used when filling shapes
ArrayOfTIntersectionInfo = array of TIntersectionInfo;
An array of intersections between an horizontal line and any shape
TBGRACustomFillInfo = class
Abstract class defining any shape that can be filled
function SegmentsCurved: boolean; virtual; abstract;
Returns true if one segment number can represent a curve and thus cannot be considered exactly straight
function GetBounds: TRect; virtual; abstract;
Returns integer bounds for the shape
function IsPointInside(x,y: single; windingMode: boolean): boolean; virtual; abstract;
Check if the point is inside the shape
function CreateIntersectionArray: ArrayOfTIntersectionInfo; virtual; abstract;
Create an array that will contain computed intersections. To augment that array, use CreateIntersectionInfo for new items
function CreateIntersectionInfo: TIntersectionInfo; virtual; abstract;
Create a structure to define one single intersection
procedure FreeIntersectionArray(var inter: ArrayOfTIntersectionInfo); virtual; abstract;
Free an array of intersections
procedure ComputeAndSort(cury: single; var inter: ArrayOfTIntersectionInfo; out nbInter: integer; windingMode: boolean); virtual; abstract;
Fill an array inter with actual intersections with the shape at the y coordinate cury. nbInter receives the number of computed intersections. windingMode specifies if the winding method must be used to determine what is inside of the shape
TGradientType = (
Shape of a gradient
gtLinear,
The color changes along a certain vector and does not change along its perpendicular direction
gtReflected,
The color changes like in gtLinear however it is symmetrical to a specified direction
gtDiamond,
The color changes along a diamond shape
gtRadial);
The color changes in a radial way from a given center
GradientTypeStr : array[TGradientType] of string
List of string to represent gradient types
function StrToGradientType(str: string): TGradientType;
Returns the gradient type represented by the given string
TBGRACustomGradient = class
Defines a gradient of color, not specifying its shape but only the series of colors
function GetColorAt(position: integer): TBGRAPixel; virtual; abstract;
Returns the color at a given position. The reference range is from 0 to 65535, however values beyond are possible as well
function GetColorAtF(position: single): TBGRAPixel; virtual;
Returns the color at a given position. The reference range is from 0 to 1, however values beyond are possible as well
function GetAverageColor: TBGRAPixel; virtual; abstract;
Returns the average color of the gradient
property Monochrome: boolean read;
This property is True if the gradient contains only one color, and thus is not really a gradient