Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6831205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:42:37+00:00 2026-05-26T22:42:37+00:00

I have three canvases I’m using in a card game app I’m building. One

  • 0

I have three canvases I’m using in a card game app I’m building. One is the main canvas that has the other two as child canvases (one static and one that will rotate):

Canvas Layout

In this sample app, I want to move the RotatingEl to the position on the StaticEl:

Start Point

When i click the Move button, it works as expected:

End Point

Now, I want to Rotate the RotatingCanvas and still have the RotatingEl move to the StaticEl location AND adjust rotation to still match the StaticEl’s angle:

Rotated Canvas

When I try it, it moves to the wrong location:

End Location After Move

Here is my code on the Move Button Click:

GeneralTransform generalTransformStaticEl = StaticEl.TransformToVisual(MainCanvas);
        Point pointstatic = generalTransformStaticEl.Transform(new Point()); 
        GeneralTransform generalTransformRotEl = RotatingEl.TransformToVisual(MainCanvas);
        Point pointrot = generalTransformRotEl.Transform(new Point());

        double distancecalcX = pointstatic.X - pointrot.X;
        double distancecalcY = pointstatic.Y - pointrot.Y;

        DoubleAnimation ELMoveY = new DoubleAnimation();

        ELMoveY.From = Canvas.GetTop(RotatingEl);
        ELMoveY.To = Canvas.GetTop(RotatingEl)+(distancecalcY);
        ELMoveY.Duration = new Duration(TimeSpan.FromSeconds(1.0));

        DoubleAnimation ELMoveX = new DoubleAnimation();

        ELMoveX.From = Canvas.GetLeft(RotatingEl);
        ELMoveX.To = Canvas.GetLeft(RotatingEl)+(distancecalcX);
        ELMoveX.Duration = new Duration(TimeSpan.FromSeconds(1.0));

        RotatingEl.BeginAnimation(Canvas.LeftProperty, ELMoveX);
        RotatingEl.BeginAnimation(Canvas.TopProperty, ELMoveY);

How can I adjusted the “To” of the animations to still move the Rotated canvas’s RotatingEl to the static StaticEl’s position AND adjust the rotation of the RotatingEl to match the StaticEl’s orientation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:42:37+00:00Added an answer on May 26, 2026 at 10:42 pm

    I found my own solution. In case anyone may be interested, here is the updated code:

    double foundangle = 0;
            //verify an actual transform group is there before getting rotate angle
            if (RotatingCanvas.RenderTransform.Value.ToString() != "Identity")
            {
                RotateTransform rt = (RotatingCanvas.RenderTransform as TransformGroup).Children[2] as RotateTransform;
                foundangle = rt.Angle;
            }
            RotateTransform rottrans = new RotateTransform(foundangle*-1);
            RotatingEl.RenderTransform = rottrans;
            GeneralTransform generalTransformStaticEl = StaticEl.TransformToVisual(RotatingCanvas);
            Point pointstatic = generalTransformStaticEl.Transform(new Point());
    
            DoubleAnimation ELMoveY = new DoubleAnimation();
    
            ELMoveY.From = Canvas.GetTop(RotatingEl);
            ELMoveY.To = pointstatic.Y;
            ELMoveY.Duration = new Duration(TimeSpan.FromSeconds(1.0));
    
            DoubleAnimation ELMoveX = new DoubleAnimation();
    
            ELMoveX.From = Canvas.GetLeft(RotatingEl);
            ELMoveX.To = pointstatic.X;
            ELMoveX.Duration = new Duration(TimeSpan.FromSeconds(1.0));
    
            RotatingEl.BeginAnimation(Canvas.LeftProperty, ELMoveX);
            RotatingEl.BeginAnimation(Canvas.TopProperty, ELMoveY);
    

    The generalTransformStaticEl required co-ordinates from the rotated canvas instead of the non-rotated MainCanvas. The adjustment to rotation was simply a matter of getting the Rotated canvas’s current rotation angle and multiplying by -1 to align with static rectangle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three files: one called sql.php witch has a class db that I
I currently have three canvases layered on top of each other by z-index. <canvas
I have three arrays that need to be combined in one three-dimension array. The
I have three (C++) classes: Player, Hand, and Card. Player has a member, hand,
Have three divs in a container that I want to float over a large
I have three column in my datagridview .One is text ,one is Combo and
I have three computers on my LAN, one running ubuntu , one running openSuse
I have two columns: the left one is a Canvas containing an mx:Tree and
I have three domains (domain1.es, domain2.com, domain3.com). I need that: domain1.es OR www.domain1.es, show
I have three tables, one of users, one of cases, and one with links

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.