#include#include void drawRectangle() { TCanvas canvas("canvas", "Rectangle example", 400, 400); TBox rectangle(0.2, 0.2, 0.8, 0.8); rectangle.SetFillColor(kRed); rectangle.Draw(); }
#includeThis code creates a TCanvas object named "canvas" with size 400x400 pixels. It then creates three rectangle objects with different coordinates and fills each one with a different color. The rectangles are then drawn on the canvas. Package/library: ROOT (https://root.cern.ch/)#include void drawRectangles() { TCanvas canvas("canvas", "Rectangles example", 400, 400); TBox rectangle1(0.1, 0.1, 0.3, 0.3); rectangle1.SetFillColor(kRed); rectangle1.Draw(); TBox rectangle2(0.4, 0.1, 0.6, 0.3); rectangle2.SetFillColor(kGreen); rectangle2.Draw(); TBox rectangle3(0.7, 0.1, 0.9, 0.3); rectangle3.SetFillColor(kBlue); rectangle3.Draw(); }