|
Este artículo proviene de un motor de traducción automática. Mueva el puntero sobre las frases del artículo para ver el texto original. Más información.
|
Traducción
Original
|
Información general sobre objetos TileBrush
Este tema contiene las secciones siguientes.
-
Si el pincel es ImageBrush, este contenido es una imagen. La propiedad ImageSource especifica el contenido de ImageBrush. -
Si el pincel es DrawingBrush, este contenido es un dibujo. La propiedad Drawing especifica el contenido de DrawingBrush. -
Si el pincel es VisualBrush, este contenido es un objeto visual. La propiedad Visual especifica el contenido de VisualBrush.
-
None : el contenido del pincel no se ajusta para rellenar el mosaico. -
Fill : se ajusta la escala del contenido del pincel para ajustarla al mosaico. Dado que la escala del alto y del ancho del contenido se ajusta de manera independiente, puede que no se conserve la relación de aspecto original del contenido. Es decir, puede que el contenido del pincel quede distorsionado al rellenar completamente el mosaico de salida. -
Uniform : se ajusta la escala del contenido del pincel para que se ajuste completamente dentro del mosaico. Se conserva la relación de aspecto del contenido. -
UniformToFill : se ajusta la escala del contenido del pincel para que rellene completamente el área de salida conservando la relación de aspecto original del contenido.
<Rectangle Width="125" Height="175" Stroke="Black" StrokeThickness="1" Margin="0,0,5,0"> <Rectangle.Fill> <ImageBrush Stretch="None" ImageSource="sampleImages\testImage.gif"/> </Rectangle.Fill> </Rectangle>
' Create a rectangle. Dim myRectangle As New Rectangle() With myRectangle .Width = 125 .Height = 175 .Stroke = Brushes.Black .StrokeThickness = 1 .Margin = New Thickness(0, 5, 0, 0) End With ' Load the image. Dim theImage As New BitmapImage(New Uri("sampleImages\testImage.gif", UriKind.Relative)) Dim myImageBrush As New ImageBrush(theImage) ' Configure the brush so that it ' doesn't stretch its image to fill ' the rectangle. myImageBrush.Stretch = Stretch.None ' Use the ImageBrush to paint the rectangle's background. myRectangle.Fill = myImageBrush
// Create a rectangle. Rectangle myRectangle = new Rectangle(); myRectangle.Width = 125; myRectangle.Height = 175; myRectangle.Stroke = Brushes.Black; myRectangle.StrokeThickness = 1; myRectangle.Margin = new Thickness(0,5,0,0); // Load the image. BitmapImage theImage = new BitmapImage( new Uri("sampleImages\\testImage.gif", UriKind.Relative)); ImageBrush myImageBrush = new ImageBrush(theImage); // Configure the brush so that it // doesn't stretch its image to fill // the rectangle. myImageBrush.Stretch = Stretch.None; // Use the ImageBrush to paint the rectangle's background. myRectangle.Fill = myImageBrush;
Tamaño del mosaico base
<Rectangle Width="50" Height="100"> <Rectangle.Fill> <!-- Paints an area with 4 tiles. --> <ImageBrush ImageSource="sampleImages\cherries_larger.jpg" Viewport="0,0,0.5,0.5" ViewportUnits="RelativeToBoundingBox" TileMode="Tile" /> </Rectangle.Fill> </Rectangle>
' Create a rectangle. Dim myRectangle As New Rectangle() myRectangle.Width = 50 myRectangle.Height = 100 ' Load the image. Dim theImage As New BitmapImage(New Uri("sampleImages\cherries_larger.jpg", UriKind.Relative)) Dim myImageBrush As New ImageBrush(theImage) ' Create tiles that are 1/4 the size of ' the output area. myImageBrush.Viewport = New Rect(0, 0, 0.25, 0.25) myImageBrush.ViewportUnits = BrushMappingMode.RelativeToBoundingBox ' Set the tile mode to Tile. myImageBrush.TileMode = TileMode.Tile ' Use the ImageBrush to paint the rectangle's background. myRectangle.Fill = myImageBrush
// Create a rectangle. Rectangle myRectangle = new Rectangle(); myRectangle.Width = 50; myRectangle.Height = 100; // Load the image. BitmapImage theImage = new BitmapImage( new Uri("sampleImages\\cherries_larger.jpg", UriKind.Relative)); ImageBrush myImageBrush = new ImageBrush(theImage); // Create tiles that are 1/4 the size of // the output area. myImageBrush.Viewport = new Rect(0,0,0.25,0.25); myImageBrush.ViewportUnits = BrushMappingMode.RelativeToBoundingBox; // Set the tile mode to Tile. myImageBrush.TileMode = TileMode.Tile; // Use the ImageBrush to paint the rectangle's background. myRectangle.Fill = myImageBrush;
<Rectangle Width="50" Height="100"> <Rectangle.Fill> <!-- Paints an area with 25 x 25 tiles. --> <ImageBrush ImageSource="sampleImages\cherries_larger.jpg" Viewport="0,0,25,25" ViewportUnits="Absolute" TileMode="Tile" /> </Rectangle.Fill> </Rectangle>
' Create a rectangle. Dim myRectangle As New Rectangle() myRectangle.Width = 50 myRectangle.Height = 100 ' Load the image. Dim theImage As New BitmapImage(New Uri("sampleImages\cherries_larger.jpg", UriKind.Relative)) Dim myImageBrush As New ImageBrush(theImage) ' Create tiles that are 25 x 25, regardless of the size ' of the output area. myImageBrush.Viewport = New Rect(0, 0, 25, 25) myImageBrush.ViewportUnits = BrushMappingMode.Absolute ' Set the tile mode to Tile. myImageBrush.TileMode = TileMode.Tile ' Use the ImageBrush to paint the rectangle's background. myRectangle.Fill = myImageBrush
// Create a rectangle. Rectangle myRectangle = new Rectangle(); myRectangle.Width = 50; myRectangle.Height = 100; // Load the image. BitmapImage theImage = new BitmapImage( new Uri("sampleImages\\cherries_larger.jpg", UriKind.Relative)); ImageBrush myImageBrush = new ImageBrush(theImage); // Create tiles that are 25 x 25, regardless of the size // of the output area. myImageBrush.Viewport = new Rect(0, 0, 25, 25); myImageBrush.ViewportUnits = BrushMappingMode.Absolute; // Set the tile mode to Tile. myImageBrush.TileMode = TileMode.Tile; // Use the ImageBrush to paint the rectangle's background. myRectangle.Fill = myImageBrush;
Comportamiento de mosaico
-
None : sólo se dibuja el mosaico base. -
Tile : se dibuja el mosaico base y el área restante se rellena repitiendo el mosaico base de tal modo que el borde derecho de un mosaico sea adyacente al borde izquierdo del siguiente, y lo mismo en sentido vertical. -
FlipX : igual que Tile, pero volteando en sentido horizontal columnas alternas de mosaicos. -
FlipY : igual que Tile, pero volteando en sentido vertical filas alternas de mosaicos.
<Rectangle Width="100" Height="100" > <Rectangle.Fill> <ImageBrush ImageSource="sampleImages\triangle.jpg" Viewport="0,0,0.25,0.25" TileMode="FlipXY" /> </Rectangle.Fill> </Rectangle>
' Create a rectangle. Dim myRectangle As New Rectangle() myRectangle.Width = 100 myRectangle.Height = 100 ' Load the image. Dim theImage As New BitmapImage(New Uri("sampleImages\triangle.jpg", UriKind.Relative)) Dim myImageBrush As New ImageBrush(theImage) ' Create tiles that are 1/4 the size of ' the output area. myImageBrush.Viewport = New Rect(0, 0, 0.25, 0.25) ' Set the tile mode to FlipXY. myImageBrush.TileMode = TileMode.FlipXY ' Use the ImageBrush to paint the rectangle's background. myRectangle.Fill = myImageBrush
// Create a rectangle. Rectangle myRectangle = new Rectangle(); myRectangle.Width = 100; myRectangle.Height = 100; // Load the image. BitmapImage theImage = new BitmapImage( new Uri("sampleImages\\triangle.jpg", UriKind.Relative)); ImageBrush myImageBrush = new ImageBrush(theImage); // Create tiles that are 1/4 the size of // the output area. myImageBrush.Viewport = new Rect(0,0,0.25,0.25); // Set the tile mode to FlipXY. myImageBrush.TileMode = TileMode.FlipXY; // Use the ImageBrush to paint the rectangle's background. myRectangle.Fill = myImageBrush;