add scale to draw2d image
This commit is contained in:
@@ -137,7 +137,7 @@ draw.slice9 = function slice9(image, rect = [0,0], slice = 0, info = slice9_info
|
||||
})
|
||||
}
|
||||
|
||||
draw.image = function image(image, rect, rotation, anchor, shear, info = {mode:"nearest"}, material = {color:{r:1,g:1,b:1,a:1}}) {
|
||||
draw.image = function image(image, rect, scale = {x:1,y:1}, anchor, shear, info = {mode:"nearest"}, material = {color:{r:1,g:1,b:1,a:1}}) {
|
||||
if (!rect) throw Error('Need rectangle to render image.')
|
||||
if (!image) throw Error('Need an image to render.')
|
||||
|
||||
@@ -146,7 +146,7 @@ draw.image = function image(image, rect, rotation, anchor, shear, info = {mode:"
|
||||
add_command("draw_image", {
|
||||
image,
|
||||
rect,
|
||||
rotation,
|
||||
scale,
|
||||
anchor,
|
||||
shear,
|
||||
info,
|
||||
|
||||
@@ -193,8 +193,11 @@ function translate_draw_commands(commands) {
|
||||
var gpu = img.gpu
|
||||
if (!gpu) break
|
||||
|
||||
if (!cmd.scale) cmd.scale = {x:1,y:1}
|
||||
cmd.rect.width ??= img.width
|
||||
cmd.rect.height ??= img.height
|
||||
cmd.rect.width = cmd.rect.width * cmd.scale.x
|
||||
cmd.rect.height = cmd.rect.height * cmd.scale.y
|
||||
cmd.rect = worldToScreenRect(cmd.rect, camera)
|
||||
|
||||
renderer_commands.push({
|
||||
|
||||
Reference in New Issue
Block a user