Dessiner cercles
This commit is contained in:
parent
8e1108d534
commit
f2aae2a502
|
@ -38,6 +38,10 @@ public:
|
|||
bool wintabAvailable = false;
|
||||
PACKET pkt = { 0 };
|
||||
UINT maxPressure = 1;
|
||||
float extX;
|
||||
float extY;
|
||||
float extZ;
|
||||
float extP;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -66,16 +70,21 @@ private:
|
|||
ctx.lcInExtX = TabletX.axMax;
|
||||
ctx.lcOutOrgX = TabletX.axMin;
|
||||
ctx.lcOutExtX = TabletX.axMax;
|
||||
extX = TabletX.axMax;
|
||||
|
||||
ctx.lcInOrgY = TabletY.axMin;
|
||||
ctx.lcInExtY = TabletY.axMax;
|
||||
ctx.lcOutOrgY = TabletY.axMin;
|
||||
ctx.lcOutExtY = TabletY.axMax;
|
||||
extY = TabletY.axMax;
|
||||
|
||||
ctx.lcInOrgZ = TabletZ.axMin;
|
||||
ctx.lcInExtZ = TabletZ.axMax;
|
||||
ctx.lcOutOrgZ = TabletZ.axMin;
|
||||
ctx.lcOutExtZ = TabletZ.axMax;
|
||||
extZ = TabletZ.axMax;
|
||||
|
||||
extP = TabletPressure.axMax;
|
||||
|
||||
hctx = gpWTOpenA(hwnd, &ctx, FALSE);
|
||||
|
||||
|
|
|
@ -38,10 +38,16 @@ protected:
|
|||
|
||||
//Lire donnés de la tablet
|
||||
tab.NewPacket();
|
||||
fParameters[kParameterTabletX] = static_cast<float>(tab.pkt.pkX);
|
||||
fParameters[kParameterTabletY] = static_cast<float>(tab.pkt.pkY);
|
||||
fParameters[kParameterTabletZ] = static_cast<float>(tab.pkt.pkZ);
|
||||
fParameters[kParameterTabletPressure] = static_cast<float>(tab.pkt.pkNormalPressure);
|
||||
|
||||
float x = 1000.0f * static_cast<float>(tab.pkt.pkX) / tab.extX;
|
||||
float y = 1000.0f * static_cast<float>(tab.pkt.pkY) / tab.extY;
|
||||
float z = 1000.0f * static_cast<float>(tab.pkt.pkZ) / tab.extZ;
|
||||
float p = 1000.0f * static_cast<float>(tab.pkt.pkNormalPressure) / tab.extP;
|
||||
|
||||
fParameters[kParameterTabletX] = x;
|
||||
fParameters[kParameterTabletY] = y;
|
||||
fParameters[kParameterTabletZ] = z;
|
||||
fParameters[kParameterTabletPressure] = p;
|
||||
|
||||
|
||||
repaint();
|
||||
|
@ -57,6 +63,13 @@ protected:
|
|||
|
||||
void onNanoDisplay() override
|
||||
{
|
||||
drawCircle(
|
||||
fParameters[kParameterTabletX],
|
||||
fParameters[kParameterTabletY],
|
||||
fParameters[kParameterTabletZ],
|
||||
fParameters[kParameterTabletPressure]
|
||||
);
|
||||
|
||||
const float lineHeight = 20 * fScale;
|
||||
|
||||
fontSize(15.0f * fScale);
|
||||
|
@ -87,6 +100,44 @@ protected:
|
|||
drawLeft(x, y, "p:");
|
||||
drawRight(x, y, getTextBufFloat(fParameters[kParameterTabletPressure]));
|
||||
y += lineHeight;
|
||||
|
||||
}
|
||||
|
||||
void drawCircle(float x, float y, float z, float p) {
|
||||
|
||||
static constexpr float circleRadius = 25.f;
|
||||
x *= getWidth() * 0.001f;
|
||||
y = (1000.f - y) * getHeight() * 0.001f;
|
||||
z = 1.f - z * 0.001f;
|
||||
p *= 0.001f;
|
||||
|
||||
beginPath();
|
||||
strokeColor(1.f, 1.f, 1.f, 0.5f);
|
||||
moveTo(x - z * circleRadius, y);
|
||||
lineTo(x + z * circleRadius, y);
|
||||
stroke();
|
||||
closePath();
|
||||
|
||||
beginPath();
|
||||
strokeColor(1.f, 1.f, 1.f, 0.5f);
|
||||
moveTo(x , y - z * circleRadius);
|
||||
lineTo(x , y + z * circleRadius);
|
||||
stroke();
|
||||
closePath();
|
||||
|
||||
beginPath();
|
||||
fillColor(1.f, 1.f, 1.f, p);
|
||||
strokeColor(255, 255, 255, 255);
|
||||
circle(x, y, circleRadius);
|
||||
fill();
|
||||
stroke();
|
||||
closePath();
|
||||
|
||||
beginPath();
|
||||
strokeColor(1.f, 1.f, 1.f, z);
|
||||
circle(x, y, z * circleRadius);
|
||||
stroke();
|
||||
closePath();
|
||||
}
|
||||
|
||||
void onResize(const ResizeEvent& ev) override
|
||||
|
|
Loading…
Reference in New Issue