示例#1
0
        public ImageSprite(Texture2D texture, ImageSourceId sourceId)
        {
            image = new Image();
            var source = texture.GetSpecialSource(sourceId.ForTextureLookup);
            image.Source = source;
            image.Width = source.PixelWidth;
            image.Height = source.PixelHeight;

            base.Create(image, sourceId.Cache, true);

            if(sourceId.DynamicColor)
            {
                // Note: This tint effect does not apply additive blending
                //       (because theoretically the non-additive version should be faster).
                //       Additive-ness is already applied at the image source.
                //       (Ditto for Opaque blending)
                canvas.Effect = tintEffect = TintEffect.Create(TintEffectMode.Normal);
            }

            if(sourceId.DynamicRectangle)
            {
                image.Clip = clipGeometry = new SWM.RectangleGeometry();
            }
        }