public void AddFramePoint(int Frame, Point Position, float Rotation = 0f, bool ShowWeapon = false) { if (!SpecificCoordinates.ContainsKey(Frame)) { AnimationPoint ap = new AnimationPoint(Position.X, Position.Y, Rotation, ShowWeapon); SpecificCoordinates.Add(Frame, ap); } else { SpecificCoordinates[Frame].X = Position.X; SpecificCoordinates[Frame].Y = Position.Y; } }
Vector3 GetNewScale(AnimationPoint point) { Vector3 newScale; if (point.rotScaleTransform != null) { newScale = point.rotScaleTransform.localScale; } else { newScale = transform.localScale; } return(newScale); }
Quaternion GetNewRorartion(AnimationPoint point) { Quaternion newRotation; if (point.rotScaleTransform != null) { newRotation = point.rotScaleTransform.rotation; } else { newRotation = transform.rotation; } return(newRotation); }
Vector3 GetNewPosition(AnimationPoint point) { Vector3 newPos; if (point.positionTransform != null) { newPos = point.positionTransform.position; } else if (point.rotScaleTransform != null) { newPos = point.rotScaleTransform.position; } else { newPos = transform.position; } return(newPos); }
private Bitmap ClipImage(Bitmap image, AnimateActionClipEnum style, AnimationPoint start, AnimationPoint end) { if (image != null) { Bitmap dstImage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppArgb); var onePercentX = image.Width / 100.0f; var onePercentY = image.Height / 100.0f; var topLeft = new PointF(start.X * onePercentX / 2, start.Y * onePercentY / 2); var btmRight = new PointF(end.X * onePercentX, end.Y * onePercentY); using (Graphics g = Graphics.FromImage(dstImage)) { // enables smoothing of the edge of the circle (less pixelated) g.SmoothingMode = SmoothingMode.AntiAlias; // fills background color using (Brush br = new SolidBrush(Color.Transparent)) { g.FillRectangle(br, 0, 0, dstImage.Width, dstImage.Height); } // adds the new ellipse & draws the image again using (GraphicsPath path = new GraphicsPath()) { // Clipping a circular path if (style == AnimateActionClipEnum.Circle) { path.AddEllipse(topLeft.X, topLeft.Y, btmRight.X, btmRight.Y); } // Clipping a square if (style == AnimateActionClipEnum.Square) { path.AddRectangle(new RectangleF(topLeft.X, topLeft.Y, btmRight.X, btmRight.Y)); } g.SetClip(path); g.DrawImage(image, 0, 0); } return(dstImage); } } return(null); }
/// <summary> /// Create animation info from string. /// </summary> private void CreateAnimationSteps(string animationDescription) { _animationSteps.Steps.Clear(); string tempstr = animationDescription.Replace(System.Environment.NewLine, " "); string[] entries = tempstr.Split(' '); AnimationPoint currentAp = null; string lastEntry = ""; foreach (string str in entries) { switch (str.ToLower()) { case "run": if (currentAp != null) _animationSteps.Steps.Add(currentAp); currentAp = new AnimationPoint(); break; } switch (lastEntry.ToLower()) { case "steps": if (currentAp != null) currentAp.Steps = int.Parse(str); break; case "time": if (currentAp != null) currentAp.Time = int.Parse(str); break; case "file": if (currentAp != null) currentAp.fileName = str; break; } lastEntry = str; } if (currentAp != null) _animationSteps.Steps.Add(currentAp); }
/// <summary> /// Append Entry to Animation /// </summary> public void AddCurrentHistoryEntry() { AnimationPoint point = new AnimationPoint(); point.Time = _dataPerTime.CurrentTime; point.Steps = ParameterDict.Current.GetInt("Animation.Steps"); string comment = ""; try { string file = _dataPerTime.Get(point.Time)["Intern.FileName"]; if (file != "") { file = System.IO.Path.GetFileNameWithoutExtension(file); comment = " # File " + file; } } catch (System.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } tbAnimationDescription.Text = tbAnimationDescription.Text + System.Environment.NewLine + "Run Steps " + point.Steps.ToString() + " Time " + point.Time.ToString() + comment ; }