Skip to content

Commit

Permalink
Dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuriy Budiyev committed Oct 16, 2017
1 parent 2fcdb2b commit 833a73a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
42 changes: 20 additions & 22 deletions src/main/java/com/budiyev/android/codescanner/ViewFinderView.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
final class ViewFinderView extends View {
private final Paint mMaskPaint;
private final Paint mFramePaint;
private final Path mPath;
private final Path mFramePath;
private Rect mFrameRect;
private boolean mSquareFrame;
private int mFrameCornerSize;
Expand All @@ -45,7 +45,7 @@ public ViewFinderView(@NonNull Context context) {
mMaskPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mFramePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mFramePaint.setStyle(Paint.Style.STROKE);
mPath = new Path();
mFramePath = new Path();
}

@Override
Expand All @@ -56,30 +56,28 @@ protected void onDraw(Canvas canvas) {
}
int width = canvas.getWidth();
int height = canvas.getHeight();
mPath.reset();
int top = frameRect.getTop();
int left = frameRect.getLeft();
int right = frameRect.getRight();
int bottom = frameRect.getBottom();
mPath.addRect(0, 0, width, top, Path.Direction.CW);
mPath.addRect(0, top, left, bottom, Path.Direction.CW);
mPath.addRect(right, top, width, bottom, Path.Direction.CW);
mPath.addRect(0, bottom, width, height, Path.Direction.CW);
canvas.drawPath(mPath, mMaskPaint);
mPath.reset();
mPath.moveTo(left, top + mFrameCornerSize);
mPath.lineTo(left, top);
mPath.lineTo(left + mFrameCornerSize, top);
mPath.moveTo(right - mFrameCornerSize, top);
mPath.lineTo(right, top);
mPath.lineTo(right, top + mFrameCornerSize);
mPath.moveTo(right, bottom - mFrameCornerSize);
mPath.lineTo(right, bottom);
mPath.lineTo(right - mFrameCornerSize, bottom);
mPath.moveTo(left + mFrameCornerSize, bottom);
mPath.lineTo(left, bottom);
mPath.lineTo(left, bottom - mFrameCornerSize);
canvas.drawPath(mPath, mFramePaint);
canvas.drawRect(0, 0, width, top, mMaskPaint);
canvas.drawRect(0, top, left, bottom, mMaskPaint);
canvas.drawRect(right, top, width, bottom, mMaskPaint);
canvas.drawRect(0, bottom, width, height, mMaskPaint);
mFramePath.reset();
mFramePath.moveTo(left, top + mFrameCornerSize);
mFramePath.lineTo(left, top);
mFramePath.lineTo(left + mFrameCornerSize, top);
mFramePath.moveTo(right - mFrameCornerSize, top);
mFramePath.lineTo(right, top);
mFramePath.lineTo(right, top + mFrameCornerSize);
mFramePath.moveTo(right, bottom - mFrameCornerSize);
mFramePath.lineTo(right, bottom);
mFramePath.lineTo(right - mFrameCornerSize, bottom);
mFramePath.moveTo(left + mFrameCornerSize, bottom);
mFramePath.lineTo(left, bottom);
mFramePath.lineTo(left, bottom - mFrameCornerSize);
canvas.drawPath(mFramePath, mFramePaint);
}

@Override
Expand Down

0 comments on commit 833a73a

Please sign in to comment.