コード例 #1
0
ファイル: Sprite.cs プロジェクト: pwitvoet/wadmaker
 private Sprite(
     SpriteType type,
     SpriteTextureFormat textureFormat,
     float boundingRadius,
     uint maximumWidth,
     uint maximumHeight,
     float beamLength,
     SpriteSynchronization synchronization,
     Rgba32[] palette)
 {
     Type            = type;
     TextureFormat   = textureFormat;
     BoundingRadius  = boundingRadius;
     MaximumWidth    = maximumWidth;
     MaximumHeight   = maximumHeight;
     BeamLength      = beamLength;
     Synchronization = synchronization;
     Palette         = palette;
 }
コード例 #2
0
ファイル: Sprite.cs プロジェクト: pwitvoet/wadmaker
        public static Sprite CreateSprite(SpriteType type, SpriteTextureFormat textureFormat, int maxWidth, int maxHeight, Rgba32[] palette)
        {
            if (maxWidth < 1 || maxHeight < 1)
            {
                throw new ArgumentException("Width and height must greater than zero.");
            }
            if (palette?.Count() > 256)
            {
                throw new ArgumentException("Palette must not contain more than 256 colors.", nameof(palette));
            }

            return(new Sprite(
                       type,
                       textureFormat,
                       (float)Math.Sqrt(maxWidth * maxWidth + maxHeight * maxHeight) / 2,
                       (uint)maxWidth,
                       (uint)maxHeight,
                       0,
                       SpriteSynchronization.Random,
                       palette));
        }