Skip to content

svgSetSize / svgGetSize bug with float numbers #3306

@FileEX

Description

@FileEX

Describe the bug

If you change the size of the SVG to float, the svgSetSize function returns false and the SVG image becomes invisible. In addition, the svgGetSize function returns the new size (even though svgSetSize returned false)

local svg = svgCreate(50.48777777777, 25, 'test.svg');
print(svg);

local w,h = svgGetSize(svg);
print(w,h); -- 50, 25

local b = svgSetSize(svg, 87.6666666, 25);
print(b); -- false

local w,h = svgGetSize(svg);
print(w,h); -- 87,25

Example code

local svg = svgCreate(50.48777777777, 25, 'test.svg');
print(svg);

local w,h = svgGetSize(svg);
print(w,h); -- 50, 25

addCommandHandler('svgsize', function()
	local b = svgSetSize(svg, 87.6666666, 25);
	print(b); -- false

	local w,h = svgGetSize(svg);
	print(w,h); -- 87,25
end);

addEventHandler('onClientRender', root, function()
	local w,h = svgGetSize(svg);
	dxDrawImage(300, 300, w,h,svg);
end);

Steps to reproduce

  1. Create an SVG with float size (the size will be rounded to the floor and the SVG will render correctly)
  2. Set the SVG size to another float number (returns false)
  3. svgGetSize returns the new size (rounded to the floor) sets by svgSetSize (which returned false)
  4. SVG after "resizing" is not rendered correctly, it is invisible

Version

Multi Theft Auto v1.6-release-22377

Additional context

No response

Relevant log output

No response

Security Policy

  • I have read and understood the Security Policy and this issue is not security related.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions