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>
105 return Gfx::RectF(p, s);
133 Gfx::PointF p =
toLogical( r.topLeft() );
135 return Gfx::RectF(p, s);
155 p =
lround(p + 0.5) - 0.5;
164 if (_scaleFactor < 1.0)
165 return toLogical(
static_cast<double>(n) );
167 double p =
toPhysical(
static_cast<double>(n) );
168 size_t s =
static_cast<size_t>(p);
169 return toLogical(
static_cast<double>(s) );
174 Gfx::PointF
align(
const Gfx::PointF& p)
const
177 pos.setX(
lround(pos.x()));
178 pos.setY(
lround(pos.y()));
184 Gfx::SizeF
align(
const Gfx::SizeF& s)
const
187 size.setWidth(
lround(size.width()));
188 size.setHeight(
lround(size.height()));
194 Gfx::RectF
align(
const Gfx::RectF& rect)
const
197 pos.setX(
lround(pos.x()));
198 pos.setY(
lround(pos.y()));
201 size.setWidth(
lround(size.width()));
202 size.setHeight(
lround(size.height()));
217 return a._scaleFactor == b._scaleFactor;
235 return a._scaleFactor < b._scaleFactor;
double toLogical(double n) const
Converts a scalar value to logical units.
Definition Scaling.h:110
Gfx::RectF toPhysical(const Gfx::RectF &r) const
Converts a rectangle to physical units.
Definition Scaling.h:101
double alignPixel(double n) const
Aligns a scalar value to a pixel center.
Definition Scaling.h:152
Gfx::PointF toPhysical(const Gfx::PointF &p) const
Converts a point to physical units.
Definition Scaling.h:87
void setScaleFactor(double scaleFactor)
Sets the scale factor.
Definition Scaling.h:72
Gfx::SizeF toPhysical(const Gfx::SizeF &s) const
Converts a size to physical units.
Definition Scaling.h:94
Gfx::SizeF align(const Gfx::SizeF &s) const
Aligns a size to physical pixels.
Definition Scaling.h:184
double scaleFactor() const
Returns the scale factor.
Definition Scaling.h:65
Gfx::PointF toLogical(const Gfx::PointF &p) const
Converts a point to logical units.
Definition Scaling.h:117
Gfx::PointF align(const Gfx::PointF &p) const
Aligns a point to physical pixels.
Definition Scaling.h:174
double alignContour(size_t n) const
Aligns a contour width while preserving visible thickness.
Definition Scaling.h:161
Scaling(double scaleFactor=1.0)
Constructs a scaling with the given factor.
Definition Scaling.h:59
double toPhysical(double n) const
Converts a scalar value to physical units.
Definition Scaling.h:80
Gfx::RectF align(const Gfx::RectF &rect) const
Aligns a rectangle to physical pixels.
Definition Scaling.h:194
Gfx::RectF toLogical(const Gfx::RectF &r) const
Converts a rectangle to logical units.
Definition Scaling.h:131
double align(double n) const
Aligns a scalar value to the nearest physical pixel.
Definition Scaling.h:141
Gfx::SizeF toLogical(const Gfx::SizeF &s) const
Converts a size to logical units.
Definition Scaling.h:124
Graphics and imaging services.
Definition Api-Argb32Image.h:12
Core module.
Definition Allocator.h:33
Pt::int32_t lround(float x)
Rounds to nearest integer value.
Definition Math.h:289