From 7f11bd674cf443f2097269a55c5cfd72ce5ccce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Pe=CC=81chard?= Date: Wed, 9 Jun 2021 10:00:24 +0200 Subject: [PATCH] PE-72 Rename form to shape --- README.md | 3 ++- .../photoediting/EditImageActivity.java | 8 ++++---- .../burhanrashid52/photoeditor/BrushDrawingView.java | 12 ++++++------ .../ja/burhanrashid52/photoeditor/PhotoEditor.java | 12 ++++++------ .../burhanrashid52/photoeditor/PhotoEditorImpl.java | 4 ++-- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 07d46efe..a09ab9a3 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ A Photo Editor library with simple, easy support for image editing using Paints, ## Features -- [**Drawing**](#drawing) on image with option to change its Brush's Color, Size, Opacity and Erasing. +- [**Drawing**](#drawing) on image with option to change its Brush's Color, Size, Opacity, Erasing and basic shapes. - Apply [**Filter Effect**](#filter-effect) on image using MediaEffect - Adding/Editing [**Text**](#text) with option to change its Color with Custom Fonts. - Adding [**Emoji**](#emoji) with Custom Emoji Fonts. @@ -113,6 +113,7 @@ We can customize our brush and paint with different set of property. To start dr | Color Opacity (In %) | `mPhotoEditor.setOpacity(opacity)` | | Brush Color | `mPhotoEditor.setBrushColor(colorCode)` | | Brush Eraser | `mPhotoEditor.brushEraser()` | +| Shape (free hand, oval, rectangle) | `mPhotoEditor.setBrushDrawingShape(brushDrawingShape)` | **Note**: Whenever we set any property of a brush for drawing it will automatically enable the drawing mode diff --git a/app/src/main/java/com/burhanrashid52/photoediting/EditImageActivity.java b/app/src/main/java/com/burhanrashid52/photoediting/EditImageActivity.java index c9586314..5a9aa456 100644 --- a/app/src/main/java/com/burhanrashid52/photoediting/EditImageActivity.java +++ b/app/src/main/java/com/burhanrashid52/photoediting/EditImageActivity.java @@ -403,17 +403,17 @@ public void onFilterSelected(PhotoFilter photoFilter) { public void onToolSelected(ToolType toolType) { switch (toolType) { case BRUSH: - mPhotoEditor.setBrushDrawingForm(PhotoEditor.BrushDrawingForm.FREE_HAND); + mPhotoEditor.setBrushDrawingShape(PhotoEditor.BrushDrawingShape.FREE_HAND); mTxtCurrentTool.setText(R.string.label_brush); showBottomSheetDialogFragment(mPropertiesBSFragment); break; case OVAL: - mPhotoEditor.setBrushDrawingForm(PhotoEditor.BrushDrawingForm.OVAL); + mPhotoEditor.setBrushDrawingShape(PhotoEditor.BrushDrawingShape.OVAL); mTxtCurrentTool.setText(R.string.label_oval); showBottomSheetDialogFragment(mPropertiesBSFragment); break; case RECTANGLE: - mPhotoEditor.setBrushDrawingForm(PhotoEditor.BrushDrawingForm.RECTANGLE); + mPhotoEditor.setBrushDrawingShape(PhotoEditor.BrushDrawingShape.RECTANGLE); mTxtCurrentTool.setText(R.string.label_rectangle); showBottomSheetDialogFragment(mPropertiesBSFragment); break; @@ -428,7 +428,7 @@ public void onToolSelected(ToolType toolType) { }); break; case ERASER: - mPhotoEditor.setBrushDrawingForm(PhotoEditor.BrushDrawingForm.FREE_HAND); + mPhotoEditor.setBrushDrawingShape(PhotoEditor.BrushDrawingShape.FREE_HAND); mPhotoEditor.brushEraser(); mTxtCurrentTool.setText(R.string.label_eraser_mode); break; diff --git a/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/BrushDrawingView.java b/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/BrushDrawingView.java index e2dc416f..7309d6d0 100644 --- a/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/BrushDrawingView.java +++ b/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/BrushDrawingView.java @@ -52,7 +52,7 @@ public class BrushDrawingView extends View { private Path mPath; private float mTouchX, mTouchY; private float mLeft, mTop, mRight, mBottom; - private PhotoEditor.BrushDrawingForm mBrushDrawForm = PhotoEditor.BrushDrawingForm.FREE_HAND; + private PhotoEditor.BrushDrawingShape mBrushDrawShape = PhotoEditor.BrushDrawingShape.FREE_HAND; private static final float TOUCH_TOLERANCE = 4; private BrushViewChangeListener mBrushViewChangeListener; @@ -109,8 +109,8 @@ void setBrushDrawingMode(boolean brushDrawMode) { } } - void setBrushDrawingForm(PhotoEditor.BrushDrawingForm brushDrawForm) { - this.mBrushDrawForm = brushDrawForm; + void setBrushDrawingShape(PhotoEditor.BrushDrawingShape brushDrawShape) { + this.mBrushDrawShape = brushDrawShape; setBrushDrawingMode(true); } @@ -255,7 +255,7 @@ private void touchStart(float x, float y) { } private void touchMove(float x, float y) { - if (mBrushDrawForm == PhotoEditor.BrushDrawingForm.FREE_HAND) { + if (mBrushDrawShape == PhotoEditor.BrushDrawingShape.FREE_HAND) { touchMoveFreeHand(x, y); } else { touchMoveInsideRect(x, y); @@ -279,7 +279,7 @@ private void touchMoveInsideRect(float x, float y) { float dx = Math.abs(x - mTouchX); float dy = Math.abs(y - mTouchY); if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) { - if (mBrushDrawForm == PhotoEditor.BrushDrawingForm.OVAL) { + if (mBrushDrawShape == PhotoEditor.BrushDrawingShape.OVAL) { mPath = createOvalPath(); } else { mPath = createRectanglePath(); @@ -290,7 +290,7 @@ private void touchMoveInsideRect(float x, float y) { } private void touchUp() { - if (mBrushDrawForm == PhotoEditor.BrushDrawingForm.FREE_HAND) { + if (mBrushDrawShape == PhotoEditor.BrushDrawingShape.FREE_HAND) { mPath.lineTo(mTouchX, mTouchY); // Commit the path to our offscreen mDrawCanvas.drawPath(mPath, mDrawPaint); diff --git a/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/PhotoEditor.java b/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/PhotoEditor.java index 957bf23d..b01f4dd9 100644 --- a/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/PhotoEditor.java +++ b/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/PhotoEditor.java @@ -119,12 +119,12 @@ public interface PhotoEditor { Boolean getBrushDrawableMode(); /** - * Specify the form drawn {@link PhotoEditorView}. Also run {@link PhotoEditor#setBrushDrawingMode} with true value. - * Default value is {@link PhotoEditor.BrushDrawingForm#FREE_HAND}. + * Specify the shape drawn on {@link PhotoEditorView}. Also run {@link PhotoEditor#setBrushDrawingMode} with true value. + * Default value is {@link BrushDrawingShape#FREE_HAND}. * - * @param brushDrawingForm the form to use + * @param brushDrawingShape the shape to use */ - void setBrushDrawingForm(BrushDrawingForm brushDrawingForm); + void setBrushDrawingShape(BrushDrawingShape brushDrawingShape); /** * set the size of brush user want to paint on canvas i.e {@link BrushDrawingView} @@ -384,9 +384,9 @@ interface OnSaveListener { /** - * Enumerates the different forms that can be drawn on a brush surface. + * Enumerates the different shapes that can be drawn on a brush surface. */ - enum BrushDrawingForm { + enum BrushDrawingShape { FREE_HAND, OVAL, RECTANGLE } diff --git a/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/PhotoEditorImpl.java b/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/PhotoEditorImpl.java index d0d0a9e5..f37b433f 100644 --- a/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/PhotoEditorImpl.java +++ b/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/PhotoEditorImpl.java @@ -198,9 +198,9 @@ public Boolean getBrushDrawableMode() { } @Override - public void setBrushDrawingForm(BrushDrawingForm brushDrawingForm) { + public void setBrushDrawingShape(BrushDrawingShape brushDrawingShape) { if (brushDrawingView != null) - brushDrawingView.setBrushDrawingForm(brushDrawingForm); + brushDrawingView.setBrushDrawingShape(brushDrawingShape); } @Override