.. page-title: Box example: pythagoras.box pythagoras.box ============== How to label geometric shapes ----------------------------- .. figure:: pythagoras.png :align: center A figure which may be used to explain the Pythagorean theorem. To run this example you will need the following file(s): `./pythagoras.box <./pythagoras.box>`__. 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 ./pythagoras.box``. .. raw:: html
   include "g"
   
   w = Window[][
     Style[.Border[1, color.black]] // Set black border
     Color[color.red, .a=0.3] // transparent red (alpha = 0.3) 
     t = .Poly[(0, 0), (0, 30), (50, 0)]
   
     Color[color.blue, .a=0.3]
     dx = 1e-6
     sq1 = .Poly[t.Get[1], t.Get[2], t.Get[(2-dx, 1)], t.Get[(1, 1)]]
     sq2 = .Poly[t.Get[2], t.Get[3], t.Get[(3-dx, 1)], t.Get[(2, 1)]]
     sq3 = .Poly[t.Get[3], t.Get[4], t.Get[(4-dx, 1)], t.Get[(3, 1)]]
   
     Style[.Border[0]] // Unset the border
     .Text[.Font["Times-Italic", 8], color.black
           "a^2", t.Get[(1.5, 0.5)];
           "c^2 = a^2 + b^2", t.Get[(2.5, 0.5)];
           "b^2", t.Get[(3.5, 0.5)];]
     .Save["pythagoras.png", Window["rgb24", .Res[Dpi[80]]]]
   ]