← ziglang.inraylib-zigGitHub

shapes

2D shapes, splines and collision checks. 75 functions, from raylib's rshapes.

defining a font char white rectangle would allow drawing everything in a single draw call

rl.setShapesTexture

Set texture and rectangle to be used on shapes drawing

Zigfn setShapesTexture(texture: Texture2D, rec: Rectangle) void
Cvoid SetShapesTexture(Texture2D texture, Rectangle rec);

rl.getShapesTexture

Get texture that is used for shapes drawing

Zigfn getShapesTexture() Texture2D
CTexture2D GetShapesTexture(void);

rl.getShapesTextureRectangle

Get texture source rectangle that is used for shapes drawing

Zigfn getShapesTextureRectangle() Rectangle
CRectangle GetShapesTextureRectangle(void);

Basic shapes drawing functions

rl.drawPixel

Draw a pixel using geometry [Can be slow, use with care]

Zigfn drawPixel(posX: i32, posY: i32, color: Color) void
Cvoid DrawPixel(int posX, int posY, Color color);

rl.drawPixelV

Draw a pixel using geometry (Vector version) [Can be slow, use with care]

Zigfn drawPixelV(position: Vector2, color: Color) void
Cvoid DrawPixelV(Vector2 position, Color color);

rl.drawLineStrip

Draw lines sequence (using gl lines)

Zigfn drawLineStrip(points: []const Vector2, color: Color) void
Cvoid DrawLineStrip(const Vector2 *points, int pointCount, Color color);

rl.drawLineBezier

Draw line segment cubic-bezier in-out interpolation

Zigfn drawLineBezier(startPos: Vector2, endPos: Vector2, thick: f32, color: Color) void
Cvoid DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color);

Used in shapes_lines_bezier, shapes_recursive_tree.

rl.drawLineDashed

Draw a dashed line

Zigfn drawLineDashed(startPos: Vector2, endPos: Vector2, dashSize: i32, spaceSize: i32, color: Color) void
Cvoid DrawLineDashed(Vector2 startPos, Vector2 endPos, int dashSize, int spaceSize, Color color);

Used in shapes_dashed_line, shapes_math_sine_cosine.

rl.drawTriangleGradient

Draw triangle with interpolated colors, counter-clockwise vertex/color order

Zigfn drawTriangleGradient(v1: Vector2, v2: Vector2, v3: Vector2, c1: Color, c2: Color, c3: Color) void
Cvoid DrawTriangleGradient(Vector2 v1, Vector2 v2, Vector2 v3, Color c1, Color c2, Color c3);

rl.drawTriangleLinesEx

Draw triangle outline with line thickness, counter-clockwise vertex order

Zigfn drawTriangleLinesEx(v1: Vector2, v2: Vector2, v3: Vector2, thick: f32, color: Color) void
Cvoid DrawTriangleLinesEx(Vector2 v1, Vector2 v2, Vector2 v3, float thick, Color color);

Used in shapes_drag_puzzle, shapes_outlines_testbed.

rl.drawTriangleFan

Draw a triangle fan defined by points (first vertex is the center)

Zigfn drawTriangleFan(points: []const Vector2, color: Color) void
Cvoid DrawTriangleFan(const Vector2 *points, int pointCount, Color color);

Used in shapes_top_down_lights.

rl.drawTriangleStrip

Draw a triangle strip defined by points

Zigfn drawTriangleStrip(points: []const Vector2, color: Color) void
Cvoid DrawTriangleStrip(const Vector2 *points, int pointCount, Color color);

Used in shapes_digital_clock.

rl.drawRectangleGradientV

Draw a vertical-gradient-filled rectangle

Zigfn drawRectangleGradientV(posX: i32, posY: i32, width: i32, height: i32, top: Color, bottom: Color) void
Cvoid DrawRectangleGradientV(int posX, int posY, int width, int height, Color top, Color bottom);

rl.drawRectangleGradientEx

Draw a gradient-filled rectangle with custom vertex colors, counter-clockwise color order

Zigfn drawRectangleGradientEx(rec: Rectangle, col1: Color, col2: Color, col3: Color, col4: Color) void
Cvoid DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4);

Used in shapes_rectangle_advanced.

rl.drawRectangleRoundedLines

Draw rectangle lines with rounded edges

Zigfn drawRectangleRoundedLines(rec: Rectangle, roundness: f32, segments: i32, color: Color) void
Cvoid DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, Color color);

Used in shapes_outlines_testbed.

rl.drawCircleSectorLinesEx

Draw circle sector outline with thickness

Zigfn drawCircleSectorLinesEx(center: Vector2, radius: f32, startAngle: f32, endAngle: f32, segments: i32, thick: f32, color: Color) void
Cvoid DrawCircleSectorLinesEx(Vector2 center, float radius, float startAngle, float endAngle, int segments, float thick, Color color);

Used in shapes_outlines_testbed.

rl.drawEllipseV

Draw ellipse (Vector version)

Zigfn drawEllipseV(center: Vector2, radiusH: f32, radiusV: f32, color: Color) void
Cvoid DrawEllipseV(Vector2 center, float radiusH, float radiusV, Color color);

Used in shapes_outlines_testbed.

rl.drawEllipseLinesV

Draw ellipse outline (Vector version)

Zigfn drawEllipseLinesV(center: Vector2, radiusH: f32, radiusV: f32, color: Color) void
Cvoid DrawEllipseLinesV(Vector2 center, float radiusH, float radiusV, Color color);

Used in shapes_outlines_testbed.

rl.drawEllipseLinesEx

Draw ellipse outline with line thickness

Zigfn drawEllipseLinesEx(center: Vector2, radiusH: f32, radiusV: f32, thick: f32, color: Color) void
Cvoid DrawEllipseLinesEx(Vector2 center, float radiusH, float radiusV, float thick, Color color);

Used in shapes_outlines_testbed.

rl.drawRingLines

Draw ring outline

Zigfn drawRingLines(center: Vector2, innerRadius: f32, outerRadius: f32, startAngle: f32, endAngle: f32, segments: i32, color: Color) void
Cvoid DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color);

Used in shapes_ring_drawing, shapes_outlines_testbed.

rl.drawRingLinesEx

Draw ring outline with line thickness

Zigfn drawRingLinesEx(center: Vector2, innerRadius: f32, outerRadius: f32, startAngle: f32, endAngle: f32, segments: i32, thick: f32, color: Color) void
Cvoid DrawRingLinesEx(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, float thick, Color color);

Used in shapes_outlines_testbed.

Splines drawing functions

rl.drawSplineBasis

Draw spline: B-Spline, minimum 4 points

Zigfn drawSplineBasis(points: []const Vector2, thick: f32, color: Color) void
Cvoid DrawSplineBasis(const Vector2 *points, int pointCount, float thick, Color color);

Used in shapes_splines_drawing.

rl.drawSplineCatmullRom

Draw spline: Catmull-Rom, minimum 4 points

Zigfn drawSplineCatmullRom(points: []const Vector2, thick: f32, color: Color) void
Cvoid DrawSplineCatmullRom(const Vector2 *points, int pointCount, float thick, Color color);

Used in shapes_splines_drawing.

rl.drawSplineBezierQuadratic

Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...]

Zigfn drawSplineBezierQuadratic(points: []const Vector2, thick: f32, color: Color) void
Cvoid DrawSplineBezierQuadratic(const Vector2 *points, int pointCount, float thick, Color color);

rl.drawSplineBezierCubic

Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...]

Zigfn drawSplineBezierCubic(points: []const Vector2, thick: f32, color: Color) void
Cvoid DrawSplineBezierCubic(const Vector2 *points, int pointCount, float thick, Color color);

Used in shapes_splines_drawing.

rl.drawSplineSegmentLinear

Draw spline segment: Linear, 2 points

Zigfn drawSplineSegmentLinear(p1: Vector2, p2: Vector2, thick: f32, color: Color) void
Cvoid DrawSplineSegmentLinear(Vector2 p1, Vector2 p2, float thick, Color color);

rl.drawSplineSegmentBasis

Draw spline segment: B-Spline, 4 points

Zigfn drawSplineSegmentBasis(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, thick: f32, color: Color) void
Cvoid DrawSplineSegmentBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color);

rl.drawSplineSegmentCatmullRom

Draw spline segment: Catmull-Rom, 4 points

Zigfn drawSplineSegmentCatmullRom(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, thick: f32, color: Color) void
Cvoid DrawSplineSegmentCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color);

rl.drawSplineSegmentBezierQuadratic

Draw spline segment: Quadratic Bezier, 2 points, 1 control point

Zigfn drawSplineSegmentBezierQuadratic(p1: Vector2, c2: Vector2, p3: Vector2, thick: f32, color: Color) void
Cvoid DrawSplineSegmentBezierQuadratic(Vector2 p1, Vector2 c2, Vector2 p3, float thick, Color color);

rl.drawSplineSegmentBezierCubic

Draw spline segment: Cubic Bezier, 2 points, 2 control points

Zigfn drawSplineSegmentBezierCubic(p1: Vector2, c2: Vector2, c3: Vector2, p4: Vector2, thick: f32, color: Color) void
Cvoid DrawSplineSegmentBezierCubic(Vector2 p1, Vector2 c2, Vector2 c3, Vector2 p4, float thick, Color color);

Used in textures_textured_curve.

Spline segment point evaluation functions, for a provided t [0.0f .. 1.0f]

rl.getSplinePointLinear

Get (evaluate) spline point: Linear

Zigfn getSplinePointLinear(startPos: Vector2, endPos: Vector2, t: f32) Vector2
CVector2 GetSplinePointLinear(Vector2 startPos, Vector2 endPos, float t);

rl.getSplinePointBasis

Get (evaluate) spline point: B-Spline

Zigfn getSplinePointBasis(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, t: f32) Vector2
CVector2 GetSplinePointBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float t);

rl.getSplinePointCatmullRom

Get (evaluate) spline point: Catmull-Rom

Zigfn getSplinePointCatmullRom(p1: Vector2, p2: Vector2, p3: Vector2, p4: Vector2, t: f32) Vector2
CVector2 GetSplinePointCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float t);

rl.getSplinePointBezierQuadratic

Get (evaluate) spline point: Quadratic Bezier

Zigfn getSplinePointBezierQuadratic(p1: Vector2, c2: Vector2, p3: Vector2, t: f32) Vector2
CVector2 GetSplinePointBezierQuadratic(Vector2 p1, Vector2 c2, Vector2 p3, float t);

rl.getSplinePointBezierCubic

Get (evaluate) spline point: Cubic Bezier

Zigfn getSplinePointBezierCubic(p1: Vector2, c2: Vector2, c3: Vector2, p4: Vector2, t: f32) Vector2
CVector2 GetSplinePointBezierCubic(Vector2 p1, Vector2 c2, Vector2 c3, Vector2 p4, float t);

Basic shapes collision detection functions

rl.checkCollisionCircles

Check collision between two circles

Zigfn checkCollisionCircles(center1: Vector2, radius1: f32, center2: Vector2, radius2: f32) bool
Cbool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2);

rl.checkCollisionCircleRec

Check collision between circle and rectangle

Zigfn checkCollisionCircleRec(center: Vector2, radius: f32, rec: Rectangle) bool
Cbool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec);

Used in models_first_person_maze.

rl.checkCollisionCircleLine

Check if circle collides with a line created between two points [p1] and [p2]

Zigfn checkCollisionCircleLine(center: Vector2, radius: f32, p1: Vector2, p2: Vector2) bool
Cbool CheckCollisionCircleLine(Vector2 center, float radius, Vector2 p1, Vector2 p2);

rl.checkCollisionPointTriangle

Check if point is inside a triangle

Zigfn checkCollisionPointTriangle(point: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) bool
Cbool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3);

Used in shapes_drag_puzzle.

rl.checkCollisionPointLine

Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]

Zigfn checkCollisionPointLine(point: Vector2, p1: Vector2, p2: Vector2, threshold: i32) bool
Cbool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshold);

rl.checkCollisionPointPoly

Check if point is within a polygon described by array of vertices

Zigfn checkCollisionPointPoly(point: Vector2, points: []const Vector2) bool
Cbool CheckCollisionPointPoly(Vector2 point, const Vector2 *points, int pointCount);

rl.checkCollisionLines

Check the collision between two lines defined by two points each, returns collision point by reference

Zigfn checkCollisionLines(startPos1: Vector2, endPos1: Vector2, startPos2: Vector2, endPos2: Vector2, collisionPoint: *Vector2) bool
Cbool CheckCollisionLines(Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2, Vector2 *collisionPoint);