29 #ifndef Pt_Gfx_Scaling_h
30 #define Pt_Gfx_Scaling_h
32 #include <Pt/Gfx/Api.h>
33 #include <Pt/Gfx/Point.h>
34 #include <Pt/Gfx/Size.h>
35 #include <Pt/Gfx/Rect.h>
152 p =
lround(p + 0.5) - 0.5;
161 if (_scaleFactor < 1.0)
162 return toLogical(
static_cast<double>(n) );
164 double p =
toPhysical(
static_cast<double>(n) );
165 size_t s =
static_cast<size_t>(p);
166 return toLogical(
static_cast<double>(s) );
174 pos.setX(
lround(pos.x()));
175 pos.setY(
lround(pos.y()));
184 size.setWidth(
lround(size.width()));
185 size.setHeight(
lround(size.height()));
194 pos.setX(
lround(pos.x()));
195 pos.setY(
lround(pos.y()));
198 size.setWidth(
lround(size.width()));
199 size.setHeight(
lround(size.height()));
214 return a._scaleFactor == b._scaleFactor;
232 return a._scaleFactor < b._scaleFactor;
Gfx::SizeF align(const Gfx::SizeF &s) const
Aligns a size to physical pixels.
Definition: Scaling.h:181
Core module.
Definition: Allocator.h:33
double alignContour(size_t n) const
Aligns a contour width while preserving visible thickness.
Definition: Scaling.h:158
Gfx::RectF toPhysical(const Gfx::RectF &r) const
Converts a rectangle to physical units.
Definition: Scaling.h:98
double scaleFactor() const
Returns the scale factor.
Definition: Scaling.h:62
Logical-to-physical unit conversion.
Definition: Scaling.h:49
Size with floating-point width and height.
Definition: Size.h:45
Point with floating-point X and Y coordinates.
Definition: Point.h:45
Pt::int32_t lround(float x)
Rounds to nearest integer value.
Definition: Math.h:289
Gfx::PointF align(const Gfx::PointF &p) const
Aligns a point to physical pixels.
Definition: Scaling.h:171
double align(double n) const
Aligns a scalar value to the nearest physical pixel.
Definition: Scaling.h:138
void setScaleFactor(double scaleFactor)
Sets the scale factor.
Definition: Scaling.h:69
double toPhysical(double n) const
Converts a scalar value to physical units.
Definition: Scaling.h:77
Gfx::PointF toLogical(const Gfx::PointF &p) const
Converts a point to logical units.
Definition: Scaling.h:114
Scaling(double scaleFactor=1.0)
Constructs a scaling with the given factor.
Definition: Scaling.h:56
Gfx::SizeF toLogical(const Gfx::SizeF &s) const
Converts a size to logical units.
Definition: Scaling.h:121
double toLogical(double n) const
Converts a scalar value to logical units.
Definition: Scaling.h:107
Gfx::RectF toLogical(const Gfx::RectF &r) const
Converts a rectangle to logical units.
Definition: Scaling.h:128
Gfx::PointF toPhysical(const Gfx::PointF &p) const
Converts a point to physical units.
Definition: Scaling.h:84
Rect with floating-point coordinates.
Definition: Rect.h:45
Gfx::RectF align(const Gfx::RectF &rect) const
Aligns a rectangle to physical pixels.
Definition: Scaling.h:191
double alignPixel(double n) const
Aligns a scalar value to a pixel center.
Definition: Scaling.h:149
Gfx::SizeF toPhysical(const Gfx::SizeF &s) const
Converts a size to physical units.
Definition: Scaling.h:91