app/src/main/java/com/geekyouup/android/ustopwatch/fragments/StopwatchCustomVectorView.java
//assumed that the incoming canvas is square
assumed that the incoming canvas is square
assumed that the incoming canvas is square
private void drawWatchface(Canvas canvas) {
        int canvasWidth = canvas.getWidth();
        int canvasHeight = canvas.getHeight();
        float canvasCenter = canvasWidth / 2.0f;
        float watchfaceOuterRadius = FULL_WATCHFACE_OUTER_RADIUS * mScaleFactor;
        float watchfaceDiameter = watchfaceOuterRadius * 2.0f;
        float pri60thDashHeight = FULL_60TH_1_DASH_HEIGHT * mScaleFactor;
        float sec60thDashHeight = FULL_60TH_2_DASH_HEIGHT * mScaleFactor;
        float ter60thDashHeight = FULL_60TH_3_DASH_HEIGHT * mScaleFactor;
        float yOffset60thCircle = (canvasHeight - watchfaceDiameter) / 2.0f + pri60thDashHeight;
        float yOffset100thCircle = (canvasHeight - (FULL_100TH_OUTER_DIAMETER * mScaleFactor)) / 2.0f;
        float pri100thDashHeight = FULL_100th_1_DASH_HEIGHT * mScaleFactor;
        float sec100thDashHeight = FULL_100th_2_DASH_HEIGHT * mScaleFactor;
        float patternCircleRadius = FULL_PATTERN_CIRCLE_RADIUS * mScaleFactor;
        float text60thHalfHeight = FULL_60th_NUMERALS_SIZE * mScaleFactor / 3; 
        float text60thRadius = FULL_60TH_NUMERALS_RADIUS * mScaleFactor;
        float text100thRadius = FULL_100TH_NUMERALS_RADIUS * mScaleFactor;
        float text100thHalfHeight = FULL_100th_NUMERALS_SIZE * mScaleFactor / 2;
        float minsCircleRadius = FULL_MINS_CIRCLE_RADIUS * mScaleFactor;
        float minsCenterY = FULL_MINS_CENTER_Y * mScaleFactor;
        float minsDashHeight = FULL_MINS_DASH_HEIGHT * mScaleFactor;
        float textMinsRadius = FULL_MINS_NUMERALS_RADIUS * mScaleFactor;
        float textMinsHalfHeigh = FULL_MINS_NUMERALS_SIZE * mScaleFactor / 3;
        /*
        float logoTextY = FULL_NAMEPLATE_Y*mScaleFactor;
        mLogoTextPath = new Path();
        mLogoTextPath.moveTo(canvasCenter / 2, logoTextY);
        mLogoTextPath.cubicTo(canvasCenter / 2, logoTextY, canvasCenter, logoTextY + watchfaceOuterRadius / 2, 3 * canvasCenter / 2, logoTextY);
        //Draw the Ultimate Stopwatch Text on a curve
        canvas.drawTextOnPath("Ultimate Stopwatch",mLogoTextPath,0,0,mLogoTextPaint);
        */
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.outHeight = (int) (FULL_NAMEPLATE_HEIGHT * mScaleFactor);
        options.outWidth = (int) (FULL_NAMEPLATE_WIDTH * mScaleFactor);
        Bitmap watchLogo = BitmapFactory.decodeResource(getResources(), R.drawable.logo, null);
        watchLogo = Bitmap.createScaledBitmap(watchLogo, (int) (FULL_NAMEPLATE_WIDTH * mScaleFactor), (int) (FULL_NAMEPLATE_HEIGHT * mScaleFactor), true);
        canvas.drawBitmap(watchLogo, FULL_NAMEPLATE_X * mScaleFactor, FULL_NAMEPLATE_Y * mScaleFactor, null);
        canvas.drawCircle(canvasCenter, minsCenterY, minsCircleRadius, mMinsCirclePaint);
        canvas.save();
        for (int a = 0; a < 360; a += 12) {
            canvas.drawLine(canvasCenter, minsCenterY - minsCircleRadius, canvasCenter, minsCenterY - minsCircleRadius + minsDashHeight, mMinsCirclePaint);
            canvas.rotate(12, canvasCenter, minsCenterY);
        }
        canvas.restore();
         numerals
        for (int a = 0; a < 6; a++) {
            double xPos = canvasCenter + Math.cos(Math.toRadians(a * 60 - 30)) * textMinsRadius;
            double yPos = minsCenterY + Math.sin(Math.toRadians(a * 60 - 30)) * textMinsRadius + textMinsHalfHeigh;
            int numeral = (a + 1) * 5;
            canvas.drawText((numeral < 10 ? " " : "") + numeral, (float) xPos, (float) yPos, mMinsNumeralsPaint);
        }
        canvas.save();
        for (int a = 0; a < 360; a += 2) {
            if (a % 30 == 0) {
                canvas.drawLine(canvasCenter, yOffset60thCircle - pri60thDashHeight, canvasCenter, yOffset60thCircle, mPrimaryDashPaint);
            } else if (a % 6 == 0) {
                canvas.drawLine(canvasCenter, yOffset60thCircle - sec60thDashHeight, canvasCenter, yOffset60thCircle, mSecondaryDashPaint);
            } else if (a % 2 == 0) {
                canvas.drawLine(canvasCenter, yOffset60thCircle - ter60thDashHeight, canvasCenter, yOffset60thCircle, mTertiaryDashPaint);
            }
            canvas.rotate(2, canvasCenter, canvasCenter);
        }
        canvas.restore();
        canvas.drawCircle(canvasCenter, canvasCenter, patternCircleRadius, mPatternCircleSolidPaint);
        canvas.drawCircle(canvasCenter, canvasCenter, patternCircleRadius, mPatternCircleDashPaint);
        canvas.save();
        for (int a = 0; a < 200; a++) {
            if (a % 10 == 0) {
                canvas.drawLine(canvasCenter, yOffset100thCircle, canvasCenter, yOffset100thCircle + pri100thDashHeight, m100thsPrimaryDashPaint);
            } else if (a % 2 == 0) {
                canvas.drawLine(canvasCenter, yOffset100thCircle, canvasCenter, yOffset100thCircle + sec100thDashHeight, m100thsPrimaryDashPaint);
            } else {
                canvas.drawLine(canvasCenter, yOffset100thCircle, canvasCenter, yOffset100thCircle + sec100thDashHeight, m100thsSecondaryDashPaint);
            }
            canvas.rotate(1.8f, canvasCenter, canvasCenter);
        }
        canvas.restore();
        for (int a = 0; a < 360; a += 30) {
            double xPos = canvasCenter + Math.cos(Math.toRadians(a)) * text60thRadius;
            double yPos = canvasCenter + Math.sin(Math.toRadians(a)) * text60thRadius + text60thHalfHeight;
            int numeral = ((a / 6 + 15) % 60);
            if (numeral == 0) numeral = 60;
            canvas.drawText((numeral < 10 ? " " : "") + numeral, (float) xPos, (float) yPos, mClockNumeralsPaint);
        }
        for (int a = 0; a < 10; a++) {
            if (a == 2 || a == 7) continue; 
            double xPos = canvasCenter + Math.cos(Math.toRadians(a * 36 + 18)) * text100thRadius;
            double yPos = canvasCenter + Math.sin(Math.toRadians(a * 36 + 18)) * text100thRadius + text100thHalfHeight;
            String numeral = (a * 10 + 30) % 100 + "";
            canvas.drawText(numeral, (float) xPos, (float) yPos, m100thsNumeralsPaint);
        }
    }
private void drawWatchface ( Canvas canvas ) { int canvasWidth = canvas . getWidth ( ) ; int canvasHeight = canvas . getHeight ( ) ; float canvasCenter = canvasWidth / 2.0f ; float watchfaceOuterRadius = FULL_WATCHFACE_OUTER_RADIUS * mScaleFactor ; float watchfaceDiameter = watchfaceOuterRadius * 2.0f ; float pri60thDashHeight = FULL_60TH_1_DASH_HEIGHT * mScaleFactor ; float sec60thDashHeight = FULL_60TH_2_DASH_HEIGHT * mScaleFactor ; float ter60thDashHeight = FULL_60TH_3_DASH_HEIGHT * mScaleFactor ; float yOffset60thCircle = ( canvasHeight - watchfaceDiameter ) / 2.0f + pri60thDashHeight ; float yOffset100thCircle = ( canvasHeight - ( FULL_100TH_OUTER_DIAMETER * mScaleFactor ) ) / 2.0f ; float pri100thDashHeight = FULL_100th_1_DASH_HEIGHT * mScaleFactor ; float sec100thDashHeight = FULL_100th_2_DASH_HEIGHT * mScaleFactor ; float patternCircleRadius = FULL_PATTERN_CIRCLE_RADIUS * mScaleFactor ; float text60thHalfHeight = FULL_60th_NUMERALS_SIZE * mScaleFactor / 3 ; float text60thRadius = FULL_60TH_NUMERALS_RADIUS * mScaleFactor ; float text100thRadius = FULL_100TH_NUMERALS_RADIUS * mScaleFactor ; float text100thHalfHeight = FULL_100th_NUMERALS_SIZE * mScaleFactor / 2 ; float minsCircleRadius = FULL_MINS_CIRCLE_RADIUS * mScaleFactor ; float minsCenterY = FULL_MINS_CENTER_Y * mScaleFactor ; float minsDashHeight = FULL_MINS_DASH_HEIGHT * mScaleFactor ; float textMinsRadius = FULL_MINS_NUMERALS_RADIUS * mScaleFactor ; float textMinsHalfHeigh = FULL_MINS_NUMERALS_SIZE * mScaleFactor / 3 ; /*
        float logoTextY = FULL_NAMEPLATE_Y*mScaleFactor;
        mLogoTextPath = new Path();
        mLogoTextPath.moveTo(canvasCenter / 2, logoTextY);
        mLogoTextPath.cubicTo(canvasCenter / 2, logoTextY, canvasCenter, logoTextY + watchfaceOuterRadius / 2, 3 * canvasCenter / 2, logoTextY);

        //Draw the Ultimate Stopwatch Text on a curve
        canvas.drawTextOnPath("Ultimate Stopwatch",mLogoTextPath,0,0,mLogoTextPaint);
        */ BitmapFactory . Options options = new BitmapFactory . Options ( ) ; options . outHeight = ( int ) ( FULL_NAMEPLATE_HEIGHT * mScaleFactor ) ; options . outWidth = ( int ) ( FULL_NAMEPLATE_WIDTH * mScaleFactor ) ; Bitmap watchLogo = BitmapFactory . decodeResource ( getResources ( ) , R . drawable . logo , null ) ; watchLogo = Bitmap . createScaledBitmap ( watchLogo , ( int ) ( FULL_NAMEPLATE_WIDTH * mScaleFactor ) , ( int ) ( FULL_NAMEPLATE_HEIGHT * mScaleFactor ) , true ) ; canvas . drawBitmap ( watchLogo , FULL_NAMEPLATE_X * mScaleFactor , FULL_NAMEPLATE_Y * mScaleFactor , null ) ; canvas . drawCircle ( canvasCenter , minsCenterY , minsCircleRadius , mMinsCirclePaint ) ; canvas . save ( ) ; for ( int a = 0 ; a < 360 ; a += 12 ) { canvas . drawLine ( canvasCenter , minsCenterY - minsCircleRadius , canvasCenter , minsCenterY - minsCircleRadius + minsDashHeight , mMinsCirclePaint ) ; canvas . rotate ( 12 , canvasCenter , minsCenterY ) ; } canvas . restore ( ) ; for ( int a = 0 ; a < 6 ; a ++ ) { double xPos = canvasCenter + Math . cos ( Math . toRadians ( a * 60 - 30 ) ) * textMinsRadius ; double yPos = minsCenterY + Math . sin ( Math . toRadians ( a * 60 - 30 ) ) * textMinsRadius + textMinsHalfHeigh ; int numeral = ( a + 1 ) * 5 ; canvas . drawText ( ( numeral < 10 ? " " : "" ) + numeral , ( float ) xPos , ( float ) yPos , mMinsNumeralsPaint ) ; } canvas . save ( ) ; for ( int a = 0 ; a < 360 ; a += 2 ) { if ( a % 30 == 0 ) { canvas . drawLine ( canvasCenter , yOffset60thCircle - pri60thDashHeight , canvasCenter , yOffset60thCircle , mPrimaryDashPaint ) ; } else if ( a % 6 == 0 ) { canvas . drawLine ( canvasCenter , yOffset60thCircle - sec60thDashHeight , canvasCenter , yOffset60thCircle , mSecondaryDashPaint ) ; } else if ( a % 2 == 0 ) { canvas . drawLine ( canvasCenter , yOffset60thCircle - ter60thDashHeight , canvasCenter , yOffset60thCircle , mTertiaryDashPaint ) ; } canvas . rotate ( 2 , canvasCenter , canvasCenter ) ; } canvas . restore ( ) ; canvas . drawCircle ( canvasCenter , canvasCenter , patternCircleRadius , mPatternCircleSolidPaint ) ; canvas . drawCircle ( canvasCenter , canvasCenter , patternCircleRadius , mPatternCircleDashPaint ) ; canvas . save ( ) ; for ( int a = 0 ; a < 200 ; a ++ ) { if ( a % 10 == 0 ) { canvas . drawLine ( canvasCenter , yOffset100thCircle , canvasCenter , yOffset100thCircle + pri100thDashHeight , m100thsPrimaryDashPaint ) ; } else if ( a % 2 == 0 ) { canvas . drawLine ( canvasCenter , yOffset100thCircle , canvasCenter , yOffset100thCircle + sec100thDashHeight , m100thsPrimaryDashPaint ) ; } else { canvas . drawLine ( canvasCenter , yOffset100thCircle , canvasCenter , yOffset100thCircle + sec100thDashHeight , m100thsSecondaryDashPaint ) ; } canvas . rotate ( 1.8f , canvasCenter , canvasCenter ) ; } canvas . restore ( ) ; for ( int a = 0 ; a < 360 ; a += 30 ) { double xPos = canvasCenter + Math . cos ( Math . toRadians ( a ) ) * text60thRadius ; double yPos = canvasCenter + Math . sin ( Math . toRadians ( a ) ) * text60thRadius + text60thHalfHeight ; int numeral = ( ( a / 6 + 15 ) % 60 ) ; if ( numeral == 0 ) numeral = 60 ; canvas . drawText ( ( numeral < 10 ? " " : "" ) + numeral , ( float ) xPos , ( float ) yPos , mClockNumeralsPaint ) ; } for ( int a = 0 ; a < 10 ; a ++ ) { if ( a == 2 || a == 7 ) continue ; double xPos = canvasCenter + Math . cos ( Math . toRadians ( a * 36 + 18 ) ) * text100thRadius ; double yPos = canvasCenter + Math . sin ( Math . toRadians ( a * 36 + 18 ) ) * text100thRadius + text100thHalfHeight ; String numeral = ( a * 10 + 30 ) % 100 + "" ; canvas . drawText ( numeral , ( float ) xPos , ( float ) yPos , m100thsNumeralsPaint ) ; } }
assumed that the incoming canvas is square
assumed that the incoming canvas is square
//one third height lines up better //minutes //draw the logo //draw the minutes //draw the minute ticks //draw the 60ths etc.. lines //draw the minutes numerals //draw the clock face //draw the 60ths etc.. lines //+60,+70,+90 //draw the black circle //draw the 100ths lines //200ths //draw the 60ths numerals //draw the 100ths numerals //no text at 0 or 50