Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
carrotech
doodle
提交
6a5938b1
D
doodle
项目概览
carrotech
/
doodle
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
doodle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6a5938b1
编写于
8月 04, 2018
作者:
H
huangziwei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
DoodlePath支持旋转。可旋转item可设置围绕某个点旋转
上级
637b45a0
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
131 addition
and
93 deletion
+131
-93
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_main.xml
+0
-1
app/src/main/res/values/colors.xml
app/src/main/res/values/colors.xml
+1
-5
doodle/src/main/java/cn/hzw/doodle/CopyLocation.java
doodle/src/main/java/cn/hzw/doodle/CopyLocation.java
+1
-4
doodle/src/main/java/cn/hzw/doodle/DoodleBitmap.java
doodle/src/main/java/cn/hzw/doodle/DoodleBitmap.java
+14
-2
doodle/src/main/java/cn/hzw/doodle/DoodleItemBase.java
doodle/src/main/java/cn/hzw/doodle/DoodleItemBase.java
+24
-7
doodle/src/main/java/cn/hzw/doodle/DoodleOnTouchGestureListener.java
...main/java/cn/hzw/doodle/DoodleOnTouchGestureListener.java
+5
-5
doodle/src/main/java/cn/hzw/doodle/DoodlePath.java
doodle/src/main/java/cn/hzw/doodle/DoodlePath.java
+5
-3
doodle/src/main/java/cn/hzw/doodle/DoodleRotatableItemBase.java
.../src/main/java/cn/hzw/doodle/DoodleRotatableItemBase.java
+19
-5
doodle/src/main/java/cn/hzw/doodle/DoodleSelectableItemBase.java
...src/main/java/cn/hzw/doodle/DoodleSelectableItemBase.java
+36
-12
doodle/src/main/java/cn/hzw/doodle/DoodleText.java
doodle/src/main/java/cn/hzw/doodle/DoodleText.java
+13
-2
doodle/src/main/java/cn/hzw/doodle/DoodleView.java
doodle/src/main/java/cn/hzw/doodle/DoodleView.java
+0
-6
doodle/src/main/java/cn/hzw/doodle/core/IDoodle.java
doodle/src/main/java/cn/hzw/doodle/core/IDoodle.java
+0
-2
doodle/src/main/java/cn/hzw/doodle/core/IDoodleItem.java
doodle/src/main/java/cn/hzw/doodle/core/IDoodleItem.java
+0
-2
doodle/src/main/java/cn/hzw/doodle/core/IDoodleSelectableItem.java
...c/main/java/cn/hzw/doodle/core/IDoodleSelectableItem.java
+8
-1
doodle/src/main/java/cn/hzw/doodle/dialog/ColorPickerDialog.java
...src/main/java/cn/hzw/doodle/dialog/ColorPickerDialog.java
+4
-17
doodle/src/main/java/cn/hzw/doodle/dialog/DialogController.java
.../src/main/java/cn/hzw/doodle/dialog/DialogController.java
+0
-6
doodle/src/main/java/cn/hzw/doodle/util/DrawUtil.java
doodle/src/main/java/cn/hzw/doodle/util/DrawUtil.java
+1
-1
doodle/src/main/res/drawable-xxhdpi/doodle_btn_add.png
doodle/src/main/res/drawable-xxhdpi/doodle_btn_add.png
+0
-0
doodle/src/main/res/drawable-xxhdpi/doodle_btn_sub.png
doodle/src/main/res/drawable-xxhdpi/doodle_btn_sub.png
+0
-0
doodle/src/main/res/drawable/doodle_btn_effect_round_pressed_yellow.xml
...n/res/drawable/doodle_btn_effect_round_pressed_yellow.xml
+0
-7
doodle/src/main/res/values-en/strings.xml
doodle/src/main/res/values-en/strings.xml
+0
-2
doodle/src/main/res/values/color.xml
doodle/src/main/res/values/color.xml
+0
-1
doodle/src/main/res/values/strings.xml
doodle/src/main/res/values/strings.xml
+0
-2
未找到文件。
app/src/main/res/layout/activity_main.xml
浏览文件 @
6a5938b1
...
...
@@ -41,7 +41,6 @@
android:background=
"@drawable/ic_launcher"
/>
<TextView
android:id=
"@+id/author"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center"
...
...
app/src/main/res/values/colors.xml
浏览文件 @
6a5938b1
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color
name=
"colorPrimary"
>
#3F51B5
</color>
<color
name=
"colorPrimaryDark"
>
#303F9F
</color>
<color
name=
"colorAccent"
>
#FF4081
</color>
</resources>
<resources></resources>
doodle/src/main/java/cn/hzw/doodle/CopyLocation.java
浏览文件 @
6a5938b1
...
...
@@ -110,10 +110,7 @@ public class CopyLocation {
* 判断是否点中
*/
public
boolean
contains
(
float
x
,
float
y
,
float
mPaintSize
)
{
if
((
mX
-
x
)
*
(
mX
-
x
)
+
(
mY
-
y
)
*
(
mY
-
y
)
<=
mPaintSize
*
mPaintSize
)
{
return
true
;
}
return
false
;
return
(
mX
-
x
)
*
(
mX
-
x
)
+
(
mY
-
y
)
*
(
mY
-
y
)
<=
mPaintSize
*
mPaintSize
;
}
public
CopyLocation
copy
()
{
...
...
doodle/src/main/java/cn/hzw/doodle/DoodleBitmap.java
浏览文件 @
6a5938b1
...
...
@@ -5,7 +5,6 @@ import android.graphics.Canvas;
import
android.graphics.Rect
;
import
cn.hzw.doodle.core.IDoodle
;
import
cn.hzw.doodle.core.IDoodleColor
;
/**
* 图片item
...
...
@@ -20,14 +19,27 @@ public class DoodleBitmap extends DoodleRotatableItemBase {
public
DoodleBitmap
(
IDoodle
doodle
,
Bitmap
bitmap
,
float
size
,
float
x
,
float
y
)
{
super
(
doodle
,
-
doodle
.
getDoodleRotation
(),
x
,
y
);
// 设置item旋转角度,使其在当前状态下显示为“无旋转”效果
setPivotX
(
x
);
setPivotY
(
y
);
this
.
mBitmap
=
bitmap
;
setSize
(
size
);
resetBounds
(
getBounds
());
}
public
void
setBitmap
(
Bitmap
bitmap
)
{
mBitmap
=
bitmap
;
resetBounds
(
getBounds
());
setPivotX
(
getLocation
().
x
+
getBounds
().
width
()
/
2
);
setPivotY
(
getLocation
().
y
+
getBounds
().
height
()
/
2
);
}
@Override
public
void
setSize
(
float
size
)
{
float
oldPivotX
=
getPivotX
();
float
oldPivotY
=
getPivotY
();
super
.
setSize
(
size
);
setPivotX
(
getLocation
().
x
+
getBounds
().
width
()
/
2
);
setPivotY
(
getLocation
().
y
+
getBounds
().
height
()
/
2
);
setLocation
(
getLocation
().
x
-
(
getPivotX
()
-
oldPivotX
),
getLocation
().
y
-
(
getPivotY
()
-
oldPivotY
));
}
public
Bitmap
getBitmap
()
{
...
...
doodle/src/main/java/cn/hzw/doodle/DoodleItemBase.java
浏览文件 @
6a5938b1
...
...
@@ -8,7 +8,6 @@ import cn.hzw.doodle.core.IDoodleColor;
import
cn.hzw.doodle.core.IDoodleItem
;
import
cn.hzw.doodle.core.IDoodlePen
;
import
cn.hzw.doodle.core.IDoodleShape
;
import
cn.hzw.doodle.util.DrawUtil
;
/**
* Created on 29/06/2018.
...
...
@@ -50,7 +49,6 @@ public abstract class DoodleItemBase implements IDoodleItem {
}
mDoodle
=
doodle
;
if
(
doodle
==
null
)
{
return
;
}
}
...
...
@@ -79,8 +77,6 @@ public abstract class DoodleItemBase implements IDoodleItem {
return
mPivotY
;
}
private
PointF
mPointF
=
new
PointF
();
@Override
public
void
setItemRotate
(
float
textRotate
)
{
mItemRotate
=
textRotate
;
...
...
@@ -92,10 +88,31 @@ public abstract class DoodleItemBase implements IDoodleItem {
return
mItemRotate
;
}
/**
* 默认改变相应的中心点位置
*
* @param x
* @param y
*/
@Override
public
void
setLocation
(
float
x
,
float
y
)
{
setLocation
(
x
,
y
,
true
);
}
/**
* @param x
* @param y
* @param changePivot 是否随着移动相应改变中心点的位置
*/
public
void
setLocation
(
float
x
,
float
y
,
boolean
changePivot
)
{
float
diffX
=
x
-
mLocation
.
x
,
diffY
=
y
-
mLocation
.
y
;
mLocation
.
x
=
x
;
mLocation
.
y
=
y
;
if
(
changePivot
)
{
mPivotX
=
mPivotX
+
diffX
;
mPivotY
=
mPivotY
+
diffY
;
}
refresh
();
}
...
...
@@ -152,9 +169,9 @@ public abstract class DoodleItemBase implements IDoodleItem {
public
void
draw
(
Canvas
canvas
)
{
canvas
.
save
();
mLocation
=
getLocation
();
// 获取旋转后的起始坐标
canvas
.
translate
(
mLocation
.
x
,
mLocation
.
y
);
//
把坐标系平移到文字
矩形范围
canvas
.
rotate
(
mItemRotate
,
0
,
0
);
// 旋转坐标系
canvas
.
translate
(
mLocation
.
x
,
mLocation
.
y
);
//
偏移,把坐标系平移到item
矩形范围
float
px
=
mPivotX
-
mLocation
.
x
,
py
=
mPivotY
-
mLocation
.
y
;
// 需要减去偏移
canvas
.
rotate
(
mItemRotate
,
px
,
py
);
// 旋转坐标系
doDraw
(
canvas
);
canvas
.
restore
();
...
...
doodle/src/main/java/cn/hzw/doodle/DoodleOnTouchGestureListener.java
浏览文件 @
6a5938b1
...
...
@@ -36,7 +36,7 @@ public class DoodleOnTouchGestureListener extends TouchGestureDetector.OnTouchGe
private
float
mSelectedItemX
,
mSelectedItemY
;
private
float
mRotate
TextDiff
;
// 开始旋转图片时的差值(当前图片
与触摸点的角度)
private
float
mRotate
Diff
;
// 开始旋转item时的差值(当前item的中心点
与触摸点的角度)
private
Path
mCurrPath
;
// 当前手写的路径
private
DoodlePath
mCurrDoodlePath
;
...
...
@@ -111,8 +111,8 @@ public class DoodleOnTouchGestureListener extends TouchGestureDetector.OnTouchGe
if
(
mSelectedItem
instanceof
DoodleRotatableItemBase
&&
(((
DoodleRotatableItemBase
)
mSelectedItem
).
canRotate
(
mDoodle
.
toX
(
mTouchX
),
mDoodle
.
toY
(
mTouchY
))))
{
((
DoodleRotatableItemBase
)
mSelectedItem
).
setIsRotating
(
true
);
mRotate
Text
Diff
=
mSelectedItem
.
getItemRotate
()
-
computeAngle
(
xy
.
x
,
xy
.
y
,
mDoodle
.
toX
(
mTouchX
),
mDoodle
.
toY
(
mTouchY
));
mRotateDiff
=
mSelectedItem
.
getItemRotate
()
-
computeAngle
(
mSelectedItem
.
getPivotX
(),
mSelectedItem
.
getPivotY
()
,
mDoodle
.
toX
(
mTouchX
),
mDoodle
.
toY
(
mTouchY
));
}
}
}
else
{
...
...
@@ -179,8 +179,8 @@ public class DoodleOnTouchGestureListener extends TouchGestureDetector.OnTouchGe
if
(
mSelectedItem
!=
null
)
{
if
((
mSelectedItem
instanceof
DoodleRotatableItemBase
)
&&
(((
DoodleRotatableItemBase
)
mSelectedItem
).
isRotating
()))
{
// 旋转item
PointF
xy
=
mSelectedItem
.
getLocation
();
mSelectedItem
.
setItemRotate
(
mRotate
Text
Diff
+
computeAngle
(
xy
.
x
,
xy
.
y
,
mDoodle
.
toX
(
mTouchX
),
mDoodle
.
toY
(
mTouchY
)
mSelectedItem
.
setItemRotate
(
mRotateDiff
+
computeAngle
(
mSelectedItem
.
getPivotX
(),
mSelectedItem
.
getPivotY
()
,
mDoodle
.
toX
(
mTouchX
),
mDoodle
.
toY
(
mTouchY
)
));
}
else
{
// 移动item
mSelectedItem
.
setLocation
(
...
...
doodle/src/main/java/cn/hzw/doodle/DoodlePath.java
浏览文件 @
6a5938b1
...
...
@@ -15,7 +15,7 @@ import cn.hzw.doodle.util.DrawUtil;
* Created by huangziwei on 2017/3/16.
*/
public
class
DoodlePath
extends
Doodle
Selec
tableItemBase
{
public
class
DoodlePath
extends
Doodle
Rota
tableItemBase
{
private
Path
mPath
;
// 画笔的路径
private
PointF
mSxy
=
new
PointF
();
// 映射后的起始坐标,(手指点击)
...
...
@@ -50,6 +50,7 @@ public class DoodlePath extends DoodleSelectableItemBase {
}
else
if
(
DoodleShape
.
FILL_RECT
.
equals
(
getShape
())
||
DoodleShape
.
HOLLOW_RECT
.
equals
(
getShape
()))
{
updateRectPath
(
mPath
,
mSxy
.
x
,
mSxy
.
y
,
mDxy
.
x
,
mDxy
.
y
,
getSize
());
}
// 改变中心点位置
mPath
.
computeBounds
(
mBound
,
false
);
setPivotX
(
mBound
.
left
);
setPivotY
(
mBound
.
top
);
...
...
@@ -58,9 +59,10 @@ public class DoodlePath extends DoodleSelectableItemBase {
public
void
updatePath
(
Path
path
)
{
this
.
mPath
=
path
;
if
(
mPath
!=
null
)
{
// 改变中心点位置
mPath
.
computeBounds
(
mBound
,
false
);
setPivotX
(
mBound
.
left
);
setPivotY
(
mBound
.
top
);
setPivotX
(
mBound
.
left
+
mBound
.
width
()
/
2
);
setPivotY
(
mBound
.
top
+
mBound
.
height
()
/
2
);
}
}
...
...
doodle/src/main/java/cn/hzw/doodle/DoodleRotatableItemBase.java
浏览文件 @
6a5938b1
...
...
@@ -31,10 +31,10 @@ public abstract class DoodleRotatableItemBase extends DoodleSelectableItemBase {
public
void
doDrawSelectedBackground
(
Canvas
canvas
)
{
mRectTemp
.
set
(
getBounds
());
float
unit
=
getDoodle
().
getUnitSize
();
mRectTemp
.
left
-=
10
*
unit
;
mRectTemp
.
top
-=
10
*
unit
;
mRectTemp
.
right
+=
10
*
unit
;
mRectTemp
.
bottom
+=
10
*
unit
;
mRectTemp
.
left
-=
ITEM_PADDING
*
unit
;
mRectTemp
.
top
-=
ITEM_PADDING
*
unit
;
mRectTemp
.
right
+=
ITEM_PADDING
*
unit
;
mRectTemp
.
bottom
+=
ITEM_PADDING
*
unit
;
mPaint
.
setShader
(
null
);
mPaint
.
setColor
(
0x33888888
);
mPaint
.
setStyle
(
Paint
.
Style
.
FILL
);
...
...
@@ -72,7 +72,21 @@ public abstract class DoodleRotatableItemBase extends DoodleSelectableItemBase {
canvas
.
drawLine
(
mRectTemp
.
right
,
mRectTemp
.
top
+
mRectTemp
.
height
()
/
2
,
mRectTemp
.
right
+
(
DoodleSelectableItemBase
.
ITEM_CAN_ROTATE_BOUND
-
16
)
*
unit
,
mRectTemp
.
top
+
mRectTemp
.
height
()
/
2
,
mPaint
);
canvas
.
drawCircle
(
mRectTemp
.
right
+
(
DoodleSelectableItemBase
.
ITEM_CAN_ROTATE_BOUND
-
8
)
*
unit
,
mRectTemp
.
top
+
mRectTemp
.
height
()
/
2
,
8
*
unit
,
mPaint
);
}
@Override
public
void
doDrawSelectedForeground
(
Canvas
canvas
)
{
float
unit
=
getDoodle
().
getUnitSize
();
// pivot
mPaint
.
setColor
(
0xffffffff
);
mPaint
.
setStrokeWidth
(
1
f
*
unit
);
mPaint
.
setStyle
(
Paint
.
Style
.
STROKE
);
// +
int
length
=
3
;
canvas
.
drawLine
(
getPivotX
()
-
getLocation
().
x
-
length
*
unit
,
getPivotY
()
-
getLocation
().
y
,
getPivotX
()
-
getLocation
().
x
+
length
*
unit
,
getPivotY
()
-
getLocation
().
y
,
mPaint
);
canvas
.
drawLine
(
getPivotX
()
-
getLocation
().
x
,
getPivotY
()
-
getLocation
().
y
-
length
*
unit
,
getPivotX
()
-
getLocation
().
x
,
getPivotY
()
-
getLocation
().
y
+
length
*
unit
,
mPaint
);
mPaint
.
setStyle
(
Paint
.
Style
.
FILL
);
canvas
.
drawCircle
(
getPivotX
()
-
getLocation
().
x
,
getPivotY
()
-
getLocation
().
y
,
unit
,
mPaint
);
}
/**
...
...
@@ -85,7 +99,7 @@ public abstract class DoodleRotatableItemBase extends DoodleSelectableItemBase {
x
=
x
-
location
.
x
;
y
=
y
-
location
.
y
;
// 把变换后矩形中的触摸点,还原回未变换前矩形中的点,然后判断是否矩形中
PointF
xy
=
rotatePoint
(
mTemp
,
(
int
)
-
getItemRotate
(),
x
,
y
,
0
,
0
);
PointF
xy
=
rotatePoint
(
mTemp
,
(
int
)
-
getItemRotate
(),
x
,
y
,
getPivotX
()
-
getLocation
().
x
,
getPivotY
()
-
getLocation
().
y
);
mRectTemp
.
set
(
getBounds
());
float
unit
=
doodle
.
getUnitSize
();
...
...
doodle/src/main/java/cn/hzw/doodle/DoodleSelectableItemBase.java
浏览文件 @
6a5938b1
...
...
@@ -17,7 +17,8 @@ import static cn.hzw.doodle.util.DrawUtil.rotatePoint;
public
abstract
class
DoodleSelectableItemBase
extends
DoodleItemBase
implements
IDoodleSelectableItem
{
public
final
static
int
ITEM_CAN_ROTATE_BOUND
=
70
;
public
final
static
int
ITEM_CAN_ROTATE_BOUND
=
35
;
public
final
static
int
ITEM_PADDING
=
5
;
// 绘制item矩形区域时增加的padding
private
Rect
mRect
=
new
Rect
();
private
Rect
mRectTemp
=
new
Rect
();
...
...
@@ -61,13 +62,13 @@ public abstract class DoodleSelectableItemBase extends DoodleItemBase implements
x
=
x
-
location
.
x
;
y
=
y
-
location
.
y
;
// 把变换后相对于矩形的触摸点,还原回未变换前的点,然后判断是否矩形中
mTemp
=
rotatePoint
(
mTemp
,
(
int
)
-
getItemRotate
(),
x
,
y
,
0
,
0
);
mTemp
=
rotatePoint
(
mTemp
,
(
int
)
-
getItemRotate
(),
x
,
y
,
getPivotX
()
-
getLocation
().
x
,
getPivotY
()
-
getLocation
().
y
);
mRectTemp
.
set
(
mRect
);
float
unit
=
getDoodle
().
getUnitSize
();
mRectTemp
.
left
-=
10
*
unit
;
mRectTemp
.
top
-=
10
*
unit
;
mRectTemp
.
right
+=
10
*
unit
;
mRectTemp
.
bottom
+=
10
*
unit
;
mRectTemp
.
left
-=
ITEM_PADDING
*
unit
;
mRectTemp
.
top
-=
ITEM_PADDING
*
unit
;
mRectTemp
.
right
+=
ITEM_PADDING
*
unit
;
mRectTemp
.
bottom
+=
ITEM_PADDING
*
unit
;
return
mRectTemp
.
contains
((
int
)
mTemp
.
x
,
(
int
)
mTemp
.
y
);
}
...
...
@@ -78,6 +79,13 @@ public abstract class DoodleSelectableItemBase extends DoodleItemBase implements
}
}
@Override
protected
void
drawAfter
(
Canvas
canvas
)
{
if
(
isSelected
())
{
drawSelectedForeground
(
canvas
);
}
}
/**
* 绘制选别时的背景
*
...
...
@@ -87,21 +95,33 @@ public abstract class DoodleSelectableItemBase extends DoodleItemBase implements
public
void
drawSelectedBackground
(
Canvas
canvas
)
{
canvas
.
save
();
PointF
location
=
getLocation
();
// 获取旋转后的起始坐标
canvas
.
translate
(
location
.
x
,
location
.
y
);
// 把坐标系平移到
文字
矩形范围
canvas
.
rotate
(
getItemRotate
(),
0
,
0
);
// 旋转坐标系
canvas
.
translate
(
location
.
x
,
location
.
y
);
// 把坐标系平移到
item
矩形范围
canvas
.
rotate
(
getItemRotate
(),
getPivotX
()
-
getLocation
().
x
,
getPivotY
()
-
getLocation
().
y
);
// 旋转坐标系
doDrawSelectedBackground
(
canvas
);
canvas
.
restore
();
}
@Override
public
void
drawSelectedForeground
(
Canvas
canvas
)
{
canvas
.
save
();
PointF
location
=
getLocation
();
// 获取旋转后的起始坐标
canvas
.
translate
(
location
.
x
,
location
.
y
);
// 把坐标系平移到item矩形范围
canvas
.
rotate
(
getItemRotate
(),
getPivotX
()
-
getLocation
().
x
,
getPivotY
()
-
getLocation
().
y
);
// 旋转坐标系
doDrawSelectedForeground
(
canvas
);
canvas
.
restore
();
}
public
void
doDrawSelectedBackground
(
Canvas
canvas
)
{
mRectTemp
.
set
(
getBounds
());
float
unit
=
getDoodle
().
getUnitSize
();
mRectTemp
.
left
-=
10
*
unit
;
mRectTemp
.
top
-=
10
*
unit
;
mRectTemp
.
right
+=
10
*
unit
;
mRectTemp
.
bottom
+=
10
*
unit
;
mRectTemp
.
left
-=
ITEM_PADDING
*
unit
;
mRectTemp
.
top
-=
ITEM_PADDING
*
unit
;
mRectTemp
.
right
+=
ITEM_PADDING
*
unit
;
mRectTemp
.
bottom
+=
ITEM_PADDING
*
unit
;
mPaint
.
setShader
(
null
);
mPaint
.
setColor
(
0x33888888
);
mPaint
.
setStyle
(
Paint
.
Style
.
FILL
);
...
...
@@ -119,6 +139,10 @@ public abstract class DoodleSelectableItemBase extends DoodleItemBase implements
canvas
.
drawRect
(
mRectTemp
,
mPaint
);
}
public
void
doDrawSelectedForeground
(
Canvas
canvas
)
{
}
@Override
public
boolean
isSelected
()
{
return
mIsSelected
;
...
...
doodle/src/main/java/cn/hzw/doodle/DoodleText.java
浏览文件 @
6a5938b1
...
...
@@ -21,10 +21,9 @@ public class DoodleText extends DoodleRotatableItemBase {
public
DoodleText
(
IDoodle
doodle
,
String
text
,
float
size
,
IDoodleColor
color
,
float
x
,
float
y
)
{
super
(
doodle
,
-
doodle
.
getDoodleRotation
(),
x
,
y
);
this
.
mText
=
text
;
mText
=
text
;
setSize
(
size
);
setColor
(
color
);
resetBounds
(
getBounds
());
}
public
String
getText
()
{
...
...
@@ -34,6 +33,18 @@ public class DoodleText extends DoodleRotatableItemBase {
public
void
setText
(
String
text
)
{
mText
=
text
;
resetBounds
(
getBounds
());
setPivotX
(
getLocation
().
x
+
getBounds
().
width
()
/
2
);
setPivotY
(
getLocation
().
y
-
getBounds
().
height
()
/
2
);
}
@Override
public
void
setSize
(
float
size
)
{
float
oldPivotX
=
getPivotX
();
float
oldPivotY
=
getPivotY
();
super
.
setSize
(
size
);
setPivotX
(
getLocation
().
x
+
getBounds
().
width
()
/
2
);
setPivotY
(
getLocation
().
y
-
getBounds
().
height
()
/
2
);
setLocation
(
getLocation
().
x
-
(
getPivotX
()
-
oldPivotX
),
getLocation
().
y
-
(
getPivotY
()
-
oldPivotY
));
}
@Override
...
...
doodle/src/main/java/cn/hzw/doodle/DoodleView.java
浏览文件 @
6a5938b1
...
...
@@ -63,7 +63,6 @@ public class DoodleView extends FrameLayout implements IDoodle {
private
float
mMinScale
=
MIN_SCALE
;
// 最小缩放倍数
private
float
mMaxScale
=
MAX_SCALE
;
// 最大缩放倍数
private
Paint
mPaint
;
private
float
mSize
;
private
IDoodleColor
mColor
;
// 画笔底色
...
...
@@ -127,11 +126,6 @@ public class DoodleView extends FrameLayout implements IDoodle {
mScale
=
1
f
;
mColor
=
new
DoodleColor
(
Color
.
RED
);
mPaint
=
new
Paint
();
mPaint
.
setStrokeWidth
(
mSize
);
mPaint
.
setAntiAlias
(
true
);
mPaint
.
setStrokeJoin
(
Paint
.
Join
.
ROUND
);
mPaint
.
setStrokeCap
(
Paint
.
Cap
.
ROUND
);
// 圆滑
mPen
=
DoodlePen
.
BRUSH
;
mShape
=
DoodleShape
.
HAND_WRITE
;
...
...
doodle/src/main/java/cn/hzw/doodle/core/IDoodle.java
浏览文件 @
6a5938b1
...
...
@@ -4,8 +4,6 @@ import android.graphics.Bitmap;
import
java.util.List
;
import
cn.hzw.doodle.DoodleColor
;
/**
* Created on 27/06/2018.
*/
...
...
doodle/src/main/java/cn/hzw/doodle/core/IDoodleItem.java
浏览文件 @
6a5938b1
...
...
@@ -3,8 +3,6 @@ package cn.hzw.doodle.core;
import
android.graphics.Canvas
;
import
android.graphics.PointF
;
import
cn.hzw.doodle.DoodleColor
;
/**
* Created on 27/06/2018.
*/
...
...
doodle/src/main/java/cn/hzw/doodle/core/IDoodleSelectableItem.java
浏览文件 @
6a5938b1
...
...
@@ -33,10 +33,17 @@ public interface IDoodleSelectableItem extends IDoodleItem {
public
boolean
contains
(
float
x
,
float
y
);
/**
* 绘制选
择
时的背景
* 绘制选
中
时的背景
*
* @param canvas
*/
public
void
drawSelectedBackground
(
Canvas
canvas
);
/**
* 绘制选中时的前景
*
* @param canvas
*/
public
void
drawSelectedForeground
(
Canvas
canvas
);
}
doodle/src/main/java/cn/hzw/doodle/dialog/ColorPickerDialog.java
浏览文件 @
6a5938b1
...
...
@@ -15,7 +15,6 @@ import android.util.Log;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.WindowManager
;
import
android.widget.ImageView
;
import
cn.forward.androids.utils.Util
;
...
...
@@ -68,7 +67,7 @@ public class ColorPickerDialog extends Dialog {
private
Paint
mLinePaint
;
//分隔线画笔
private
Paint
mRectPaint
;
//渐变方块画笔
private
Shader
rectShader
;
//渐变方块渐变图像
private
Shader
rectShader
;
//渐变方块渐变图像
private
float
rectLeft
;
//渐变方块左x坐标
private
float
rectTop
;
//渐变方块右x坐标
private
float
rectRight
;
//渐变方块上y坐标
...
...
@@ -259,11 +258,7 @@ public class ColorPickerDialog extends Dialog {
double
outCircle
=
Math
.
PI
*
outRadius
*
outRadius
;
double
inCircle
=
Math
.
PI
*
inRadius
*
inRadius
;
double
fingerCircle
=
Math
.
PI
*
(
x
*
x
+
y
*
y
);
if
(
fingerCircle
<
outCircle
&&
fingerCircle
>
inCircle
)
{
return
true
;
}
else
{
return
false
;
}
return
fingerCircle
<
outCircle
&&
fingerCircle
>
inCircle
;
}
/**
...
...
@@ -277,11 +272,7 @@ public class ColorPickerDialog extends Dialog {
private
boolean
inCenter
(
float
x
,
float
y
,
float
centerRadius
)
{
double
centerCircle
=
Math
.
PI
*
centerRadius
*
centerRadius
;
double
fingerCircle
=
Math
.
PI
*
(
x
*
x
+
y
*
y
);
if
(
fingerCircle
<
centerCircle
)
{
return
true
;
}
else
{
return
false
;
}
return
fingerCircle
<
centerCircle
;
}
/**
...
...
@@ -292,11 +283,7 @@ public class ColorPickerDialog extends Dialog {
* @return
*/
private
boolean
inRect
(
float
x
,
float
y
)
{
if
(
x
<=
rectRight
&&
x
>=
rectLeft
&&
y
<=
rectBottom
&&
y
>=
rectTop
)
{
return
true
;
}
else
{
return
false
;
}
return
x
<=
rectRight
&&
x
>=
rectLeft
&&
y
<=
rectBottom
&&
y
>=
rectTop
;
}
/**
...
...
doodle/src/main/java/cn/hzw/doodle/dialog/DialogController.java
浏览文件 @
6a5938b1
...
...
@@ -2,8 +2,6 @@ package cn.hzw.doodle.dialog;
import
android.app.Activity
;
import
android.app.Dialog
;
import
android.content.DialogInterface
;
import
android.graphics.Bitmap
;
import
android.text.Editable
;
import
android.text.Html
;
import
android.text.TextUtils
;
...
...
@@ -17,12 +15,8 @@ import android.widget.TextView;
import
java.util.List
;
import
cn.forward.androids.base.InjectionLayoutInflater
;
import
cn.forward.androids.utils.ImageUtils
;
import
cn.forward.androids.utils.StatusBarUtil
;
import
cn.hzw.doodle.DoodleBitmap
;
import
cn.hzw.doodle.DoodleText
;
import
cn.hzw.doodle.R
;
import
cn.hzw.doodle.core.IDoodleSelectableItem
;
import
cn.hzw.doodle.imagepicker.ImageSelectorView
;
import
cn.hzw.doodle.util.DrawUtil
;
...
...
doodle/src/main/java/cn/hzw/doodle/util/DrawUtil.java
浏览文件 @
6a5938b1
...
...
@@ -145,7 +145,7 @@ public class DrawUtil {
}
// 顺时针旋转
public
static
PointF
rotatePoint
(
PointF
coords
,
in
t
degree
,
float
x
,
float
y
,
float
px
,
float
py
)
{
public
static
PointF
rotatePoint
(
PointF
coords
,
floa
t
degree
,
float
x
,
float
y
,
float
px
,
float
py
)
{
if
(
degree
%
360
==
0
)
{
coords
.
x
=
x
;
coords
.
y
=
y
;
...
...
doodle/src/main/res/drawable-xxhdpi/doodle_btn_add.png
已删除
100644 → 0
浏览文件 @
637b45a0
3.0 KB
doodle/src/main/res/drawable-xxhdpi/doodle_btn_sub.png
已删除
100644 → 0
浏览文件 @
637b45a0
2.9 KB
doodle/src/main/res/drawable/doodle_btn_effect_round_pressed_yellow.xml
已删除
100644 → 0
浏览文件 @
637b45a0
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:drawable=
"@drawable/doodle_shape_circle_pressed"
android:state_pressed=
"true"
/>
<item
android:drawable=
"@drawable/doodle_shape_circle_pressed"
android:state_selected=
"true"
/>
<item
android:drawable=
"@drawable/doodle_shape_circle_pressed"
android:state_checked=
"true"
/>
</selector>
doodle/src/main/res/values-en/strings.xml
浏览文件 @
6a5938b1
...
...
@@ -6,8 +6,6 @@
<string
name=
"doodle_saving_picture"
>
Save before exit?
</string>
<string
name=
"doodle_enter"
>
Enter
</string>
<string
name=
"doodle_cancel"
>
Cancel
</string>
<string
name=
"doodle_success"
>
Success
</string>
<string
name=
"doodle_failed"
>
Failed
</string>
<string
name=
"doodle_edit"
>
Edit
</string>
<string
name=
"doodle_remove"
>
Delete
</string>
...
...
doodle/src/main/res/values/color.xml
浏览文件 @
6a5938b1
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color
name=
"doodle_btn_pressed_color"
>
#ffffd943
</color>
<color
name=
"doodle_btn_text"
>
#000000
</color>
<color
name=
"doodle_btn_border"
>
#88cccccc
</color>
</resources>
\ No newline at end of file
doodle/src/main/res/values/strings.xml
浏览文件 @
6a5938b1
...
...
@@ -6,8 +6,6 @@
<string
name=
"doodle_saving_picture"
>
保存图片
</string>
<string
name=
"doodle_enter"
>
确定
</string>
<string
name=
"doodle_cancel"
>
取消
</string>
<string
name=
"doodle_success"
>
成功
</string>
<string
name=
"doodle_failed"
>
失败
</string>
<string
name=
"doodle_edit"
>
编辑
</string>
<string
name=
"doodle_remove"
>
移除
</string>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录