#need help to add spin

7 messages · Page 1 of 1 (latest)

glad flicker
#

using draw add shape but need to keep spinning

        // convert to float for bounds
        bounds.set((x - radius),(y - radius),(x + radius),(y + radius));

        int halfWidth = width / 2;


//        int rotate = 45;
//
//        if (rotate == 45) {
//            rotate();
//            rotate = 90;
//        }
//        if (rotate == 90) {
//            rotate();
//            rotate = 135;
//        }
//        if (rotate == 90) {
//            rotate();
//            rotate = 180;
//        }
//        if (rotate == 180) {
//            rotate();
//            rotate = 45;
//        }


        Path path = new Path();
        path.moveTo(x, y - halfWidth); // Top
        path.lineTo(x - halfWidth, y + halfWidth); // Bottom left
        path.lineTo(x + halfWidth, y + halfWidth); // Bottom right
        path.lineTo(x, y - halfWidth); // Back to Top
        path.close();


        //canvas.save();
        float rotation = 0;
        canvas.save();
        canvas.rotate(rotation, x / 2, y/ 2);
//all drawing from (x,y) point


        canvas.drawPath(path, paint);
        canvas.restore();
steady zodiacBOT
#

This post has been reserved for your question.

Hey @glad flicker! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

glad flicker
#
        // convert to float for bounds
        bounds.set((x - radius),(y - radius),(x + radius),(y + radius));

        int halfWidth = width / 2;
        
        canvas.save();
        if (angle == 0.0)
            canvas.rotate(90, x / 2, y/ 2);
        else {
            canvas.rotate((float) Math.toDegrees(angle), x, y);
            canvas.rotate(180, x / 2, y/ 2);
        }
        canvas.restore();

        Path path = new Path();
        path.moveTo(x, y - halfWidth); // Top
        path.lineTo(x - halfWidth, y + halfWidth); // Bottom left
        path.lineTo(x + halfWidth, y + halfWidth); // Bottom right
        path.lineTo(x, y - halfWidth); // Back to Top
        path.close();


        //canvas.save();
        float rotation = 0;
        canvas.save();
        canvas.rotate(45, x / 2, y/ 2);
//all drawing from (x,y) point


        canvas.drawPath(path, paint);
        canvas.restore();


    }
}
glad flicker
#

just slowly updating

#
        // convert to float for bounds
        bounds.set((x - radius),(y - radius),(x + radius),(y + radius));

        int halfWidth = width / 2;

        canvas.save();
        if (angle == 0.0)
            canvas.rotate(90, x / 2, y/ 2);
        else {
            canvas.rotate((float) Math.toDegrees(angle), x, y);
            canvas.rotate(0, x / 2, y/ 2);
        }
        canvas.restore();


        //triangle
        Path path = new Path();
        path.moveTo(x, y - halfWidth); // Top
        path.lineTo(x - halfWidth, y + halfWidth); // Bottom left
        path.lineTo(x + halfWidth, y + halfWidth); // Bottom right
        path.lineTo(x, y - halfWidth); // Back to Top
        path.close();


        int saveCount = canvas.save();
        canvas.rotate(mRotation, mArcRect.centerX(), mArcRect.centerY());

        float startAngle = -90 + 360 * (mOffset + mStart);
        float sweepAngle = 360 * (mEnd - mStart);
        canvas.drawArc(mArcRect, startAngle, sweepAngle, false, mArcPaint);

        canvas.restoreToCount(saveCount);

        //canvas.save();
//        float rotation = 0;
//        canvas.save();
        //canvas.rotate(45, x / 2, y/ 2);
//all drawing from (x,y) point


        canvas.drawPath(path, paint);
        canvas.restoreToCount(saveCount);
        //canvas.restore();


    }```
#
        // convert to float for bounds
        bounds.set((x - radius),(y - radius),(x + radius),(y + radius));

        int halfWidth = width / 2;




        //triangle
        Path path = new Path();
        path.moveTo(x, y - halfWidth); // Top
        path.lineTo(x - halfWidth, y + halfWidth); // Bottom left
        path.lineTo(x + halfWidth, y + halfWidth); // Bottom right
        path.lineTo(x, y - halfWidth); // Back to Top
        path.close();

        canvas.save();
        if (angle == 0.0)
            canvas.rotate(90, x / 2, y/ 2);

        else {
            canvas.rotate((float) Math.toDegrees(angle), x, y);
            canvas.rotate(0, x / 2, y/ 2);

        }
        canvas.restore();
        //draw
        canvas.drawPath(path, paint);
        

    }```