Skip to content

Commit

Permalink
PE-72 Rename form to shape
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanepechard authored and burhanrashid52 committed Jul 10, 2021
1 parent c68b9a7 commit 7f11bd6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7f11bd6

Please sign in to comment.