Skip to content

achnitreda/drawing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Geometrical Shapes Drawer

This Rust project generates an image composed of various geometrical shapes β€” such as lines, circles, rectangles, triangles, and points β€” and saves the result as a PNG file using the raster image processing library.

πŸ–ΌοΈ Example Output

Here’s the generated image showing various shapes:

Shapes

🧠 Project Concepts

This project teaches and reinforces the following key Rust programming concepts:

  • Modules and File Organization
  • Traits and Trait Objects
  • Structs with Associated Functions
  • Randomized Geometry Generation
  • Algorithm Implementation (DDA ,Midpoint Circle Algorithm)

πŸ“ Project Structure

β”œβ”€β”€ src
β”‚ β”œβ”€β”€ main.rs
β”‚ └── geometrical_shapes.rs
β”œβ”€β”€ Cargo.toml
└── image.png (generated)

🧩 Shapes Implemented

Each shape is defined as a struct with associated constructors:

  • Point β€” created from (x, y)
  • Line β€” from two Point references
  • Rectangle β€” from two diagonal Point references
  • Triangle β€” from three Point references
  • Circle β€” from a Point and a radius

All shapes implement the Drawable trait, allowing them to be drawn onto a raster::Image.

🎯 Usage

  • Clone the repository

  • Add dependencies to Cargo.toml:

[dependencies]
raster = "0.2.0"
rand = "0.9.1"
  • Run the program
cargo run

About

generates an image composed of various geometrical shapes

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages