From dbd6a9dea16c2a4f58884f19b61dddc718c71a5e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 19 Oct 2022 20:39:41 +0200 Subject: [PATCH] - fixed DrawLine commands by giving them a consistent floating point interface. --- src/common/2d/v_draw.cpp | 32 ++++++++++++++-------------- wadsrc/static/zscript/engine/base.zs | 8 +++---- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/common/2d/v_draw.cpp b/src/common/2d/v_draw.cpp index 941306dd4d..b5cc614bc9 100644 --- a/src/common/2d/v_draw.cpp +++ b/src/common/2d/v_draw.cpp @@ -1564,10 +1564,10 @@ static void DrawLine(double x1, double y1, double x2, double y2, uint32_t realco DEFINE_ACTION_FUNCTION_NATIVE(_Screen, DrawLine, DrawLine) { PARAM_PROLOGUE; - PARAM_INT(x0); - PARAM_INT(y0); - PARAM_INT(x1); - PARAM_INT(y1); + PARAM_FLOAT(x0); + PARAM_FLOAT(y0); + PARAM_FLOAT(x1); + PARAM_FLOAT(y1); PARAM_INT(color); PARAM_INT(alpha); DrawLine(x0, y0, x1, y1, color, alpha); @@ -1577,10 +1577,10 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Screen, DrawLine, DrawLine) DEFINE_ACTION_FUNCTION(FCanvas, DrawLine) { PARAM_SELF_PROLOGUE(FCanvas); - PARAM_INT(x0); - PARAM_INT(y0); - PARAM_INT(x1); - PARAM_INT(y1); + PARAM_FLOAT(x0); + PARAM_FLOAT(y0); + PARAM_FLOAT(x1); + PARAM_FLOAT(y1); PARAM_INT(color); PARAM_INT(alpha); self->Drawer.AddLine(DVector2(x0, y0), DVector2(x1, y1), nullptr, color | MAKEARGB(255, 0, 0, 0), alpha); @@ -1597,10 +1597,10 @@ static void DrawThickLine(double x1, double y1, double x2, double y2, double thi DEFINE_ACTION_FUNCTION_NATIVE(_Screen, DrawThickLine, DrawThickLine) { PARAM_PROLOGUE; - PARAM_INT(x0); - PARAM_INT(y0); - PARAM_INT(x1); - PARAM_INT(y1); + PARAM_FLOAT(x0); + PARAM_FLOAT(y0); + PARAM_FLOAT(x1); + PARAM_FLOAT(y1); PARAM_FLOAT(thickness); PARAM_INT(color); PARAM_INT(alpha); @@ -1611,10 +1611,10 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Screen, DrawThickLine, DrawThickLine) DEFINE_ACTION_FUNCTION(FCanvas, DrawThickLine) { PARAM_SELF_PROLOGUE(FCanvas); - PARAM_INT(x0); - PARAM_INT(y0); - PARAM_INT(x1); - PARAM_INT(y1); + PARAM_FLOAT(x0); + PARAM_FLOAT(y0); + PARAM_FLOAT(x1); + PARAM_FLOAT(y1); PARAM_FLOAT(thickness); PARAM_INT(color); PARAM_INT(alpha); diff --git a/wadsrc/static/zscript/engine/base.zs b/wadsrc/static/zscript/engine/base.zs index d610282228..821508434f 100644 --- a/wadsrc/static/zscript/engine/base.zs +++ b/wadsrc/static/zscript/engine/base.zs @@ -513,9 +513,9 @@ class Canvas : Object native abstract native vararg void DrawShapeFill(Color col, double amount, Shape2D s, ...); native vararg void DrawChar(Font font, int normalcolor, double x, double y, int character, ...); native vararg void DrawText(Font font, int normalcolor, double x, double y, String text, ...); - native void DrawLine(int x0, int y0, int x1, int y1, Color color, int alpha = 255); + native void DrawLine(double x0, double y0, double x1, double y1, Color color, int alpha = 255); native void DrawLineFrame(Color color, int x0, int y0, int w, int h, int thickness = 1); - native void DrawThickLine(int x0, int y0, int x1, int y1, double thickness, Color color, int alpha = 255); + native void DrawThickLine(double x0, double y0, double x1, double y1, double thickness, Color color, int alpha = 255); native Vector2, Vector2 VirtualToRealCoords(Vector2 pos, Vector2 size, Vector2 vsize, bool vbottom=false, bool handleaspect=true); native void SetClipRect(int x, int y, int w, int h); native void ClearClipRect(); @@ -546,9 +546,9 @@ struct Screen native native static vararg void DrawShapeFill(Color col, double amount, Shape2D s, ...); native static vararg void DrawChar(Font font, int normalcolor, double x, double y, int character, ...); native static vararg void DrawText(Font font, int normalcolor, double x, double y, String text, ...); - native static void DrawLine(int x0, int y0, int x1, int y1, Color color, int alpha = 255); + native static void DrawLine(double x0, double y0, double x1, double y1, Color color, int alpha = 255); native static void DrawLineFrame(Color color, int x0, int y0, int w, int h, int thickness = 1); - native static void DrawThickLine(int x0, int y0, int x1, int y1, double thickness, Color color, int alpha = 255); + native static void DrawThickLine(double x0, double y0, double x1, double y1, double thickness, Color color, int alpha = 255); native static Vector2, Vector2 VirtualToRealCoords(Vector2 pos, Vector2 size, Vector2 vsize, bool vbottom=false, bool handleaspect=true); native static double GetAspectRatio(); native static void SetClipRect(int x, int y, int w, int h);