0

我很想获得一些关于如何实现以下内容的想法:

我有一些资产是 1920x1080 SVG。该资产是一个精灵表。我想在使用时保持其纵横比ClipPath,以便对精灵表进行切片并仅使用我需要的部分。作为第一步,我尝试将其渲染为GridView.count只是为了确保我知道如何使用它的所有部分,并将 SVG 包含在OverflowBox.

我不确定我是否确实设法正确地剪辑了精灵表,如果是这样,为什么网格会这样渲染(下面附上截图)。

提前致谢。

GridView.count(
      crossAxisCount: 4,
      children: sprites
          .map((Sprite sprite) => SizedBox(
                child: OverflowBox(
                  child: ClipPath(
                      clipBehavior: Clip.antiAlias,
                      clipper:
                      // sprite sheet is a grid and I access the current sprite by using a matrix
                          SpriteClipper(spritePosition: sprite.position), 
                      child: const SpriteSheetSVG()),
                  maxWidth: 1920,
                  maxHeight: 1080,
                ),
                width: 480,
                height: 270,
              ))
          .toList(),

编辑:看起来像ClipPath作品,它剪辑了我想要的部分,但是剪辑的部分没有与容器对齐,而是按原样呈现......

如何网格渲染

4

0 回答 0