Shapes Object

I had been thinking about a little programming project for Microsoft Excel.  In order to complete the project, I needed to have a better understanding of the drawing engine.  I proposed for myself a little recreation to get a better understanding of what that would entail.

My idea was to make an analog clock, the kind with hands that go around.  Simple shape rotation stepped by a counter.  Not quite so.

The shapes in Microsoft Excel are located by their Top and Left properties.  No problem.  Just locate and rotate the hands as required.  Not so fast.  The shape rotates around its center.  No problem a bit harder to locate the Top and Left, but wait…there’s more.

It seems that the bounding box, the imaginary box that would enclose a shape does not track the rotating object.  Yes that’s right, the bounding box may or may not enclose the rotating shape.  And this.  The place where it changes is not an obvious thing that you could program to.  How to rotate the hand around the center of the clock as if it were a pivot.

An excellent suggestion I got was “why not put the center of the hand-shape in the center of the clock and hide the other part.  Good idea but it just moves the problem to the other side.  Since I have not learned yet how to color just half of a shape, I would have to have a second shape that matched the background that would act as a cover-up.  But I would have to rotate it just has I had the original.
In the end, i found a way to do it what I needed so it will be the subject of the next few blogs.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.