位图绘制 (BitmapPaint)

父级 绘制 (Paint)
display.*
版本 版本 2024.3703
关键词 位图绘制
另请参阅 object.fill(对象填充)
object.stroke(对象描边)
效果指南

概述

位图绘制包含单个纹理。

如果需要,位图填充可以重复(平铺)显示对象的整个跨度。有关更多信息,请参阅 display.setDefault() 的**纹理键 (Texture Keys)** 部分中的 textureWrapXtextureWrapY 属性。

语法

local paint = {
    type = "image",
    filename = ,
    baseDir = 
}
类型 (必填)

字符串 (String). 字符串值 "image"

文件名 (必填)

字符串 (String). 图像文件的文件名。

基准目录 (可选)

常量 (Constant). 指定文件名所在的基本目录。选项包括 system.ResourceDirectory(资源目录)、system.DocumentsDirectory(文档目录)、system.TemporaryDirectory(临时目录)和 system.CachesDirectory(缓存目录)。默认为 system.ResourceDirectory(资源目录)。

属性

(继承自 绘制 (Paint) 的属性)

fill.rotation(填充旋转)

fill.scaleX(填充横向缩放)

fill.scaleY(填充纵向缩放)

fill.x(填充 x 坐标)

fill.y(填充 y 坐标)

示例

-- Create a vector rectangle
local rect = display.newRect( 200, 200, 300, 300 )

-- Set the fill (paint) to use the bitmap image
local paint = {
    type = "image",
    filename = "texture1.png"
}

-- Fill the rectangle
rect.fill = paint