This site is supported by donations to The OEIS Foundation.

Template:Canvas/Test

From OeisWiki
Jump to: navigation, search

This is a testing template for the {{canvas}} template.

Code Result
{{canvas|width = 600|height = 400|float = right
|<!--
-->{{ellipse|center = 500, 350|semi-axes = 100, 50
|units = px|stroke = 3px solid orange}}<!--

  Red triangle

-->{{line|points =    0,  0; 100, 50 |color = red}}<!--
-->{{line|points =  100, 50; 200,  0 |color = red}}<!--
-->{{line|points =  200,  0;   0,  0 |color = red}}<!--

  Green triangle (translated 200, 200)

-->{{translate|<!--
  -->{{line|points =   0,  0; 100, 50 |color = green}}<!--
  -->{{line|points = 100, 50; 200,  0 |color = green}}<!--
  -->{{line|points = 200,  0;   0,  0 |color = green}}<!--
-->| 200, 200<!-- 
-->}}<!--

  Blue triangle (offset x: 200)

-->{{line|points =    0 + 200,  0; 100 + 200, 50 |color = blue}}<!--
-->{{line|points =  100 + 200, 50; 200 + 200,  0 |color = blue}}<!--
-->{{line|points =  200 + 200,  0;   0 + 200,  0 |color = blue}}<!--
--><!--

  Purple triangle (offset y: 200)

-->{{line|points =    0,  0 + 200; 100, 50 + 200 |color = purple}}<!--
-->{{line|points =  100, 50 + 200; 200,  0 + 200 |color = purple}}<!--
-->{{line|points =  200,  0 + 200;   0,  0 + 200 |color = purple}}<!--

  Black 200 x 200 square (translated 400, 200)

-->{{translate|<!--
  -->{{line|points =   0,   0;   0, 200 |width = 4|color = black}}<!--
  -->{{line|points =   0, 200; 200, 200 |width = 4|color = black}}<!--
  -->{{line|points = 200, 200; 200,   0 |width = 4|color = black}}<!--
  -->{{line|points = 200,   0;   0,   0 |width = 4|color = black}}<!--
-->| 400, 200<!--
-->}}<!--

  Yellow 100 x 100 square (translated 450, 250)

  The medium bordered translated yellow square should be in the center of
  the large black square.

-->{{translate|<!--
  -->{{line|points =   0,   0;   0, 100 |width = 3|color = yellow}}<!--
  -->{{line|points =   0, 100; 100, 100 |width = 3|color = yellow}}<!--
  -->{{line|points = 100, 100; 100,   0 |width = 3|color = yellow}}<!--
  -->{{line|points = 100,   0;   0,   0 |width = 3|color = yellow}}<!--
-->| 450, 250<!--
-->}}<!--

  Orange 100 x 100 square (rotated 45 deg; then translated 450, 250)

  The thick bordered rotated orange square should be in the center of
  the large black square.

-->{{translate|<!--
  -->{{rotate|<!--
    -->{{line|points =   0,   0;   0, 100 |width = 5|color = orange}}<!--
    -->{{line|points =   0, 100; 100, 100 |width = 5|color = orange}}<!--
    -->{{line|points = 100, 100; 100,   0 |width = 5|color = orange}}<!--
    -->{{line|points = 100,   0;   0,   0 |width = 5|color = orange}}<!--
  -->|45|origin offset = 50% 50%}}<!--
-->| 450, 250 }}<!--

-->}}

Penrose tribar

Since the {{polygon}} template doesn't currently support the fill (only the stroke), while the {{rectangle}} template does support the fill, each of the 3 shaded areas is made up of 2 skewed rectangles, the second of which is properly rotated and translated to get the proper shape for the shaded area.

Code Result
<!--
-->{{canvas|width = 600|height = 400|float = right
   | title = Penrose tribar
   |<!--

     Black shaded area (START)

  -->{{translate|<!--
    -->{{rotate|<!--

       -->{{skewX|<!--
         -->{{rect
            | width = 300 | height = 40 | stroke width = 0 | units = px 
            | stroke = black | fill = black
            }}<!--
       -->| angle = pi/6
          }}<!--

       -->{{translate|<!--
         -->{{rotate|<!--
           -->{{skewX|<!--
             -->{{rect
                | width = 300 - 92 | height = 40 | stroke width = 0 | units = px 
                | stroke = black | fill = black
                }}<!--
           -->| angle = pi/6
              }}<!--
         -->| angle = pi/3
            }}<!--
       -->| -150 + 75, 150 - 60
          }}<!--

    -->| angle = 0
       }}<!--
  -->| 300, 75 
     }}<!--

     Black shaded area (END)

  --><!--

     Dark grey shaded area (START)

  -->{{translate|<!--
    -->{{rotate|<!--

       -->{{skewX|<!--
         -->{{rect
            | width = 300 | height = 40 | stroke width = 0 | units = px 
            | stroke = grey | fill = grey
            }}<!--
       -->| angle = pi/6
          }}<!--

       -->{{translate|<!--
         -->{{rotate|<!--
           -->{{skewX|<!--
             -->{{rect
                | width = 300 - 92 | height = 40 | stroke width = 0 | units = px 
                | stroke = grey | fill = grey
                }}<!--
           -->| angle = pi/6
              }}<!--
         -->| angle = pi/3
            }}<!--
       -->| -150 + 75, 150 - 60
          }}<!--

    -->| angle = -2*pi/3
       }}<!--
  -->| 200 + 2, 175 + 30 
     }}<!--

     Dark grey shaded area (END)

  --><!--

     Light grey shaded area (START)

  -->{{translate|<!--
    -->{{rotate|<!--

       -->{{skewX|<!--
         -->{{rect
            | width = 300 | height = 40 | stroke width = 0 | units = px 
            | stroke = lightgrey | fill = lightgrey
            }}<!--
       -->| angle = pi/6
          }}<!--

       -->{{translate|<!--
         -->{{rotate|<!--
           -->{{skewX|<!--
             -->{{rect
                | width = 300 - 92 | height = 40 | stroke width = 0 | units = px 
                | stroke = lightgrey | fill = lightgrey
                }}<!--
           -->| angle = pi/6
              }}<!--
         -->| angle = pi/3
            }}<!--
       -->| -150 + 75, 150 - 60
          }}<!--

    -->| angle = 2*pi/3
       }}<!--
  -->| 300 + 60 + 3, 175 + 50
     }}<!--

     Light grey shaded area (END)

  --><!--

-->}}


Penrose tribar