1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PixiJSでSVGのサイズ変更が上手く出来なかった

Posted at

はじめに

PixiJSでSVGファイルのscaleを変更しようとすると、見切れてしまった。

コード

const svgr = new PIXI.SVGResource(svg, { scale: 2 })
const svg_tex = PIXI.Texture.from(svgr)
const tex = new PIXI.Texture(new PIXI.BaseTexture(svg_tex))
const spr = new PIXI.Sprite(tex)
stage.addChild(spr)

結果

scale: 1
image.png
scale:2
image.png
わぁ!切れてる!

理由

SVGファイルにwidthとheightが設定されていなかったから。

感想

issuesにもあった
https://github.com/pixijs/pixijs/issues/7686

下の記事にもwidthとheightをつけろって書いてある
https://qiita.com/manabuyasuda/items/01a76204f97cd73ffc4e

でもなんで見切れるぐらい大きくなるんだ???

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?