This is what the name implies. It is a freely definable shape. It resembles a sprite in a way. A sprite is usually rendered only as a quad. A quad usually consists of four vertieces and corresponding UV coordinates, which are usually also squared on an image.
This is where the shape differs from the sprite.
These are the main differences. Most of the commands are similar to Sprite. You also have the possibility to create prefabricated shapes. When you create a prefabricated shape, the corresponding UV coordinates are automatically created.
Here you can see an example of creating a shape.
Agk.CreateShapeTriangle(2, 128, 128); Agk.SetShapePosition(2, Agk.GetShapeRadius(2), 384); Agk.SetShapeImage(2, 1);
The result looks like this.

Creates an empty new shape.This can be used later to fill the shape with vertieces using LoadShapeFromMemblock or LoadShapeFromMemory.
| PARAMETER | |
|---|---|
| iShapeIndex | The shape ID in which the new shape. |
float[] custVert = { -112, -122, 130, -64, 105, 120, -100, 85 }; float[] custColor = { 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0.5f, 0.5f, 0.5f, 1 }; float[] custUV = { 0, 0, 1, 0, 1, 1, 0, 1 }; ushort[] custIndicies = { 0, 1, 2, 0, 2, 3 }; Agk.LoadImage(1, "media/background5.jpg"); Agk.CreateShape(1); Agk.LoadShapeFromMemory(1, 4, custVert, custColor, custUV, 6, custIndicies); Agk.SetShapePosition(1, 512, 128);

Creates a shape with three vertices.
| PARAMETER | |
|---|---|
| iShapeIndex | The shape ID in which the new shape. |
| fX1 | X coordinate of the first vertex. |
| fY1 | Y coordinate of the first vertex. |
| fX2 | X coordinate of the second vertex. |
| fY2 | Y coordinate of the second vertex. |
| fX3 | X coordinate of the third vertex. |
| fY3 | Y coordinate of the third vertex. |
| fWidth | Triangle width. |
| fHeight | Triangle height. |
Creates a shape with four corner points.
| PARAMETER | |
|---|---|
| iShapeIndex | The shape ID in which the new shape. |
| fWidth | Triangle width. |
| fHeight | Triangle height. |
Agk.CreateShapeRectangle(3, 128, 128); Agk.SetShapePosition(3, Agk.GetShapeX(2) + Agk.GetShapeRadius(3) * 2.0f, 384); Agk.SetShapeImage(3, 1); Agk.SetShapeUVAxis(3, 0.5f, 0.5f);

Creates a star with the total size of width and height. The parameter inner specifies how far the pikes may go inwards.
| PARAMETER | |
|---|---|
| iShapeIndex | The shape ID in which the new shape. |
| fWidth | Shape width. |
| fHeight | Shape height. |
| fInner | Inner radius of the generated star. It is a percentage value of the whole star. For an inner radius the value should be between 0.0 and 1.0. If the value is greater than one, it is more of an outer radius. |
| iSpikes | Number of spikes to be generated. |
Agk.CreateShapeStar(5, 128, 128, 0.38f, 6); Agk.SetShapePosition(5, Agk.GetShapeX(4) + Agk.GetShapeRadius(5) * 2.0f, 384);

Creates a symbol as a shape. There are currently 4 different symbols.
| PARAMETER | |
|---|---|
| iShapeIndex | The shape ID in which the new shape. |
| fWidth | Shape width. |
| fHeight | Shape height. |
| iSymbol | Symbol number 0=Chefron arrow ; 1=Direction arrow ; 2=Notched arrow ; 3=Arrow |
Agk.CreateShapeSymbol(6, 128, 128, 2); Agk.SetShapePosition(6, Agk.GetShapeRadius(6), 484); Agk.InkShape(6, 0.5f, 0.7f, 0, 1); Agk.MoveShapeAxis(6, 64, 0);

Creates a polygon with the specified number of edges. The created points are generated in a circle around the center point.
| PARAMETER | |
|---|---|
| iShapeIndex | The shape ID in which the new shape. |
| fWidth | Shape width. |
| fHeight | Shape height. |
| iEdges | Symbol number 0=Chefron arrow ; 1=Direction arrow ; 2=Notched arrow ; 3=Arrow |
Agk.CreateShapePolygon(4, 128, 128, 10); Agk.SetShapePosition(4, Agk.GetShapeX(3) + Agk.GetShapeRadius(4) * 2.0f, 384); Agk.SetShapeImage(4, 1); Agk.SetShapeDepth(4, 0.5f);

Returns the pointer to the shape class.
| PARAMETER | |
|---|---|
| iShapeIndex | The shape ID from which the pointer is to be fetched. |
Fills a shape object previously created with CreateShape() or CreateShape(id) with vertices.
| PARAMETER | |
|---|---|
| iShapeIndex | The shape ID to be filled with the vertex data. |
| iNumVertices | Number of vertices that will be loaded into it. |
| iVertMemblock | This memblock contains the position data of the vertices. Values in the memblock must be of type float. The number of float values are the double of iNumVertices. So for each vertex two float values (X and Y) |
| iColorMemblock | This memblock contains the color information for each vertex. For each vertex there must be 4 float values. The value range is between 0.0 and 1.0 representing the red, green, blue and alpha channels. Also in this order. |
| iUVMemblock | This memblock contains the UV coordinates of each vertex. Again, the values are between 0.0 and 1.0. Two values for each vertex must be present. |
| iNumIndices | Number of indices for the shape. The number of indices should be divisible by three. |
| iIndicesMemblock | This memblock contains the indices. The values are short values. Three indices form a triangle. |
Fills a shape object previously created with CreateShape() or CreateShape(id) with vertices. The data is passed here as float and ushort arrays.
| PARAMETER | |
|---|---|
| iShapeIndex | The shape ID to be filled with the vertex data. |
| iNumVertices | Number of vertices that will be loaded into it. |
| Vert | This array contains the position data of the vertices. Values in the array must be of type float. The number of float values are the double of iNumVertices. So for each vertex two float values (X and Y) |
| Color | This array contains the color information for each vertex. For each vertex there must be 4 float values. The value range is between 0.0 and 1.0 representing the red, green, blue and alpha channels. Also in this order. |
| UV | This array contains the UV coordinates of each vertex. Again, the values are between 0.0 and 1.0. Two values for each vertex must be present. |
| iNumIndices | Number of indices for the shape. The number of indices should be divisible by three. |
| Indices | This array contains the indices. The values are short values. Three indices form a triangle. |
Used to check if the shape is in the visible area of the screen.
| PARAMETER | |
|---|---|
| iShapeIndex | The shape ID to be checked. |
Used to check if the shape set to visible.
| PARAMETER | |
|---|---|
| iShapeIndex | The shape ID to be checked. |
Gets the current X coordinate of the shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
Gets the current Y coordinate of the shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
Gets the current X scale factor.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
Gets the current Y scale factor.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
Gets the current angle of the shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
UV coordinates can be rotated independently from the normal vertices. This is used to retrieve the angle of the UV rotation.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
Gets the current width of the shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
Gets the current height of the shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
Gets the furthest vertex from the axis of the shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
Gets the current drawing depth. The values are between 0.0001 and 0.9999. The lowest value is in the front of the screen and the higher values are in the back of the screen.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
Gets the X center of the axis. This is the negative value of the smallest value of the X axis.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
Gets the Y center of the axis. This is the negative value of the smallest value of the Y axis.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
Gets the X position of a vertex from a shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
| iVertexIndex | The Vertex-ID from the shape to retrieve |
Gets the Y position of a vertex from a shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
| iVertexIndex | The Vertex-ID from the shape to retrieve |
Gets the Y position of a vertex from a shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
| iVertexIndex | The Vertex-ID from the shape to retrieve |
Gets the color of a vertex from a shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
| iVertexIndex | The Vertex-ID from the shape to retrieve |
Gets the texture U coordinate of a vertex from a shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
| iVertexIndex | The Vertex-ID from the shape to retrieve |
Gets the texture V coordinate of a vertex from a shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
| iVertexIndex | The Vertex-ID from the shape to retrieve |
Checks whether the shape has been fixed to the screen.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
Get the X screen position of the shape. Different from GetShapeX which gets the position in world coordinates.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
Get the Y screen position of the shape. Different from GetShapeY which gets the position in world coordinates.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to retrieve |
Sets the visibility of the shape. Shapes whose iMode is set to 0 are not drawn.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
| iMode | The visibility of this shape, 1 for visible, 0 for hidden |
Sets the position of the shape. Positions are set in world coordinates.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
| fPositionX | The X position in world coordinates to set |
| fPositionY | The Y position in world coordinates to set |
Sets the scale of the shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
| fScaleH | The horizontal scale to set. |
| fScaleV | The vertical scale to set. |
Sets the rotation of UV-Texture from the shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
| fAngle | The angle to rotate the uv texture. |
Sets the texture image of the shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
| iImageIndex | The image id to set as a texture. |
Sets the size of the shape in pixels.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
| fWidth | The resulting width of the shape. |
| fHeight | The resulting height of the shape. |
Sets the drawing depth of the shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
| fDepth | The drawing depth must between 0.0001 (front) and 0.9999 (back). |
Moves the current axis. The positions of the vertices are recalculated.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
| fMoveX | Move the axis by fMoveX in X direction |
| fMoveY | Move the axis by fMoveY in Y direction |
Sets a new reference point for the UV coordinates.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
| fMoveX | X value of the new reference point. |
| fMoveY | Y value of the new reference point. |
Sets new color values of all Vertices in the shape.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
| fR | New value for the red component. |
| fG | New value for the green component. |
| fB | New value for the blue component. |
| fA | New value for the alpha component. |
Sets the vertex specified with iVertexIndex to a new position. The values refer to the shape axis.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
| iVertexIndex | The Vertex ID of the shape to be modified. |
| fPosX | New value for the X position. |
| fPosY | New value for the Y position. |
Sets the color of the specified vertex.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
| iVertexIndex | The Vertex ID of the shape to be modified. |
| fR | New value for the red component. |
| fG | New value for the green component. |
| fB | New value for the blue component. |
| fA | New value for the alpha component. |
Sets a new texture coordinate for the specified vertex.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
| iVertexIndex | The Vertex ID of the shape to be modified. |
| fU | New value for the U position. |
| fV | New value for the V position. |
Fixes a shape on the screen.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
| iMode | The mode to be set 0 = not fixed, 1 = fixed. |
Fixes the transformation of a shape. Normally, scaling and rotation are calculated in each new frame. With this command all vertices are recalculated according to the rotation and scaling. This is recommended for static shapes whose rotation and scaling do not change anymoreor not every frame.
| PARAMETER | |
|---|---|
| iShapeIndex | The ID of the shape to modify |
using System; using AgkSharp; using AGKCore; namespace AGKCore { static class AppInfo { public static string COMPANY_NAME = "MadBit"; public static string WIN_TITLE = "DrawPrimitives"; } } namespace DrawPrimitives { static class Program { /// <summary> /// Der Haupteinstiegspunkt für die Anwendung. /// </summary> [STAThread] static void Main() { Core.CreateWindow(AppInfo.WIN_TITLE, 1024, 768, false); if (!Core.InitAGK()) return; Agk.SetVirtualResolution(1024, 768); float[] custVert = { -112, -122, 130, -64, 105, 120, -100, 85 }; float[] custColor = { 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0.5f, 0.5f, 0.5f, 1 }; float[] custUV = { 0, 0, 1, 0, 1, 1, 0, 1 }; ushort[] custIndicies = { 0, 1, 2, 0, 2, 3 }; Agk.LoadImage(1, "media/background5.jpg"); Agk.CreateShape(1); Agk.LoadShapeFromMemory(1, 4, custVert, custColor, custUV, 6, custIndicies); Agk.SetShapePosition(1, 512, 128); Agk.CreateShapeTriangle(2, 128, 128); Agk.SetShapePosition(2, Agk.GetShapeRadius(2), 384); Agk.SetShapeImage(2, 1); Agk.CreateShapeRectangle(3, 128, 128); Agk.SetShapePosition(3, Agk.GetShapeX(2) + Agk.GetShapeRadius(3) * 2.0f, 384); Agk.SetShapeImage(3, 1); Agk.SetShapeUVAxis(3, 0.5f, 0.5f); Agk.CreateShapePolygon(4, 128, 128, 10); Agk.SetShapePosition(4, Agk.GetShapeX(3) + Agk.GetShapeRadius(4) * 2.0f, 384); Agk.SetShapeImage(4, 1); Agk.SetShapeDepth(4, 0.5f); Agk.CreateShapeStar(5, 128, 128, 0.38f, 6); Agk.SetShapePosition(5, Agk.GetShapeX(4) + Agk.GetShapeRadius(5) * 2.0f, 384); Agk.CreateShapeSymbol(6, 128, 128, 2); Agk.SetShapePosition(6, Agk.GetShapeRadius(6), 484); Agk.InkShape(6, 0.5f, 0.7f, 0, 1); Agk.MoveShapeAxis(6, 64, 0); while (Core.LoopAGK()) { Agk.Print(Agk.ScreenFPS()); Agk.SetShapeAngle(2, Agk.GetShapeAngle(2) + 1.0f); Agk.SetShapeAngle(3, Agk.GetShapeAngle(3) - 1.0f); Agk.SetShapeUVAngle(3, Agk.GetShapeAngle(3)); Agk.SetShapeAngle(4, Agk.GetShapeAngle(4) + 0.5f); Agk.SetShapeAngle(5, Agk.GetShapeAngle(5) - 0.3f); Agk.Print(Agk.GetShapeScaleX(6)); Agk.Print(Agk.GetShapeScaleY(6)); Agk.Print(Agk.GetShapeAngle(6)); Agk.Print(Agk.GetShapeUVAngle(6)); Agk.Sync(); } Core.CleanUp(); } } }
