void EntityShadows::doShadowSprite(float intensity, VertexBuffer& vertexBuffer) { if (intensity*255.0f < 1.0f) return; auto& renderer = Renderer::get(); renderer.setColour(Colour4f(intensity, intensity, intensity, 1.0f)); renderer.render(vertexBuffer, PrimitiveType::TriangleFan, 0, 4); }
void InternalWindow::drawContainer(DrawingContext& drawingContext) { std::shared_ptr<const Material> material; //Draw background first material = std::make_shared<const Material>(_background.get(), Colour4f(Colour3f::white(), 0.9f), true); _gameEngine->getUIManager()->drawImage(Point2f(getDerivedPosition().x(), getDerivedPosition().y()), Vector2f(getWidth(), getHeight()), material); //Draw window title _titleBar->draw(drawingContext); //Draw the close button _closeButton->draw(drawingContext); }
void InternalWindow::TitleBar::draw(DrawingContext& drawingContext) { std::shared_ptr<const Material> material; Point2f position; // Background of title bar position = getDerivedPosition(); position -= Vector2f(BORDER_PIXELS * 2, 0.0f); material = std::make_shared<const Material>(_titleBarTexture.get(), Ego::Math::Colour4f::white(), true); _gameEngine->getUIManager()->drawImage(position, Vector2f(getWidth() + BORDER_PIXELS * 4, getHeight()), material); // Title string (centered on title bar) position = getDerivedPosition(); position += Vector2f(getWidth() / 2.0f - _textWidth / 2.0f, 12); _font->drawText(_title, position.x(), position.y(), Colour4f(0.28f, 0.16f, 0.07f, 1.0f)); //Skull texture (centered above top border of title bar) const int skullWidth = _titleSkullTexture.get_ptr()->getWidth() / 2; const int skullHeight = _titleSkullTexture.get_ptr()->getHeight() / 2; material = std::make_shared<const Material>(_titleSkullTexture.get(), Ego::Math::Colour4f::white(), true); position = getDerivedPosition(); position += Vector2f(getWidth() / 2.0f - skullWidth / 2.0f, -skullHeight / 2.0f); _gameEngine->getUIManager()->drawImage(position, Vector2f(skullWidth, skullHeight), material); }
/** * @brief * Convert a colour value in RGBA colour space represented by * four Byte values * into the internal representation. * @param r * the Byte value of the red component * @param g * the Byte value of the green component * @param b * the Byte value of the blue component * @param a * the Byte value of the alpha component * @return * the colour */ static Colour4f parse(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { return Colour4f(((float)r) / 255.0f, ((float)g) / 255.0f, ((float)b) / 255.0f, ((float)a) / 255.0f); }
/** * @brief * Make a brighter version of this colour * @param brightness * the scalar for brightness increase (0 = normal, 1 = twice as bright) * @return * the brighter colour * @remark * Given a colour \f$(r,g,b,a)\f$ in real-valued, normalized RGBA space, * then corresponding inverted colour is \f$(brighness*r,brighness*1,brighness*1,a)\f$. This conversion * is not reverrsible. */ Colour4f brighter(float brightness) const { if(brightness <= 0.0f) return *this; brightness += 1.0f; return Colour4f(std::min(1.0f, _r*brightness), std::min(1.0f, _g*brightness), std::min(1.0f, _b*brightness), _a); }
/** * @brief * Invert this colour value. * @return * the inverted colour * @remark * Given a colour \f$(r,g,b,a)\f$ in real-valued, normalized RGBA space, * then corresponding inverted colour is \f$(1-r,1-g,1-b,a)\f$. Inverting * a colour twice yields the same colour (modula floating-point precision). * @remark * The corresponding inverted colour is also known as the complementary colour. */ Colour4f invert() const { return Colour4f(1.0f - _r, 1.0f - _g, 1.0f - _b, _a); }