Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
门心叼龙
android-custom-view
提交
ca3b77f7
A
android-custom-view
项目概览
门心叼龙
/
android-custom-view
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
android-custom-view
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ca3b77f7
编写于
11月 01, 2019
作者:
门心叼龙
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code perfect
上级
7c53bb58
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
3 deletion
+37
-3
app/src/main/java/com/mxdl/customview/view/CaptureRectView.java
...c/main/java/com/mxdl/customview/view/CaptureRectView.java
+37
-3
未找到文件。
app/src/main/java/com/mxdl/customview/view/CaptureRectView.java
浏览文件 @
ca3b77f7
...
...
@@ -38,7 +38,8 @@ public class CaptureRectView extends View {
private
int
mLastX
;
private
int
mLastY
;
private
int
mHitCorner
;
private
Rect
reverseRect
=
new
Rect
();
private
Path
reversePath
=
new
Path
();
public
CaptureRectView
(
Context
context
)
{
super
(
context
);
initView
();
...
...
@@ -96,14 +97,46 @@ public class CaptureRectView extends View {
canvas
.
save
();
//路径重新设置
mCapturePath
.
reset
();
//添加了一个当前的矩形区域
mCapturePath
.
addRect
(
new
RectF
(
mCaptureRect
),
Path
.
Direction
.
CW
);
//当前的画布与指定的路径相交
canvas
.
clipPath
(
mCapturePath
,
Region
.
Op
.
INTERSECT
);
//画矩形背景选区
canvas
.
drawRect
(
mScreenRect
,
mAreaPaint
);
//画矩形背景边框
canvas
.
drawPath
(
mCapturePath
,
mBorderPaint
);
//添加了一个当前的矩形区域
boolean
reverse
=
false
;
if
(
mCaptureRect
.
left
>
mCaptureRect
.
right
){
reverse
=
true
;
reversePath
.
reset
();
reverseRect
.
left
=
mCaptureRect
.
right
;
reverseRect
.
right
=
mCaptureRect
.
left
;
if
(
mCaptureRect
.
top
>
mCaptureRect
.
bottom
){
reverseRect
.
top
=
mCaptureRect
.
bottom
;
reverseRect
.
bottom
=
mCaptureRect
.
top
;
}
else
{
reverseRect
.
top
=
mCaptureRect
.
top
;
reverseRect
.
bottom
=
mCaptureRect
.
bottom
;
}
}
else
if
(
mCaptureRect
.
top
>
mCaptureRect
.
bottom
){
reverse
=
true
;
reversePath
.
reset
();
reverseRect
.
top
=
mCaptureRect
.
bottom
;
reverseRect
.
bottom
=
mCaptureRect
.
top
;
reverseRect
.
left
=
mCaptureRect
.
left
;
reverseRect
.
right
=
mCaptureRect
.
right
;
}
if
(
reverse
){
reversePath
.
addRect
(
new
RectF
(
reverseRect
),
Path
.
Direction
.
CW
);
canvas
.
drawPath
(
reversePath
,
mBorderPaint
);
Log
.
v
(
"MYTAG"
,
"========================================"
+
reverseRect
.
toString
());
}
else
{
canvas
.
drawPath
(
mCapturePath
,
mBorderPaint
);
}
Log
.
v
(
"MYTAG"
,
mCaptureRect
.
toString
());
canvas
.
restore
();
//画左上锚点
...
...
@@ -189,6 +222,7 @@ public class CaptureRectView extends View {
if
(
mCaptureRect
.
bottom
<=
mHalfAnchorWidth
)
{
mCaptureRect
.
bottom
=
mHalfAnchorWidth
;
}
boolean
square
=
true
;
if
(
Math
.
abs
(
mCaptureRect
.
right
-
mCaptureRect
.
left
)
!=
Math
.
abs
(
mCaptureRect
.
bottom
-
mCaptureRect
.
top
))
{
square
=
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录