Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_34031325
engine
提交
f1d3d84f
E
engine
项目概览
qq_34031325
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f1d3d84f
编写于
10月 17, 2017
作者:
C
Chinmay Garde
提交者:
GitHub
10月 17, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Expose SkPath::arcTo and SkPath::rArcTo to Dart. (#4222)
上级
faaf321b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
131 addition
and
18 deletion
+131
-18
lib/ui/painting.dart
lib/ui/painting.dart
+64
-0
lib/ui/painting/path.cc
lib/ui/painting/path.cc
+53
-18
lib/ui/painting/path.h
lib/ui/painting/path.h
+14
-0
未找到文件。
lib/ui/painting.dart
浏览文件 @
f1d3d84f
...
...
@@ -34,6 +34,12 @@ bool _offsetIsValid(Offset offset) {
return
true
;
}
bool
_radiusIsValid
(
Radius
radius
)
{
assert
(
radius
!=
null
,
'Radius argument was null.'
);
assert
(!
radius
.
x
.
isNaN
&&
!
radius
.
y
.
isNaN
,
'Radius argument contained a NaN value.'
);
return
true
;
}
Color
_scaleAlpha
(
Color
a
,
double
factor
)
{
return
a
.
withAlpha
((
a
.
alpha
*
factor
).
round
().
clamp
(
0
,
255
));
}
...
...
@@ -860,6 +866,64 @@ class Path extends NativeFieldWrapperClass2 {
void
_arcTo
(
double
left
,
double
top
,
double
right
,
double
bottom
,
double
startAngle
,
double
sweepAngle
,
bool
forceMoveTo
)
native
"Path_arcTo"
;
/// Appends up to four conic curves weighted to describe an oval of [radius]
/// and rotated by [rotation].
///
/// The first curve begins from the last point in the path and the last ends
/// at [arcEnd]. The curves follow a path in a direction determined by
/// [clockwise] and [largeArc] in such a way that the sweep angle
/// is always less than 360 degrees.
///
/// A simple line is appended if either either radii are zero or the last
/// point in the path is [arcEnd]. The radii are scaled to fit the last path
/// point if both are greater than zero but too small to describe an arc.
///
void
arcToPoint
(
Offset
arcEnd
,
{
Radius
radius:
Radius
.
zero
,
double
rotation:
0.0
,
bool
largeArc:
false
,
bool
clockwise:
true
,
})
{
assert
(
_offsetIsValid
(
arcEnd
));
assert
(
_radiusIsValid
(
radius
));
_arcToPoint
(
arcEnd
.
dx
,
arcEnd
.
dy
,
radius
.
x
,
radius
.
y
,
rotation
,
largeArc
,
clockwise
);
}
void
_arcToPoint
(
double
arcEndX
,
double
arcEndY
,
double
radiusX
,
double
radiusY
,
double
rotation
,
bool
largeArc
,
bool
clockwise
)
native
"Path_arcToPoint"
;
/// Appends up to four conic curves weighted to describe an oval of [radius]
/// and rotated by [rotation].
///
/// The last path point is described by (px, py).
///
/// The first curve begins from the last point in the path and the last ends
/// at [arcEndDelta].dx + px and [arcEndDelta].dy + py. The curves follow a
/// path in a direction determined by [clockwise] and [largeArc]
/// in such a way that the sweep angle is always less than 360 degrees.
///
/// A simple line is appended if either either radii are zero, or, both
/// [arcEndDelta].dx and [arcEndDelta].dy are zero. The radii are scaled to
/// fit the last path point if both are greater than zero but too small to
/// describe an arc.
void
relativeArcToPoint
(
Offset
arcEndDelta
,
{
Radius
radius:
Radius
.
zero
,
double
rotation:
0.0
,
bool
largeArc:
false
,
bool
clockwise:
true
,
})
{
assert
(
_offsetIsValid
(
arcEndDelta
));
assert
(
_radiusIsValid
(
radius
));
_relativeArcToPoint
(
arcEndDelta
.
dx
,
arcEndDelta
.
dy
,
radius
.
x
,
radius
.
y
,
rotation
,
largeArc
,
clockwise
);
}
void
_relativeArcToPoint
(
double
arcEndX
,
double
arcEndY
,
double
radiusX
,
double
radiusY
,
double
rotation
,
bool
largeArc
,
bool
clockwise
)
native
"Path_relativeArcToPoint"
;
/// Adds a new subpath that consists of four lines that outline the
/// given rectangle.
void
addRect
(
Rect
rect
)
{
...
...
lib/ui/painting/path.cc
浏览文件 @
f1d3d84f
...
...
@@ -25,29 +25,31 @@ static void Path_constructor(Dart_NativeArguments args) {
IMPLEMENT_WRAPPERTYPEINFO
(
ui
,
Path
);
#define FOR_EACH_BINDING(V) \
V(Path, getFillType) \
V(Path, setFillType) \
V(Path, moveTo) \
V(Path, relativeMoveTo) \
V(Path, lineTo) \
V(Path, relativeLineTo) \
V(Path, quadraticBezierTo) \
V(Path, relativeQuadraticBezierTo) \
V(Path, cubicTo) \
V(Path, relativeCubicTo) \
V(Path, conicTo) \
V(Path, relativeConicTo) \
V(Path, arcTo) \
V(Path, addRect) \
V(Path, addOval) \
V(Path, addArc) \
V(Path, addOval) \
V(Path, addPath) \
V(Path, addPolygon) \
V(Path, addRect) \
V(Path, addRRect) \
V(Path, a
ddPath)
\
V(Path,
extendWithPath)
\
V(Path, a
rcTo)
\
V(Path,
arcToPoint)
\
V(Path, close) \
V(Path,
reset)
\
V(Path,
conicTo)
\
V(Path, contains) \
V(Path, cubicTo) \
V(Path, extendWithPath) \
V(Path, getFillType) \
V(Path, lineTo) \
V(Path, moveTo) \
V(Path, quadraticBezierTo) \
V(Path, relativeArcToPoint) \
V(Path, relativeConicTo) \
V(Path, relativeCubicTo) \
V(Path, relativeLineTo) \
V(Path, relativeMoveTo) \
V(Path, relativeQuadraticBezierTo) \
V(Path, reset) \
V(Path, setFillType) \
V(Path, shift) \
V(Path, transform)
...
...
@@ -139,6 +141,39 @@ void CanvasPath::arcTo(float left,
forceMoveTo
);
}
void
CanvasPath
::
arcToPoint
(
float
arcEndX
,
float
arcEndY
,
float
radiusX
,
float
radiusY
,
float
xAxisRotation
,
bool
isLargeArc
,
bool
isClockwiseDirection
)
{
const
auto
arcSize
=
isLargeArc
?
SkPath
::
ArcSize
::
kLarge_ArcSize
:
SkPath
::
ArcSize
::
kSmall_ArcSize
;
const
auto
direction
=
isClockwiseDirection
?
SkPath
::
Direction
::
kCW_Direction
:
SkPath
::
Direction
::
kCCW_Direction
;
path_
.
arcTo
(
radiusX
,
radiusY
,
xAxisRotation
,
arcSize
,
direction
,
arcEndX
,
arcEndY
);
}
void
CanvasPath
::
relativeArcToPoint
(
float
arcEndDeltaX
,
float
arcEndDeltaY
,
float
radiusX
,
float
radiusY
,
float
xAxisRotation
,
bool
isLargeArc
,
bool
isClockwiseDirection
)
{
const
auto
arcSize
=
isLargeArc
?
SkPath
::
ArcSize
::
kLarge_ArcSize
:
SkPath
::
ArcSize
::
kSmall_ArcSize
;
const
auto
direction
=
isClockwiseDirection
?
SkPath
::
Direction
::
kCW_Direction
:
SkPath
::
Direction
::
kCCW_Direction
;
path_
.
rArcTo
(
radiusX
,
radiusY
,
xAxisRotation
,
arcSize
,
direction
,
arcEndDeltaX
,
arcEndDeltaY
);
}
void
CanvasPath
::
addRect
(
float
left
,
float
top
,
float
right
,
float
bottom
)
{
path_
.
addRect
(
SkRect
::
MakeLTRB
(
left
,
top
,
right
,
bottom
));
}
...
...
lib/ui/painting/path.h
浏览文件 @
f1d3d84f
...
...
@@ -53,6 +53,20 @@ class CanvasPath : public fxl::RefCountedThreadSafe<CanvasPath>,
float
startAngle
,
float
sweepAngle
,
bool
forceMoveTo
);
void
arcToPoint
(
float
arcEndX
,
float
arcEndY
,
float
radiusX
,
float
radiusY
,
float
xAxisRotation
,
bool
isLargeArc
,
bool
isClockwiseDirection
);
void
relativeArcToPoint
(
float
arcEndDeltaX
,
float
arcEndDeltaY
,
float
radiusX
,
float
radiusY
,
float
xAxisRotation
,
bool
isLargeArc
,
bool
isClockwiseDirection
);
void
addRect
(
float
left
,
float
top
,
float
right
,
float
bottom
);
void
addOval
(
float
left
,
float
top
,
float
right
,
float
bottom
);
void
addArc
(
float
left
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录