Exemple #1
0
 public Linear(VectorInt aCurrent, VectorInt aTarget, VectorDouble aStep, bool useBounce)
 {
     _Start = new VectorDouble(aCurrent.X, aCurrent.Y);
     _Current = new VectorDouble(aCurrent.X, aCurrent.Y);
     _Target = _Start.Add(aTarget.ToVectorDouble());
     _Step = aStep;
     _Bounce = useBounce;
 }
Exemple #2
0
        public VectorDouble GetPhysFromLogical(VectorInt i)
        {
            var v = grid.Children[0] as Image;

            var s = new VectorDouble(grid.ColumnDefinitions.First().ActualWidth,
                                  grid.RowDefinitions.First().ActualHeight);
            return new VectorDouble(i.X, i.Y).Multiply(s).Add( s.Divide(new VectorDouble(2,2))) ;
        }
Exemple #3
0
 public VectorInt getNext()
 {
     _Current = _Current.Add(_Step);
     if (_Bounce)
     {
         if (_Current.X >= _Target.X) _Step.X *= -1;
         if (_Current.X <= _Start.X) _Step.X *= -1;
         if (_Current.Y >= _Target.Y) _Step.Y *= -1;
         if (_Current.Y <= _Start.Y) _Step.Y *= -1;
         return _Current.ToVectorInt();
     }
     else
     {
         if (_Current == _Target) return null;
         return _Current.ToVectorInt();
     }
 }
Exemple #4
0
        public void Step()
        {
            if (elements == null) return;

            foreach (var e in elements)
            {
                var p = new VectorDouble(Canvas.GetLeft(e.Target), Canvas.GetTop(e.Target));
                if (p.X + e.Speed.X > container.ActualWidth - e.Size.X) e.Speed.X *= -1;
                if (p.X + e.Speed.X < 0) e.Speed.X *= -1;

                if (p.Y + e.Speed.Y > container.ActualHeight - e.Size.Y) e.Speed.Y *= -1;
                if (p.Y + e.Speed.Y < 0) e.Speed.Y *= -1;

                Canvas.SetLeft(e.Target, p.X + e.Speed.X);
                Canvas.SetTop(e.Target, p.Y + e.Speed.Y);

                e.Spin += e.SpinSpeed;

                e.Target.RenderTransform = new RotateTransform(e.Spin);
            }
        }
 public VectorDouble Divide(VectorDouble value)
 {
     return new VectorDouble(x / value.X, y / value.Y);
 }
 public VectorDouble Add(VectorDouble value)
 {
     return new VectorDouble(x + value.X, y + value.Y);
 }
 public VectorDouble(VectorDouble copy)
 {
     this.x = copy.x;
     this.y = copy.y;
 }
 public VectorDouble Subtract(VectorDouble value)
 {
     return new VectorDouble(x - value.X, y - value.Y);
 }
 public VectorDouble Multiply(VectorDouble value)
 {
     return new VectorDouble(x * value.X, y * value.Y);
 }