public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch) { Rectangle bounds = new Rectangle((int)(Position.X), (int)(Position.Y), (int)(Size.X), (int)(Size.Y)); var sprite = Game.GetSlice(BackgroundImage); spriteBatch.Draw(sprite.Texture, bounds, sprite.Crop, TintColor); // Draw Background Vector2 textsize = Game.GetFont(Font).MeasureString(Caption); GraphicsHelper.DrawShadowedString(spriteBatch, Game.GetFont(Font), Caption, Position + new Vector2(Size.X / 2 - textsize.X / 2, Size.Y / 2 - textsize.Y / 2), (Enabled ?(IsMouseHold ? MouseHoldColor : (IsMouseHovered ? MouseHoverColor : ForeColor)):DisabledColor), ShadowColor); }
public virtual void Draw(GameTime gameTime) { if (Kinect == null || !Kinect.IsSensorReady) { return; } var Z = TrackPointData.Z; for (int i = 0; i < TrackPoints.Count; i++) { var point = TrackPoints[i]; //if (Game.Frame - Kinect.LastSkeletonFrame > 5) if (point.SkeletonId < Kinect.TrackedSkeletonsIndices.Count) { var tx = Game.GetSlice((point.TrackTime > Delay ? point.PushedTextureName : point.TextureName), gameTime); var trackPos = Kinect.ToVector3(point.TrackJoint, point.SkeletonId); //var basePos = Kinect.ToVector3(point.BaseJoint, point.SkeletonId); var scaleFactor = 2 - (MathHelper.Clamp(point.BasePos.Z - trackPos.Z, 0, Z)) / (Z); var alpha = -scaleFactor + 2; //scaleFactor += 2; var size = tx.Crop.HasValue ? new Vector2(tx.Crop.Value.Width, tx.Crop.Value.Height) : new Vector2(tx.Texture.Width, tx.Texture.Height); var color = point.Hold ? Color.Red : GraphicsHelper.GetColorWithAlpha(point.Tint, alpha); if (point.TrackingState == JointTrackingState.NotTracked) { color = gameTime.TotalGameTime.Seconds % 2 == 0 ? Color.Gray : Color.DarkGray; } if (point.TrackingState == JointTrackingState.Inferred && (gameTime.TotalGameTime.Milliseconds / 100) % 2 == 0) { color = Color.Gray; } if (!point.Hold && point.Pushed && (gameTime.TotalGameTime.Milliseconds / 100) % 2 == 0) { color = Color.Orange; } Game.SpriteBatch.Draw(tx.Texture, point.Position - size / 2.0f, tx.Crop, color, 0, Vector2.Zero, scaleFactor, SpriteEffects.None, 0); } } }