diff --git a/app/src/main/java/com/burhanrashid52/photoediting/ShapeBSFragment.java b/app/src/main/java/com/burhanrashid52/photoediting/ShapeBSFragment.java index 507c1343..badfbfe4 100644 --- a/app/src/main/java/com/burhanrashid52/photoediting/ShapeBSFragment.java +++ b/app/src/main/java/com/burhanrashid52/photoediting/ShapeBSFragment.java @@ -60,6 +60,8 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat mProperties.onShapePicked(ShapeType.OVAL); } else if (checkedId == R.id.rectRadioButton) { mProperties.onShapePicked(ShapeType.RECTANGLE); + } else if (checkedId == R.id.arrowRadioButton) { + mProperties.onShapePicked(ShapeType.ARROW); } else { mProperties.onShapePicked(ShapeType.BRUSH); } diff --git a/app/src/main/res/layout/fragment_bottom_shapes_dialog.xml b/app/src/main/res/layout/fragment_bottom_shapes_dialog.xml index af32dcfe..d3f3dd98 100644 --- a/app/src/main/res/layout/fragment_bottom_shapes_dialog.xml +++ b/app/src/main/res/layout/fragment_bottom_shapes_dialog.xml @@ -28,6 +28,11 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/label_line" /> + = TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) { + path = createLinePath(); + lastX = x; + lastY = y; + } + } + + private @NonNull Path createLinePath() { + float angle = 90; + float radius = 35; + float angleRad = (float) (Math.PI*angle/180.0f); + float lineAngle = (float) (Math.atan2(bottom-top,right-left)); + Path path = new Path(); + // line + path.moveTo(left, top); + path.lineTo(right, bottom); + // arrow head + path.moveTo(right, bottom); + path.lineTo( + (float)(right-radius*cos(lineAngle - (angleRad / 2.0))), + (float)(bottom-radius*sin(lineAngle - (angleRad / 2.0))) + ); + path.lineTo( + (float)(right-radius*cos(lineAngle + (angleRad / 2.0))), + (float)(bottom-radius*sin(lineAngle + (angleRad / 2.0))) + ); + path.close(); + return path; + } + + @Override + public void stopShape() { + Log.d(getTag(), "stopShape"); + } + +} diff --git a/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/shape/ShapeType.java b/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/shape/ShapeType.java index defc271b..86391e5b 100644 --- a/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/shape/ShapeType.java +++ b/photoeditor/src/main/java/ja/burhanrashid52/photoeditor/shape/ShapeType.java @@ -7,5 +7,6 @@ public enum ShapeType { BRUSH, OVAL, RECTANGLE, - LINE + LINE, + ARROW }