| 87 | } |
| 88 | |
| 89 | Drawable Drawable::makeImage(AssetPath image, float pixelSize, bool centered, Vec2F const& position, Color const& color) { |
| 90 | Drawable drawable; |
| 91 | Mat3F transformation = Mat3F::identity(); |
| 92 | if (centered) { |
| 93 | auto imageMetadata = Root::singleton().imageMetadataDatabase(); |
| 94 | Vec2F imageSize = Vec2F(imageMetadata->imageSize(image)); |
| 95 | transformation.translate(-imageSize / 2); |
| 96 | } |
| 97 | |
| 98 | if (pixelSize != 1.0f) |
| 99 | transformation.scale(pixelSize); |
| 100 | |
| 101 | drawable.part = ImagePart{std::move(image), std::move(transformation)}; |
| 102 | drawable.position = position; |
| 103 | drawable.color = color; |
| 104 | |
| 105 | return drawable; |
| 106 | } |
| 107 | |
| 108 | Drawable::Drawable() |
| 109 | : color(Color::White), fullbright(false) {} |