CrImage::Util::Tiling
Image tiling and pattern generation.
Provides tools for creating tiled patterns and seamless textures. Useful for:
- Creating backgrounds and wallpapers
- Generating repeating patterns
- Making seamless textures for 3D graphics
- Web design and UI backgrounds
Class methods
Creates a seamless tileable pattern from an image.
Blends opposite edges together to eliminate visible seams when the image is tiled. The blend_width controls how much of the edge is blended (larger = smoother transition but more distortion).
Parameters:
src: The source imageblend_width: Width of edge blending in pixels (0 = auto, 1/8 of smallest dimension)
Returns: A new RGBA image that tiles seamlessly
Raises: ArgumentError if blend_width is too large
Example:
img = CrImage.read("texture.png")
seamless = img.make_seamless
tiled = seamless.tile(4, 4) # No visible seams
Tiles an image in a grid pattern.
Creates a larger image by repeating the source image in a rectangular grid. Each tile is an exact copy of the source image.
Parameters:
src: The source image to tilecols: Number of columns (must be positive)rows: Number of rows (must be positive)
Returns: A new RGBA image with tiled pattern
Raises: ArgumentError if cols or rows are not positive
Example:
img = CrImage.read("tile.png")
tiled = img.tile(3, 3) # 3x3 grid
Tiles an image to fill specific dimensions.
Repeats the image as many times as needed to cover the target area, cropping the final row/column if they extend beyond the target size. Useful for creating backgrounds and wallpapers.
Parameters:
src: The source image to tiletarget_width: Desired width in pixels (must be positive)target_height: Desired height in pixels (must be positive)
Returns: A new RGBA image with tiled pattern
Raises: ArgumentError if dimensions are not positive
Example:
img = CrImage.read("pattern.png")
background = img.tile_to_size(1920, 1080)