help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
cpp-shape-drawer
/
include
RSK World
cpp-shape-drawer
C++ Shape Drawer - Advanced Graphics Application + Raylib + OOP Design + Shape Tools + Transformation + Export + Educational Design
include
  • Circle.hpp2 KB
  • DrawingCanvas.hpp7.3 KB
  • PatternGenerator.hpp1.6 KB
  • Polygon.hpp2.3 KB
  • RectangleShape.hpp2.7 KB
  • Shape.hpp4.2 KB
  • Star.hpp2.8 KB
  • TextShape.hpp2 KB
  • Triangle.hpp2.5 KB
TextShape.hpp
include/TextShape.hpp
Raw Download
Find: Go to:
/**
 * @file TextShape.hpp
 * @brief Text rendering as a shape.
 * 
 * Part of the C++ Shape Drawer Project.
 * 
 * @author Molla Samser (Founder of RSK World)
 * @designer Rima Khatun
 * @website https://rskworld.in
 * @email hello@rskworld.in
 * @phone +91 93305 39277
 * @location Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India, 713147
 * @year 2026
 */

#ifndef TEXT_SHAPE_HPP
#define TEXT_SHAPE_HPP

#include "Shape.hpp"

class TextShape : public Shape {
private:
    std::string text;
    float fontSize;

public:
    TextShape(Vector2 pos, std::string t, float size, Color col)
        : Shape(pos, col, true), text(t), fontSize(size) {}

    void draw() const override {
        Vector2 pos = getEffectivePosition();
        float finalSize = fontSize * getEffectiveScale();
        Color c = getEffectiveColor();
        
        DrawText(text.c_str(), (int)pos.x, (int)pos.y, (int)finalSize, c);
    }

    bool contains(Vector2 point) const override {
        float finalSize = fontSize * scale;
        Rectangle rect = { position.x, position.y, (float)MeasureText(text.c_str(), (int)finalSize), finalSize };
        return CheckCollisionPointRec(point, rect);
    }

    std::string serialize() const override {
        return "TEXT," + std::to_string(position.x) + "," + std::to_string(position.y) + "," +
               text + "," + std::to_string(fontSize) + "," +
               std::to_string(color.r) + "," + std::to_string(color.g) + "," +
               std::to_string(color.b) + "," + std::to_string(alpha) + "," + "1" + "," +
               std::to_string(rotation) + "," + std::to_string(scale) + "," + (useGradient ? "1" : "0") + "," +
               std::to_string(secondaryColor.r) + "," + std::to_string(secondaryColor.g) + "," +
               std::to_string(secondaryColor.b) + "," + std::to_string((int)animType);
    }

    std::string getType() const override { return "Text"; }
    void setText(std::string t) { text = t; }
};

#endif // TEXT_SHAPE_HPP
59 lines•2 KB
cpp

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer