@Test public void draw_scale() { region.set(16, 16, 48, 48); TestBadgeShape badgeShape = new TestBadgeShape(0.5f, 1, Gravity.NO_GRAVITY); badgeShape.draw(canvas, bounds, paint, 0); badgeShape.assertRegion(region); }
public Rect draw(@NonNull Canvas canvas, @NonNull Rect bounds, @NonNull Paint paint, int layoutDirection) { float width = bounds.width() * scale; float height = bounds.height() * scale; if (width < height * aspectRatio) { height = width / aspectRatio; } else { width = height * aspectRatio; } applyGravity((int) width, (int) height, bounds, layoutDirection); onDraw(canvas, rect, paint); return rect; }
BadgeShape { public Rect draw(@NonNull Canvas canvas, @NonNull Rect bounds, @NonNull Paint paint, int layoutDirection) { float width = bounds.width() * scale; float height = bounds.height() * scale; if (width < height * aspectRatio) { height = width / aspectRatio; } else { width = height * aspectRatio; } applyGravity((int) width, (int) height, bounds, layoutDirection); onDraw(canvas, rect, paint); return rect; } }
BadgeShape { public Rect draw(@NonNull Canvas canvas, @NonNull Rect bounds, @NonNull Paint paint, int layoutDirection) { float width = bounds.width() * scale; float height = bounds.height() * scale; if (width < height * aspectRatio) { height = width / aspectRatio; } else { width = height * aspectRatio; } applyGravity((int) width, (int) height, bounds, layoutDirection); onDraw(canvas, rect, paint); return rect; } protected  BadgeShape(@FloatRange(from = 0, to = 1) float scale, float aspectRatio, int gravity); }
BadgeShape { public Rect draw(@NonNull Canvas canvas, @NonNull Rect bounds, @NonNull Paint paint, int layoutDirection) { float width = bounds.width() * scale; float height = bounds.height() * scale; if (width < height * aspectRatio) { height = width / aspectRatio; } else { width = height * aspectRatio; } applyGravity((int) width, (int) height, bounds, layoutDirection); onDraw(canvas, rect, paint); return rect; } protected  BadgeShape(@FloatRange(from = 0, to = 1) float scale, float aspectRatio, int gravity); Rect draw(@NonNull Canvas canvas, @NonNull Rect bounds, @NonNull Paint paint, int layoutDirection); static BadgeShape circle(@FloatRange(from = 0, to = 1) float scale, int gravity); static BadgeShape oval(@FloatRange(from = 0, to = 1) float scale, float aspectRatio, int gravity); static BadgeShape rect(@FloatRange(from = 0, to = 1) float scale, float aspectRatio, int gravity); static BadgeShape rect(@FloatRange(from = 0, to = 1) float scale, float aspectRatio, int gravity,
                                  @FloatRange(from = 0, to = 1) final float radiusFactor); static BadgeShape square(@FloatRange(from = 0, to = 1) float scale, int gravity); static BadgeShape square(@FloatRange(from = 0, to = 1) float scale, int gravity,
                                    @FloatRange(from = 0, to = 1) float radiusFactor); }
BadgeShape { public Rect draw(@NonNull Canvas canvas, @NonNull Rect bounds, @NonNull Paint paint, int layoutDirection) { float width = bounds.width() * scale; float height = bounds.height() * scale; if (width < height * aspectRatio) { height = width / aspectRatio; } else { width = height * aspectRatio; } applyGravity((int) width, (int) height, bounds, layoutDirection); onDraw(canvas, rect, paint); return rect; } protected  BadgeShape(@FloatRange(from = 0, to = 1) float scale, float aspectRatio, int gravity); Rect draw(@NonNull Canvas canvas, @NonNull Rect bounds, @NonNull Paint paint, int layoutDirection); static BadgeShape circle(@FloatRange(from = 0, to = 1) float scale, int gravity); static BadgeShape oval(@FloatRange(from = 0, to = 1) float scale, float aspectRatio, int gravity); static BadgeShape rect(@FloatRange(from = 0, to = 1) float scale, float aspectRatio, int gravity); static BadgeShape rect(@FloatRange(from = 0, to = 1) float scale, float aspectRatio, int gravity,
                                  @FloatRange(from = 0, to = 1) final float radiusFactor); static BadgeShape square(@FloatRange(from = 0, to = 1) float scale, int gravity); static BadgeShape square(@FloatRange(from = 0, to = 1) float scale, int gravity,
                                    @FloatRange(from = 0, to = 1) float radiusFactor);  }