From bbeaed58afecdc2c70326581b47733e969e92064 Mon Sep 17 00:00:00 2001 From: xzebra Date: Sat, 6 Feb 2021 01:11:59 +0100 Subject: [PATCH 1/6] circle sector functions --- raylib/shapes.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/raylib/shapes.go b/raylib/shapes.go index f3706b0..1d74931 100644 --- a/raylib/shapes.go +++ b/raylib/shapes.go @@ -67,6 +67,28 @@ func DrawCircle(centerX, centerY int32, radius float32, color Color) { C.DrawCircle(ccenterX, ccenterY, cradius, *ccolor) } +// DrawCircleSector - Draw a piece of a circle +func DrawCircleSector(center Vector2, radius float32, startAngle, endAngle, segments int32, color Color) { + ccenter := center.cptr() + cradius := (C.float)(radius) + cstartAngle := (C.int)(startAngle) + cendAngle := (C.int)(endAngle) + csegments := (C.int)(segments) + ccolor := color.cptr() + C.DrawCircleSector(*ccenter, cradius, cstartAngle, cendAngle, csegments, *ccolor) +} + +// DrawCircleSectorLines - +func DrawCircleSectorLines(center Vector2, radius float32, startAngle, endAngle, segments int32, color Color) { + ccenter := center.cptr() + cradius := (C.float)(radius) + cstartAngle := (C.int)(startAngle) + cendAngle := (C.int)(endAngle) + csegments := (C.int)(segments) + ccolor := color.cptr() + C.DrawCircleSectorLines(*ccenter, cradius, cstartAngle, cendAngle, csegments, *ccolor) +} + // DrawCircleGradient - Draw a gradient-filled circle func DrawCircleGradient(centerX, centerY int32, radius float32, color1, color2 Color) { ccenterX := (C.int)(centerX) From 8448e4c97cb37d629431b818429f2fc87c77a8f8 Mon Sep 17 00:00:00 2001 From: xzebra Date: Sat, 6 Feb 2021 01:12:11 +0100 Subject: [PATCH 2/6] ring functions --- raylib/shapes.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/raylib/shapes.go b/raylib/shapes.go index 1d74931..e5926b0 100644 --- a/raylib/shapes.go +++ b/raylib/shapes.go @@ -136,6 +136,30 @@ func DrawEllipseLines(centerX, centerY int32, radiusH, radiusV float32, color Co C.DrawEllipseLines(ccenterX, ccenterY, cradiusH, cradiusV, *ccolor) } +// DrawRing - +func DrawRing(center Vector2, innerRadius, outerRadius float32, startAngle, endAngle, segments int32, color Color) { + ccenter := center.cptr() + cinnerRadius := (C.float)(innerRadius) + couterRadius := (C.float)(outerRadius) + cstartAngle := (C.int)(startAngle) + cendAngle := (C.int)(endAngle) + csegments := (C.int)(segments) + ccolor := color.cptr() + C.DrawRing(*ccenter, cinnerRadius, couterRadius, cstartAngle, cendAngle, csegments, *ccolor) +} + +// DrawRingLines - +func DrawRingLines(center Vector2, innerRadius, outerRadius float32, startAngle, endAngle, segments int32, color Color) { + ccenter := center.cptr() + cinnerRadius := (C.float)(innerRadius) + couterRadius := (C.float)(outerRadius) + cstartAngle := (C.int)(startAngle) + cendAngle := (C.int)(endAngle) + csegments := (C.int)(segments) + ccolor := color.cptr() + C.DrawRingLines(*ccenter, cinnerRadius, couterRadius, cstartAngle, cendAngle, csegments, *ccolor) +} + // DrawRectangle - Draw a color-filled rectangle func DrawRectangle(posX, posY, width, height int32, color Color) { cposX := (C.int)(posX) From 7d41c2d3df5d05b6ce7a5e56a682324e9e724b1e Mon Sep 17 00:00:00 2001 From: xzebra Date: Sat, 6 Feb 2021 01:12:27 +0100 Subject: [PATCH 3/6] rounded rectangle functions --- raylib/shapes.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/raylib/shapes.go b/raylib/shapes.go index e5926b0..2bdf435 100644 --- a/raylib/shapes.go +++ b/raylib/shapes.go @@ -244,6 +244,25 @@ func DrawRectangleLinesEx(rec Rectangle, lineThick int32, color Color) { C.DrawRectangleLinesEx(*crec, clineThick, *ccolor) } +// DrawRectangleRounded - Draw rectangle with rounded edges +func DrawRectangleRounded(rec Rectangle, roundness float32, segments int32, color Color) { + crec := rec.cptr() + croundness := (C.float)(roundness) + csegments := (C.int)(segments) + ccolor := color.cptr() + C.DrawRectangleRounded(*crec, croundness, csegments, *ccolor) +} + +// DrawRectangleRoundedLines - Draw rectangle with rounded edges outline +func DrawRectangleRoundedLines(rec Rectangle, roundness float32, segments, lineThick int32, color Color) { + crec := rec.cptr() + croundness := (C.float)(roundness) + csegments := (C.int)(segments) + clineThick := (C.int)(lineThick) + ccolor := color.cptr() + C.DrawRectangleRoundedLines(*crec, croundness, csegments, clineThick, *ccolor) +} + // DrawTriangle - Draw a color-filled triangle func DrawTriangle(v1, v2, v3 Vector2, color Color) { cv1 := v1.cptr() From 1b2825bc0c0203d77a68101714a84797e49c7512 Mon Sep 17 00:00:00 2001 From: xzebra Date: Sat, 6 Feb 2021 01:12:40 +0100 Subject: [PATCH 4/6] triangle functions --- raylib/shapes.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/raylib/shapes.go b/raylib/shapes.go index 2bdf435..cf3dc12 100644 --- a/raylib/shapes.go +++ b/raylib/shapes.go @@ -281,6 +281,22 @@ func DrawTriangleLines(v1, v2, v3 Vector2, color Color) { C.DrawTriangleLines(*cv1, *cv2, *cv3, *ccolor) } +// DrawTriangleFan - Draw a triangle fan defined by points +func DrawTriangleFan(points []Vector2, color Color) { + cpoints := (*C.Vector2)(unsafe.Pointer(&points[0])) + cpointsCount := (C.int)(int32(len(points))) + ccolor := color.cptr() + C.DrawTriangleLines(*cpoints, cpointsCount, *ccolor) +} + +// DrawTriangleStrip - Draw a triangle strip defined by points +func DrawTriangleStrip(points []Vector2, color Color) { + cpoints := (*C.Vector2)(unsafe.Pointer(&points[0])) + cpointsCount := (C.int)(int32(len(points))) + ccolor := color.cptr() + C.DrawTriangleStrip(*cpoints, cpointsCount, *ccolor) +} + // DrawPoly - Draw a regular polygon (Vector version) func DrawPoly(center Vector2, sides int32, radius, rotation float32, color Color) { ccenter := center.cptr() From afb72fa594babcaf421d99ac9a9ecb60ebf35294 Mon Sep 17 00:00:00 2001 From: xzebra Date: Sat, 6 Feb 2021 01:12:57 +0100 Subject: [PATCH 5/6] lined polygon function --- raylib/shapes.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/raylib/shapes.go b/raylib/shapes.go index cf3dc12..d007617 100644 --- a/raylib/shapes.go +++ b/raylib/shapes.go @@ -307,6 +307,16 @@ func DrawPoly(center Vector2, sides int32, radius, rotation float32, color Color C.DrawPoly(*ccenter, csides, cradius, crotation, *ccolor) } +// DrawPolyLines - Draw a polygon outline of n sides +func DrawPolyLines(center Vector2, sides int32, radius, rotation float32, color Color) { + ccenter := center.cptr() + csides := (C.int)(sides) + cradius := (C.float)(radius) + crotation := (C.float)(rotation) + ccolor := color.cptr() + C.DrawPolyLines(*ccenter, csides, cradius, crotation, *ccolor) +} + // CheckCollisionRecs - Check collision between two rectangles func CheckCollisionRecs(rec1, rec2 Rectangle) bool { crec1 := rec1.cptr() From a7db43f398c27a56ac03928d92cf3ca75d640238 Mon Sep 17 00:00:00 2001 From: xzebra Date: Sat, 6 Feb 2021 01:34:23 +0100 Subject: [PATCH 6/6] fix binding mistakes --- raylib/shapes.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/raylib/shapes.go b/raylib/shapes.go index d007617..39e499f 100644 --- a/raylib/shapes.go +++ b/raylib/shapes.go @@ -286,7 +286,7 @@ func DrawTriangleFan(points []Vector2, color Color) { cpoints := (*C.Vector2)(unsafe.Pointer(&points[0])) cpointsCount := (C.int)(int32(len(points))) ccolor := color.cptr() - C.DrawTriangleLines(*cpoints, cpointsCount, *ccolor) + C.DrawTriangleFan(cpoints, cpointsCount, *ccolor) } // DrawTriangleStrip - Draw a triangle strip defined by points @@ -294,7 +294,7 @@ func DrawTriangleStrip(points []Vector2, color Color) { cpoints := (*C.Vector2)(unsafe.Pointer(&points[0])) cpointsCount := (C.int)(int32(len(points))) ccolor := color.cptr() - C.DrawTriangleStrip(*cpoints, cpointsCount, *ccolor) + C.DrawTriangleStrip(cpoints, cpointsCount, *ccolor) } // DrawPoly - Draw a regular polygon (Vector version)