Painter: Xform2D::GetClass removed

This commit is contained in:
Mirek Fidler 2023-11-29 21:16:02 +01:00
parent eba38dda5d
commit a402ea0cb4
6 changed files with 4213 additions and 27 deletions

View file

@ -6,13 +6,14 @@ GUI_APP_MAIN
{ {
ImagePainter iw(4000, 2000); ImagePainter iw(4000, 2000);
iw.Co(); iw.Co();
Image m;
for(int i = 0; i < 10; i++) { for(int i = 0; i < 20; i++) {
{ {
RTIMING("Clear"); RTIMING("Clear");
iw.Clear(); iw.Clear();
} }
{ if(1) {
RTIMING("Text"); RTIMING("Text");
for(int y = 0; y < 2000; y += 30) for(int y = 0; y < 2000; y += 30)
iw.DrawText(0, y, iw.DrawText(0, y,
@ -20,8 +21,9 @@ GUI_APP_MAIN
Arial(25)); Arial(25));
iw.Finish(); iw.Finish();
} }
// m = iw;
} }
TopWindow win; TopWindow win;
ImageCtrl h; ImageCtrl h;
h.SetImage(iw); h.SetImage(iw);

View file

@ -13,16 +13,6 @@ namespace Upp {
INITIALIZE(PaintPainting) INITIALIZE(PaintPainting)
enum XformClass { // classification of Xform (simpler forms can be optimized)
XFORM_REGULAR = 32, // same scale in X and Y, does not skew line width
XFORM_IDENTITY = 0|XFORM_REGULAR, // not transformation
XFORM_TRANSLATION = 1|XFORM_REGULAR,
XFORM_REGULAR_SCALE = 2|XFORM_REGULAR, // just scale, same in X and Y
XFORM_SCALE = 2, // just scale, but X scale != Y scale
XFORM_ANY = 0,
};
struct Xform2D { struct Xform2D {
Pointf x, y, t; Pointf x, y, t;
@ -33,8 +23,6 @@ struct Xform2D {
double GetScale() const; double GetScale() const;
bool IsRegular() const; bool IsRegular() const;
byte GetClass() const;
static Xform2D Identity(); static Xform2D Identity();
static Xform2D Translation(double x, double y); static Xform2D Translation(double x, double y);
static Xform2D Scale(double sx, double sy); static Xform2D Scale(double sx, double sy);

View file

@ -24,18 +24,6 @@ bool Xform2D::IsRegular() const
return Epsqual(d.x, d.y); return Epsqual(d.x, d.y);
} }
byte Xform2D::GetClass() const
{
if(x.y == 0 && y.x == 0) {
if(t.x == 0 && t.y == 0)
return XFORM_IDENTITY;
else
return XFORM_TRANSLATION;
return Epsqual(x.x, y.x) ? XFORM_REGULAR_SCALE : XFORM_SCALE;
}
return IsRegular() ? XFORM_REGULAR : XFORM_ANY;
}
Xform2D::Xform2D() Xform2D::Xform2D()
{ {
x.x = y.y = 1; x.x = y.y = 1;

View file

@ -0,0 +1,10 @@
uses
CtrlLib;
file
test.iml,
main.cpp;
mainconfig
"" = "GUI";

View file

@ -0,0 +1,45 @@
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#define IMAGECLASS TestImg
#define IMAGEFILE <PainterImage3/test.iml>
#include <Draw/iml_header.h>
#define IMAGECLASS TestImg
#define IMAGEFILE <PainterImage3/test.iml>
#include <Draw/iml_source.h>
struct MyApp : TopWindow {
DropList dl;
Pointf p1 = Pointf(0, 0);
Pointf p2 = Pointf(200, 0);
Pointf p3 = Pointf(200, 200);
void Paint(Draw& w) override {
Size sz = GetSize();
DrawPainter iw(w, GetSize());
iw.Clear(SWhite());
iw.Rectangle(0, 0, sz.cx, sz.cy).Fill(TestImg::naso(), p1, p2);
}
void LeftDown(Point p, dword keyflags) override
{
p1 = p;
Refresh();
}
void RightDown(Point p, dword keyflags) override
{
p2 = p;
Refresh();
}
MyApp() {
}
};
GUI_APP_MAIN
{
MyApp().Run();
}

File diff suppressed because it is too large Load diff