rotation
This commit is contained in:
parent
9a25340287
commit
c9fadb3779
5 changed files with 214 additions and 4 deletions
|
|
@ -70,4 +70,25 @@ export namespace Crafter {
|
|||
void UpdatePosition(Window& window) override;
|
||||
void UpdatePosition(Window& window, Transform& parent) override;
|
||||
};
|
||||
|
||||
class RenderingElementScalingRotating2D : public RenderingElement {
|
||||
public:
|
||||
std::vector<Pixel_BU8_GU8_RU8_AU8> buffer;
|
||||
std::uint_fast32_t bufferWidth;
|
||||
std::uint_fast32_t bufferHeight;
|
||||
std::uint_fast32_t rotation;
|
||||
bool rotationUpdated = true;
|
||||
|
||||
RenderingElementScalingRotating2D(OpaqueType opaque = OpaqueType::Transparent);
|
||||
RenderingElementScalingRotating2D(OpaqueType opaque, std::int_fast32_t anchorX, std::int_fast32_t anchorY, std::uint_fast32_t relativeWidth, std::uint_fast32_t relativeHeight, std::int_fast32_t anchorOffsetX, std::int_fast32_t anchorOffsetY, std::int_fast32_t z, bool ignoreScaling);
|
||||
RenderingElementScalingRotating2D(OpaqueType opaque, std::uint_fast32_t bufferWidth, std::uint_fast32_t bufferHeight, std::uint_fast32_t rotationAngle = 0, double scaleX = 1.0, double scaleY = 1.0, std::int_fast32_t anchorX = FractionalToMapped(0.5), std::int_fast32_t anchorY = FractionalToMapped(0.5), std::uint_fast32_t relativeWidth = FractionalToMapped(1), std::uint_fast32_t relativeHeight = FractionalToMapped(1), std::int_fast32_t anchorOffsetX = FractionalToMapped(0.5), std::int_fast32_t anchorOffsetY = FractionalToMapped(0.5), std::int_fast32_t z = 0, bool ignoreScaling = false);
|
||||
RenderingElementScalingRotating2D(RenderingElementScalingRotating2D&) = delete;
|
||||
RenderingElementScalingRotating2D& operator=(RenderingElementScalingRotating2D&) = delete;
|
||||
|
||||
void UpdateRotation(std::uint_fast32_t newRotation);
|
||||
void ResizeBuffer(std::uint_fast32_t width, std::uint_fast32_t height);
|
||||
void UpdateScaledBuffer(ScaleData& data);
|
||||
void UpdatePosition(Window& window) override;
|
||||
void UpdatePosition(Window& window, Transform& parent) override;
|
||||
};
|
||||
}
|
||||
|
|
@ -111,14 +111,22 @@ namespace Crafter {
|
|||
export constexpr std::int_fast32_t BOUND = 9;
|
||||
export constexpr std::int_fast32_t SCALE = std::numeric_limits<std::int_fast32_t>::max() / BOUND;
|
||||
export constexpr double SCALEDOUBLE = static_cast<double>(std::numeric_limits<std::int_fast32_t>::max()) / BOUND;
|
||||
export constexpr double SCALEDOUBLEU = static_cast<double>(std::numeric_limits<std::uint_fast32_t>::max()) / BOUND;
|
||||
|
||||
export constexpr std::int_fast32_t SCALEBOUNDLESS = std::numeric_limits<std::int_fast32_t>::max();
|
||||
export constexpr double SCALEDOUBLEBOUNDLESS = static_cast<double>(std::numeric_limits<std::int_fast32_t>::max());
|
||||
|
||||
export constexpr std::int_fast32_t SCALEBOUNDLESSU = std::numeric_limits<std::uint_fast32_t>::max();
|
||||
export constexpr double SCALEDOUBLEBOUNDLESSU = static_cast<double>(std::numeric_limits<std::uint_fast32_t>::max());
|
||||
|
||||
export constexpr std::int_fast32_t FractionalToMapped(double f) {
|
||||
return std::int_fast32_t(f * SCALEDOUBLE);
|
||||
}
|
||||
|
||||
export constexpr std::uint_fast32_t FractionalToMappedU(double f) {
|
||||
return std::uint_fast32_t(f * SCALEDOUBLEU);
|
||||
}
|
||||
|
||||
export constexpr double MappedToFractional(std::int_fast32_t mapped) {
|
||||
return static_cast<double>(mapped) / SCALEDOUBLE;
|
||||
}
|
||||
|
|
@ -139,6 +147,10 @@ namespace Crafter {
|
|||
return std::int_fast32_t(f * SCALEDOUBLEBOUNDLESS);
|
||||
}
|
||||
|
||||
export constexpr std::uint_fast32_t FractionalToMappedBoundlessU(double f) {
|
||||
return std::uint_fast32_t(f * SCALEDOUBLEBOUNDLESSU);
|
||||
}
|
||||
|
||||
export constexpr double MappedToFractionalBoundless(std::int_fast32_t mapped) {
|
||||
return static_cast<double>(mapped) / SCALEDOUBLEBOUNDLESS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue