J2DGrafContext and J2DOrthoGraph

This commit is contained in:
lepelog
2021-12-06 12:57:45 +01:00
parent c15d8fcb3e
commit 9da2309be7
34 changed files with 250 additions and 1633 deletions
+15 -13
View File
@@ -51,9 +51,9 @@ struct TVec2 {
}
void setMin(const TVec2<f32>& min) {
if (min.x <= x)
if (x >= min.x)
x = min.x;
if (min.y <= y)
if (y >= min.y)
y = min.y;
}
@@ -70,7 +70,7 @@ struct TVec2 {
}
bool isAbove(const TVec2<T>& other) const {
return (other.x <= x) && (other.y <= y) ? true : false;
return (x >= other.x) && (y >= other.y) ? true : false;
}
T x;
@@ -90,14 +90,6 @@ template<> struct TBox<TVec2<f32> > {
f32 getWidth() const { return f.x - i.x; }
f32 getHeight() const { return f.y - i.y; }
inline void operator= (const TBox<TVec2<f32> >& rhs) {
// ???
*(u32*)&i.x = *(u32*)&rhs.i.x;
*(u32*)&i.y = *(u32*)&rhs.i.y;
*(u32*)&f.x = *(u32*)&rhs.f.x;
*(u32*)&f.y = *(u32*)&rhs.f.y;
}
bool isValid() const { return f.isAbove(i); }
void addPos(const TVec2<f32>& pos) {
@@ -117,9 +109,19 @@ template<> struct TBox<TVec2<f32> > {
template <typename T>
struct TBox2 : TBox<TVec2<T> > {
TBox2() {}
TBox2(const TVec2<f32>& i, const TVec2<f32> f) { set(i, f); }
TBox2(f32 x0, f32 y0, f32 x1, f32 y1) { set(x0, y0, x1, y1); }
inline const TBox2& operator=(const TBox2& rhs) { *(TBox<TVec2<T> >*)this = rhs; }
void absolute() {
if (!this->isValid()) {
TBox2<T> box(*this);
this->i.setMin(box.i);
this->i.setMin(box.f);
this->f.setMax(box.i);
this->f.setMax(box.f);
}
}
void set(const TBox2& other) { set(other.i, other.f); }
void set(const TVec2<f32>& i, const TVec2<f32> f) { this->i.set(i), this->f.set(f); }
void set(f32 x0, f32 y0, f32 x1, f32 y1) { i.set(x0, y0); f.set(x1, y1); }
@@ -129,4 +131,4 @@ struct TBox2 : TBox<TVec2<T> > {
} // namespace JGeometry
#endif
#endif