コード例 #1
0
 /// <summary>
 /// Create a cropped bounding box.
 /// </summary>
 /// <returns>The crop info.</returns>
 /// <param name="boundingBoxType">The type of the bounding box to be cropped.</param>
 /// <param name="crop">Crop.</param>
 /// <param name="adjustedScale">Adjusted scale.</param>
 public AGSCropInfo Crop(BoundingBoxType boundingBoxType, ICropSelfComponent crop, PointF adjustedScale)
 {
     if (crop == null)
     {
         return(new AGSCropInfo(this, null, CropFrom.None));
     }
     return(crop.Crop(ref this, boundingBoxType, adjustedScale));
 }
コード例 #2
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IDrawableInfoComponent>(c => _drawableInfo = c, _ => _drawableInfo = null);
     Entity.Bind <IImageComponent>(c => _obj   = c, _ => _obj = null);
     Entity.Bind <IScaleComponent>(c => _scale = c, _ => _scale = null);
     Entity.Bind <IPixelPerfectComponent>(c => _pixelPerfect = c, _ => _pixelPerfect = null);
     Entity.Bind <IBoundingBoxComponent>(c => _boundingBox   = c, _ => _boundingBox = null);
     Entity.Bind <ICropSelfComponent>(c => _crop             = c, _ => _crop = null);
 }
コード例 #3
0
 public override void Init()
 {
     base.Init();
     Entity.Bind <IImageComponent>(c => _image = c, _ => _image = null);
     Entity.Bind <IScaleComponent>(c => { _scale = c; c.PropertyChanged += onScalePropertyChanged; }, c => { _scale = null; c.PropertyChanged -= onScalePropertyChanged; });
     Entity.Bind <IDrawableInfoComponent>(c => { _drawable = c; c.PropertyChanged += onDrawablePropertyChanged; }, c => { _drawable = null; c.PropertyChanged -= onDrawablePropertyChanged; });
     Entity.Bind <ICropSelfComponent>(c => _cropSelf = c, _ => _cropSelf = null);
     Entity.Bind <IModelMatrixComponent>(c => { _matrix = c; c.OnMatrixChanged.Subscribe(onMatrixChanged); }, c => { _matrix = null; c.OnMatrixChanged.Unsubscribe(onMatrixChanged); });
     Entity.Bind <IVisibleComponent>(c => _visible = c, _ => _visible = null);
     _events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
     _pipeline.Subscribe(Entity.ID, this, -10);
 }
コード例 #4
0
        /// <summary>
        /// Create a cropped bounding box.
        /// </summary>
        /// <returns>The crop info.</returns>
        /// <param name="crop">Crop.</param>
        /// <param name="adjustedScale">Adjusted scale.</param>
        public AGSCropInfo Crop(BoundingBoxType boundingBoxType, ICropSelfComponent crop, PointF adjustedScale)
        {
            if (crop == null)
            {
                return(new AGSCropInfo(this, null));
            }
            float scaleX                   = adjustedScale.X;
            float scaleY                   = adjustedScale.Y;
            float spriteWidth              = Width / scaleX;
            float spriteHeight             = Height / scaleY;
            var   args                     = new BeforeCropEventArgs(this, boundingBoxType);
            FourCorners <Vector2> cropArea = crop.GetCropArea(args, spriteWidth, spriteHeight, out float width, out float height);

            if (!crop.CropEnabled)
            {
                return(new AGSCropInfo(this, null));
            }
            if (width <= 0f || height <= 0f)
            {
                return(default);
コード例 #5
0
        public override void Init()
        {
            base.Init();

            Entity.Bind <IModelMatrixComponent>(c => { c.OnMatrixChanged.Subscribe(_onHitTextBoxShouldChangeCallback); _matrix = c; },
                                                c => { c.OnMatrixChanged.Unsubscribe(_onHitTextBoxShouldChangeCallback); _matrix = null; });
            Entity.Bind <ICropSelfComponent>(c => { c.PropertyChanged += _onCropShouldChangeCallback; _crop = c; },
                                             c => { c.PropertyChanged -= _onCropShouldChangeCallback; _crop = null; });
            Entity.Bind <IImageComponent>(c => { _image = c; c.PropertyChanged += _onImageChangedCallback; },
                                          c => { _image = null; c.PropertyChanged -= _onImageChangedCallback; });
            Entity.Bind <IScaleComponent>(c => _scale = c, _ => _scale = null);
            Entity.Bind <IDrawableInfoComponent>(c => { c.PropertyChanged += _onDrawableChangedCallback; _drawable = c; },
                                                 c => { c.PropertyChanged -= _onDrawableChangedCallback; _drawable = null; });
            Entity.Bind <ITextureOffsetComponent>(c => { c.PropertyChanged += _onTextureOffsetChangedCallback; _textureOffset = c; onAllViewportsShouldChange(); },
                                                  c => { c.PropertyChanged -= _onTextureOffsetChangedCallback; _textureOffset = null; onAllViewportsShouldChange(); });
        }
コード例 #6
0
 /// <summary>
 /// Tweens the height of the crop area.
 /// <example>
 /// <code language="lang-csharp">
 /// var tween = crop.TweenHeight(15f, 2f, Ease.CubeIn);
 /// await tween.Task;
 /// </code>
 /// </example>
 /// <seealso cref="Tween"/>
 /// <seealso cref="ICropSelfComponent"/>
 /// </summary>
 /// <returns>The tween.</returns>
 /// <param name="crop">Crop component.</param>
 /// <param name="toHeight">To height.</param>
 /// <param name="timeInSeconds">Time in seconds.</param>
 /// <param name="easing">Easing function.</param>
 public static Tween TweenHeight(this ICropSelfComponent crop, float toHeight, float timeInSeconds, Func <float, float> easing = null)
 {
     return(Tween.Run(crop.CropArea.Height, toHeight, height => crop.CropArea = new RectangleF(crop.CropArea.X, crop.CropArea.Y, crop.CropArea.Width, height), timeInSeconds, easing));
 }
コード例 #7
0
        public override void Init(IEntity entity)
        {
            _entity = entity;
            base.Init(entity);

            entity.Bind <IModelMatrixComponent>(c => { c.OnMatrixChanged.Subscribe(onHitTextBoxShouldChange); _matrix = c; },
                                                c => { c.OnMatrixChanged.Unsubscribe(onHitTextBoxShouldChange); _matrix = null; });
            entity.Bind <ICropSelfComponent>(c => { c.PropertyChanged += onCropShouldChange; _crop = c; },
                                             c => { c.PropertyChanged -= onCropShouldChange; _crop = null; });
            entity.Bind <IImageComponent>(c => c.PropertyChanged += onImageChanged,
                                          c => c.PropertyChanged -= onImageChanged);
            entity.Bind <IAnimationComponent>(c => _animation     = c, _animation => _animation = null);
            entity.Bind <IDrawableInfoComponent>(c => { c.PropertyChanged += onDrawableChanged; _drawable = c; },
                                                 c => { c.PropertyChanged -= onDrawableChanged; _drawable = null; });
            entity.Bind <ITextureOffsetComponent>(c => { c.PropertyChanged += onTextureOffsetChanged; _textureOffset = c; onAllViewportsShouldChange(); },
                                                  c => { c.PropertyChanged -= onTextureOffsetChanged; _textureOffset = null; onAllViewportsShouldChange(); });
        }