From fb23c8d47f6dcef429423256d8dddcc0f7184fc4 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Sun, 4 Jun 2023 13:02:14 +0200 Subject: Further advances in nuklear port. Rendering now looks similar to Qt version, needs a few tweaks: * Proper multisampling * Background Missing features: * Barcharts * Interactivity (e.g. brushing/linking in all objects) * History view of interactions --- scale.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 scale.cpp (limited to 'scale.cpp') diff --git a/scale.cpp b/scale.cpp new file mode 100644 index 0000000..ba0cff0 --- /dev/null +++ b/scale.cpp @@ -0,0 +1,38 @@ +#include "scale.h" + +#include + +void updateTransform4x4(const LinearScale &sx, + const LinearScale &sy, + float transform[4][4]) +{ + float fsx = 2.0f * sx.slope(); + float ftx = 2.0f * sx.offset() - 1.0f; + float fsy = 2.0f * sy.slope(); + float fty = 2.0f * sy.offset() - 1.0f; + + // The transform matrix should be this, but we have it transposed + // in memory: + // + // [ sx 0.0f 0.0f tx ] + // [ 0.0f sy 0.0f ty ] + // [ 0.0f 0.0f 0.0f 0.0f ] + // [ 0.0f 0.0f 0.0f 1.0f ] + // + // It is already initialized with 0s and bottom-right 1 + transform[0][0] = fsx; + transform[1][1] = fsy; + transform[3][0] = ftx; + transform[3][1] = fty; +} + +void updateTransform4x4(LinearScale &sx, + LinearScale &sy, + float offsetX, + float offsetY, + float transform[4][4]) +{ + sx.setRange(offsetX, 1.0f - offsetX); + sy.setRange(1.0f - offsetY, offsetY); + updateTransform4x4(sx, sy, transform); +} -- cgit v1.2.3