How to label geometric shapes


A figure which may be used to explain the Pythagorean theorem. To run this example you will need the following file(s): ./ If the example requires more than one file, then you should put them into the same directory. You can then launch Box with box -l g ./

include "g"

w = Window[][
  // Styles for drawing the main triangle (s1) and the squares (s2)
  s1 = Style[Color[, .a=0.3], Border[0.5,]]
  s2 = Style[Color[, .a=0.3], Border[0.5,]]

  t = Poly[s1, (0, 0), (0, 30), (50, 0)] // Main triangle

  // The three squares
  dx = 1e-6
  sq1 = Poly[s2, t.Get[0], t.Get[1], t.Get[(1-dx, 1)], t.Get[(0, 1)]]
  sq2 = Poly[s2, t.Get[1], t.Get[2], t.Get[(2-dx, 1)], t.Get[(1, 1)]]
  sq3 = Poly[s2, t.Get[2], t.Get[0], t.Get[(0-dx, 1)], t.Get[(2, 1)]]

  // Send the shapes to the window for drawing
  t, sq1, sq2, sq3

  Texts[Font["Times-Italic", 8,]
        "a^2", t.Get[(0.5, 0.5)];
        "c^2 = a^2 + b^2", t.Get[(1.5, 0.5)];
        "b^2", t.Get[(2.5, 0.5)];]

w.Save["pythagoras.png", Window["rgb24", .Res[Dpi[80]]]]

Table Of Contents

This Page

Get The figure description language: Box at Fast, secure and Free Open Source software downloads