• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How Do I Rotate Shadows Offset from Center Wear OS Project

WolfSpyryt

Lurker
I have an Android Wear OS watch project. It has 3 watch hands(.png) and 3 watch hand shadows(.png) images.

It all works except I need to define an offset center point for the shadow images, and for that center point to be fixed.

I need each of the shadows to have a seperate center point.

When I try to move their center, the center point moves in orbit around mCenterX & mCenterY.

The mHoursPaint, mMinutesPaint and mSecondsPaint are the Hand shadow images.
The mHourPaint, nMinutePaint and mSecondPaint are main Hand images.
The mHourmPaint, mMinutemPaint and mSecondmPaint are for markers on hands.

Here is the code for the MyWatchFace.java:

..........................................................................................

Java:
private void drawWatchFace(Canvas canvas) {

       final float seconds =
               (mCalendar.get(Calendar.SECOND) + mCalendar.get(Calendar.MILLISECOND) / 1000f);
       final float secondsRotation = seconds * 6f;

       final float minutesRotation = mCalendar.get(Calendar.MINUTE) * 6f;

       final float hourHandOffset = mCalendar.get(Calendar.MINUTE) / 2f;
       final float hoursRotation = (mCalendar.get(Calendar.HOUR) * 30) + hourHandOffset;

       canvas.save();

       canvas.rotate(hoursRotation, mCenterX, mCenterY);
       canvas.drawBitmap(mHoursPaint,  4,4,  paint);
       canvas.drawBitmap(mHourPaint,  0,0,  paint);
       canvas.drawBitmap(mHourmPaint,  0,0,  paint);

       canvas.rotate(minutesRotation-hoursRotation,mCenterX, mCenterY);
       canvas.drawBitmap(mMinutesPaint,  6,6,  paint);
       canvas.drawBitmap(mMinutePaint,  0,0 ,  paint);
       canvas.drawBitmap(mMinutemPaint,  0,0 ,  paint);

       canvas.rotate(secondsRotation-minutesRotation, mCenterX, mCenterY);
       canvas.drawBitmap(mSecondsPaint,  8, 8, paint);
       canvas.drawBitmap(mSecondPaint,  0, 0 , paint);
       canvas.drawBitmap(mSecondmPaint,  0, 0 , paint);


       canvas.restore();

.................................................................................

Thank you in advance for your help!
 
Last edited:
Welcome to androidforums.com!! :)

I added code tags for readability.
Code Tags Usage:
[code]Line 1
Line 2
Line 3
[/code]

Result:
Code:
Line 1
Line 2
Line 3

I also moved it to the developer forum but left a link in the Wear forum for you. Hopefully this gets you the help you need.
 
Welcome to androidforums.com!! :)

I added code tags for readability.
Code Tags Usage:
[code]Line 1
Line 2
Line 3
[/code]

Result:
Code:
Line 1
Line 2
Line 3

I also moved it to the developer forum but left a link in the Wear forum for you. Hopefully this gets you the help you need.
My apologies and appreciation
 
Back
Top Bottom