Some minor cosmetic changes.

This commit is contained in:
Leon Styhre 2020-09-04 19:05:48 +02:00
parent fd10aba815
commit 79b5bfffef
6 changed files with 11 additions and 11 deletions

View file

@ -294,19 +294,19 @@ const Transform4x4f& GuiComponent::getTransform()
if (mScale != 1.0)
mTransform.scale(mScale);
if (mRotation != 0.0) {
// Calculate offset as difference between origin and rotation origin
// Calculate offset as difference between origin and rotation origin.
Vector2f rotationSize = getRotationSize();
float xOff = (mOrigin.x() - mRotationOrigin.x()) * rotationSize.x();
float yOff = (mOrigin.y() - mRotationOrigin.y()) * rotationSize.y();
// Transform to offset point
// Transform to offset point.
if (xOff != 0.0 || yOff != 0.0)
mTransform.translate(Vector3f(xOff * -1, yOff * -1, 0.0f));
// Apply rotation transform
// Apply rotation transform.
mTransform.rotateZ(mRotation);
// Tranform back to original point
// Transform back to original point.
if (xOff != 0.0 || yOff != 0.0)
mTransform.translate(Vector3f(xOff, yOff, 0.0f));
}
@ -373,12 +373,12 @@ bool GuiComponent::finishAnimation(unsigned char slot)
{
assert(slot < MAX_ANIMATIONS);
if (mAnimationMap[slot]) {
// Skip to animation's end
// Skip to animation's end.
const bool done = mAnimationMap[slot]->update(mAnimationMap[slot]->
getAnimation()->getDuration() - mAnimationMap[slot]->getTime());
assert(done);
delete mAnimationMap[slot]; // Will also call finishedCallback
delete mAnimationMap[slot]; // Will also call finishedCallback.
mAnimationMap[slot] = nullptr;
return true;
}

View file

@ -10,7 +10,7 @@
#include <FreeImage.h>
#include <string.h>
std::vector<unsigned char> ImageIO::loadFromMemoryRGBA32(const unsigned char * data,
std::vector<unsigned char> ImageIO::loadFromMemoryRGBA32(const unsigned char* data,
const size_t size, size_t & width, size_t & height)
{
std::vector<unsigned char> rawData;

View file

@ -169,12 +169,12 @@ void ImageComponent::setImage(std::string path, bool tile)
resize();
}
void ImageComponent::setImage(const char* path, size_t length, bool tile)
void ImageComponent::setImage(const char* data, size_t length, bool tile)
{
mTexture.reset();
mTexture = TextureResource::get("", tile);
mTexture->initFromMemory(path, length);
mTexture->initFromMemory(data, length);
resize();
}

View file

@ -26,7 +26,7 @@ public:
// as tiling, creates vertices accordingly).
void setImage(std::string path, bool tile = false);
// Loads an image from memory.
void setImage(const char* image, size_t length, bool tile = false);
void setImage(const char* data, size_t length, bool tile = false);
// Use an already existing texture.
void setImage(const std::shared_ptr<TextureResource>& texture);

View file

@ -25,7 +25,7 @@ public:
static std::shared_ptr<TextureResource> get(const std::string& path, bool tile = false,
bool forceLoad = false, bool dynamic = true);
void initFromPixels(const unsigned char* dataRGBA, size_t width, size_t height);
virtual void initFromMemory(const char* file, size_t length);
virtual void initFromMemory(const char* data, size_t length);
// For scalable source images in textures we want to set the resolution to rasterize at.
void rasterizeAt(size_t width, size_t height);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 83 KiB