1. Are you ready for the Galaxy S20? Here is everything we know so far!

How Do I Rotate Shadows Offset from Center Wear OS Project

Discussion in 'Android Development' started by WolfSpyryt, Dec 3, 2020.

  1. WolfSpyryt

    WolfSpyryt Lurker
    Thread Starter

    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:

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

    Code (Java):
    1.  
    2. private void drawWatchFace(Canvas canvas) {
    3.  
    4.        final float seconds =
    5.                (mCalendar.get(Calendar.SECOND) + mCalendar.get(Calendar.MILLISECOND) / 1000f);
    6.        final float secondsRotation = seconds * 6f;
    7.  
    8.        final float minutesRotation = mCalendar.get(Calendar.MINUTE) * 6f;
    9.  
    10.        final float hourHandOffset = mCalendar.get(Calendar.MINUTE) / 2f;
    11.        final float hoursRotation = (mCalendar.get(Calendar.HOUR) * 30) + hourHandOffset;
    12.  
    13.        canvas.save();
    14.  
    15.        canvas.rotate(hoursRotation, mCenterX, mCenterY);
    16.        canvas.drawBitmap(mHoursPaint,  4,4,  paint);
    17.        canvas.drawBitmap(mHourPaint,  0,0,  paint);
    18.        canvas.drawBitmap(mHourmPaint,  0,0,  paint);
    19.  
    20.        canvas.rotate(minutesRotation-hoursRotation,mCenterX, mCenterY);
    21.        canvas.drawBitmap(mMinutesPaint,  6,6,  paint);
    22.        canvas.drawBitmap(mMinutePaint,  0,0 ,  paint);
    23.        canvas.drawBitmap(mMinutemPaint,  0,0 ,  paint);
    24.  
    25.        canvas.rotate(secondsRotation-minutesRotation, mCenterX, mCenterY);
    26.        canvas.drawBitmap(mSecondsPaint,  8, 8, paint);
    27.        canvas.drawBitmap(mSecondPaint,  0, 0 , paint);
    28.        canvas.drawBitmap(mSecondmPaint,  0, 0 , paint);
    29.  
    30.  
    31.        canvas.restore();
    32.  
    .................................................................................

    Thank you in advance for your help!
     


    #1 WolfSpyryt, Dec 3, 2020
    Last edited: Dec 4, 2020

    1. Download the Forums for Android™ app!


      Download

       
  2. Unforgiven

    Unforgiven ...eschew obfuscation...
    Moderator

    Welcome to androidforums.com!! :)

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

    Result:
    Code (Text):
    1. Line 1
    2. Line 2
    3. Line 3
    4.  
    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.
     
    WolfSpyryt likes this.
  3. WolfSpyryt

    WolfSpyryt Lurker
    Thread Starter

    My apologies and appreciation
     
    Unforgiven likes this.
  4. Unforgiven

    Unforgiven ...eschew obfuscation...
    Moderator

    Apologies not needed, but I'm grateful for the appreciation. :)
     
    WolfSpyryt likes this.
  5. WolfSpyryt

    WolfSpyryt Lurker
    Thread Starter

    Is there anyone who could assist me please?
     
Loading...
Similar Threads - Rotate Shadows Offset
  1. Fabrizio Ferrari
    Replies:
    0
    Views:
    409
  2. mike WRIGHT
    Replies:
    2
    Views:
    320
  3. bjourine stekarfield
    Replies:
    0
    Views:
    638
  4. NewArtDroid
    Replies:
    3
    Views:
    491
  5. ujjawal49
    Replies:
    0
    Views:
    380
  6. anushasubin
    Replies:
    1
    Views:
    420
  7. 785Droid
    Replies:
    5
    Views:
    1,149
  8. pledgeX
    Replies:
    1
    Views:
    786
  9. Hank1111
    Replies:
    2
    Views:
    828
  10. volcanolam
    Replies:
    2
    Views:
    4,468

Share This Page

Loading...