Filling a rectangle with an image

Code:

(*Sample data*)  
data = Table[
   ColorData["Rainbow", t] /. RGBColor -> List, {t, 0, 1, 1/100}];

(*Visualize*)    
Graphics[{Texture[data], 
      Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, 
       VertexTextureCoordinates -> {{0}, {0}, {1}, {1}}]}]

Output:

example output

Note:

In the above picture data could be any picture you wish to use as a Texture[]. Please see references below to find more useful information.

Reference:

Texture
VertexTextureCoordinates


Here is a way to make a Lena-Sierpinski triangle. I'm not very experienced with Mathematica's image processing tools, so it's probably far from optimal, but it might give you a starting point for developing better code.

lena = ExampleData[{"TestImage", "Lena"}];

tripleImage[img_Image] :=
  Module[{scaled},
    scaled = 
     ImageTransformation[img, ScalingTransform[{2, 2}], 
       Background -> Transparent, Masking -> All];
    ImageCompose[
      ImageCompose[
        scaled,
        ImageTransformation[scaled, TranslationTransform[{-.5, 0}], 
          Background -> Transparent, Masking -> All]], 
      ImageTransformation[scaled, TranslationTransform[{-.25, -.5}], 
        Background -> Transparent, Masking -> All]]]

Nest[tripleImage, lena, 4]

lena

Tags:

Image

Graphics