Jump to content

GpiPolySpline

From EDM2
Revision as of 20:59, 6 April 2025 by Iturbide (talk | contribs) (Created page with "This function creates a succession of Bezier splines. ==Syntax== GpiPolySpline(hps, lCount, aptlPoints) ==Parameters== ; hps (HPS) - input : Presentation-space handle. ; lCount (LONG) - input : Count of points. : This is the number of points specified in aptlPoints. It must be three times the number of splines. The value must not be negative, and it must be divisible by 3. Zero is valid but causes no output. ; aptlPoints (PPOINTL) - input : An array of p...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function creates a succession of Bezier splines.

Syntax

GpiPolySpline(hps, lCount, aptlPoints)

Parameters

hps (HPS) - input
Presentation-space handle.
lCount (LONG) - input
Count of points.
This is the number of points specified in aptlPoints. It must be three times the number of splines. The value must not be negative, and it must be divisible by 3. Zero is valid but causes no output.
aptlPoints (PPOINTL) - input
An array of points.
The points are given in this order: c11, c12, e1, c21, c22, e2, ... cs1, cs2, es
where:
cs1 is the first control point of spline s
cs2 is the second control point of spline s
es is the end point of spline s.

Return Value

lHits (LONG) - returns
Correlation and error indicators.
GPI_OK
Successful
GPI_HITS
Correlate hits
GPI_ERROR
Error.

Remarks

The first Bezier spline starts from the current position and goes to the third specified point, with the first and second points used as control points. Subsequent splines start from the ending point of the previous spline, and end at the next specified point but two, with the intervening points their first and second control points. It is the responsibility of the application to ensure that the gradient is continuous at each end and start point, if this is required. On completion, the current position is set to the last specified point. Each individual spline always lies within the area bounded by the start, end, and control points. It is not an error for any of the points to be coincident. The maximum number of splines allowed is more than 2 500.

Errors

Possible returns from WinGetLastError:

PMERR_INV_HPS (0x207F)
An invalid presentation-space handle was specified.
PMERR_PS_BUSY (0x20F4)
An attempt was made to access the presentation space from more than one thread simultaneously.
PMERR_INV_LENGTH_OR_COUNT (0x2092)
An invalid length or count parameter was specified.
PMERR_INV_COORDINATE (0x205B)
An invalid coordinate value was specified.
PMERR_INV_NESTED_FIGURES (0x20A8)
Nested figures have been detected within a path definition.

Graphic Elements and Orders

Element Type: OCODE_GCBEZ Order: Bezier Curve at Given Position As many of these orders are generated as is necessary to hold the specified splines.

Example Code

#define INCL_GPIPRIMITIVES /* Or use INCL_GPI, INCL_PM, */
#include <os2.h>

HPS     hps;         /* Presentation-space handle. */
LONG    lCount;      /* Count of points. */
PPOINTL aptlPoints;  /* An array of points. */
LONG    lHits;       /* Correlation and error indicators. */

lHits = GpiPolySpline(hps, lCount, aptlPoints);

This example uses the GpiPolySpline function to draw a curve. The curve is drawn within a skewed rectangle, with the bottom corners being the start and end points and the top corners being the control points.

#define INCL_GPIPRIMITIVES /* GPI primitive functions */
#include <os2.h>

HPS hps; /* presentation space handle */
POINTL ptlStart = { 0, 0 }; /* start point */
POINTL aptl[3] = { 0, 100, 200, 150, 200, 50 }; /* point array */

GpiMove(hps, &ptlStart); /* moves to start point */
GpiPolySpline(hps, /* presentation-space handle */
                3L, /* 3 points in the array */
                aptl); /* address of array of points */

Related Functions