GithubHelp home page GithubHelp logo

astrodynamic / geometry Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 206 KB

Geometry: A program to draw geometric primitives using SFML. Create lines, circles, triangles, rectangles, and squares easily. MIT licensed.

License: MIT License

CMake 15.75% Makefile 2.33% C++ 81.92%
affine-transformation cmake cmakelists cpp cpp17 drawing-app geometry graphics make makefile primitives sfml sfml-library

geometry's Introduction

Geometry

This program allows you to draw geometric primitives using SFML.

promo

Installation

To build and install the project, follow these steps:

  1. Clone the repository:

    git clone https://github.com/your/repository.git
    
  2. Change to the project directory:

    cd Geometry
    
  3. Build the project using CMake:

    cmake -S . -B ./build
    cmake --build ./build
    
  4. Run the executable:

    ./build/Geometry
    

Dependencies

The project uses the SFML library (version 2.5.1) for graphics, window management, and system functionality. The library source code will be downloaded automatically during the build process.

Usage

The program allows you to draw different types of primitives, such as lines, circles, triangles, rectangles, and squares. The following code snippet demonstrates how to use the program:

#include <SFML/Graphics.hpp>
#include <memory>

#include "line.h"
#include "circle.h"
#include "triangle.h"
#include "rectangle.h"
#include "square.h"

int main() {
  sf::RenderWindow window(sf::VideoMode(800, 600), "Geometry");
  std::vector<std::unique_ptr<Primitive>> primitives;
  primitives.emplace_back(std::make_unique<Line>(100, 100, 200, 200));
  primitives.emplace_back(std::make_unique<Circle>(400, 300, 50));
  primitives.emplace_back(std::make_unique<Triangle>(300, 100, 400, 200, 200, 200));
  primitives.emplace_back(std::make_unique<Rectangle>(500, 400, 100, 50));
  while (window.isOpen()) {
    sf::Event event;
    while (window.pollEvent(event)) {
      if (event.type == sf::Event::Closed) window.close();
    }
    window.clear();
    for (auto& primitive : primitives) {
      primitive->draw(window);
      primitive->rotate(0.2f);
    }
    window.display();
    sf::sleep(sf::milliseconds(50));
  }
  return 0;
}

License

This project is licensed under the MIT License.

geometry's People

Contributors

astrodynamic avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.