diff options
author | Samuel Fadel <samuel@nihil.ws> | 2023-06-04 13:02:14 +0200 |
---|---|---|
committer | Samuel Fadel <samuel@nihil.ws> | 2023-06-04 13:02:14 +0200 |
commit | fb23c8d47f6dcef429423256d8dddcc0f7184fc4 (patch) | |
tree | 34e0032f28df5807e4abd90d6b1b4baad24d2991 /scale.cpp | |
parent | 0f34fd437efb936ef29ac91186321aa7251fbfb1 (diff) |
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
Diffstat (limited to 'scale.cpp')
-rw-r--r-- | scale.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
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 <iostream> + +void updateTransform4x4(const LinearScale<float> &sx, + const LinearScale<float> &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<float> &sx, + LinearScale<float> &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); +} |