From 4ff5b2cdc8b385dd8e88e83d0f47fe946ffe2543 Mon Sep 17 00:00:00 2001 From: Alessandro Cuppari Date: Mon, 31 Oct 2022 14:06:41 +0000 Subject: [PATCH 1/2] Added ImageDrawLine and ImageDrawLineV --- raylib/rtextures.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/raylib/rtextures.go b/raylib/rtextures.go index ba343a5..27d1fc2 100644 --- a/raylib/rtextures.go +++ b/raylib/rtextures.go @@ -384,6 +384,28 @@ func ImageDraw(dst, src *Image, srcRec, dstRec Rectangle, tint color.RGBA) { C.ImageDraw(cdst, *csrc, *csrcRec, *cdstRec, *ctint) } +// ImageDrawLine - Draw line within an image +func ImageDrawLine(dst *Image, startPosX, startPosY, endPosX, endPosY int32, col color.RGBA) { + cdst := dst.cptr() + cstartPosX := (C.int)(startPosX) + cstartPosY := (C.int)(startPosY) + cendPosX := (C.int)(endPosX) + cendPosY := (C.int)(endPosY) + ccolor := colorCptr(col) + C.ImageDrawLine(cdst, cstartPosX, cstartPosY, cendPosX, cendPosY, ccolor) +} + +// ImageDrawLineV - Draw line within an image, vector version +func ImageDrawLineV(dst *Image, startPosX, startPosY, endPosX, endPosY int32, col color.RGBA) { + cdst := dst.cptr() + cstartPosX := (C.int)(startPosX) + cstartPosY := (C.int)(startPosY) + cendPosX := (C.int)(endPosX) + cendPosY := (C.int)(endPosY) + ccolor := colorCptr(col) + C.ImageDrawLineV(cdst, cstartPosX, cstartPosY, cendPosX, cendPosY, ccolor) +} + // ImageDrawCircle - Draw a filled circle within an image func ImageDrawCircle(dst *Image, centerX, centerY, radius int32, col color.RGBA) { cdst := dst.cptr() From 971b4522172cb26cb92de8edf63b28a4e30d7bd2 Mon Sep 17 00:00:00 2001 From: Alessandro Cuppari Date: Mon, 31 Oct 2022 14:19:58 +0000 Subject: [PATCH 2/2] Fixed signature of ImageDrawLineV --- raylib/rtextures.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/raylib/rtextures.go b/raylib/rtextures.go index 27d1fc2..a74d7c0 100644 --- a/raylib/rtextures.go +++ b/raylib/rtextures.go @@ -392,18 +392,16 @@ func ImageDrawLine(dst *Image, startPosX, startPosY, endPosX, endPosY int32, col cendPosX := (C.int)(endPosX) cendPosY := (C.int)(endPosY) ccolor := colorCptr(col) - C.ImageDrawLine(cdst, cstartPosX, cstartPosY, cendPosX, cendPosY, ccolor) + C.ImageDrawLine(cdst, cstartPosX, cstartPosY, cendPosX, cendPosY, *ccolor) } // ImageDrawLineV - Draw line within an image, vector version -func ImageDrawLineV(dst *Image, startPosX, startPosY, endPosX, endPosY int32, col color.RGBA) { +func ImageDrawLineV(dst *Image, start, end Vector2, col color.RGBA) { cdst := dst.cptr() - cstartPosX := (C.int)(startPosX) - cstartPosY := (C.int)(startPosY) - cendPosX := (C.int)(endPosX) - cendPosY := (C.int)(endPosY) + cstart := start.cptr() + cend := end.cptr() ccolor := colorCptr(col) - C.ImageDrawLineV(cdst, cstartPosX, cstartPosY, cendPosX, cendPosY, ccolor) + C.ImageDrawLineV(cdst, *cstart, *cend, *ccolor) } // ImageDrawCircle - Draw a filled circle within an image