Rectangle/object tilted/rotated

I started to look for a way to do that, but haven’t found anything so far. Maybe one of you guys haves a tip?
I’d like to draw a joystick, like this old video game controllers had the to steer the cursor (red ball on a metal stick).

Well the red ball is easy, but the stick is more difficult:
I need a small rectangle with a curvy side do be drawn with the same with but in various length, and different angles (e.g. 40 points long, 45°, or 66 points, 185°), to be overlayed at the other end by the red oval (ball).

Is there a way to dynamically lengthen and rotate this ‘stick object’, assuming a rectangle, according movement of the ball (x,y)?
Is there an example code I can easily learn from?

http://documentation.xojo.com/index.php/Object2D

It seems to work. However, I encounter a problem:
If my canvas area has a backdrop, the drawn object isn’t shown.
And how can I erase the drawn object to clear it for a next one / replacement?

If you draw in the canvas, draw first the image you would have put as backdrop with Drawpicture. Don’t use Backdrop at all.

To erase a portion of the screen, see ClearRect http://documentation.xojo.com/index.php/Graphics

Basically, use Canvas1.invalidate to trigger a new Paint.

Ok, it gets better and better.
But my joystick ball, when moving around, is overlapping stuff I drew with drawrect. It seems that an oval is in fact a square, and at the corners it is overwriting stuff that it shouldn’t. This part is not transparent, or colourless, and it can’t be overruled in the definitions of an oval… so it blocks my hard created stick of the joystick sometimes (e.g. when at a 315° position).
/Users/chroni/Desktop/Screen Shot 2017-05-02 at 22.27.38.png

For what appears to be a game, and especially for a ball, I would not use Direct2D. I would rather use already drawn objects.

It is not exactly what you do, but you may want to look at Example Projects/Graphics and Multimedia/CanvasDrawDrag.xojo_binary_project

It will show you how to move objects on a canvas.

This seems quite interesting, although maybe too complicated for my purpose. Will have a look at it, thanks.

As you noticed, the circle in Direct2D is in fact a rounded square. Use FillOval instead for the red ball and you won’t have the issue.

Thank to everyone, I programmed it to my satisfaction now.
I used a superclass for the canvas, bitmapforcaching, there graphics.filloval and drawline, an several handlers and methods… too large to show here, but the result is in my application iHubelmatt (Tab SolarTelescope) nicely visible.