Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
anyefeiyu
uni-app
提交
540d65e2
U
uni-app
项目概览
anyefeiyu
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
540d65e2
编写于
3月 27, 2019
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 增加CanvasContext相关属性支持
上级
86e16f4f
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
145 addition
and
1 deletion
+145
-1
src/core/service/api/context/canvas.js
src/core/service/api/context/canvas.js
+144
-0
src/platforms/h5/components/page/transparent.js
src/platforms/h5/components/page/transparent.js
+1
-1
未找到文件。
src/core/service/api/context/canvas.js
浏览文件 @
540d65e2
...
...
@@ -434,6 +434,150 @@ class CanvasContext {
this
.
clearActions
()
return
actions
}
set
lineDashOffset
(
value
)
{
this
.
actions
.
push
({
method
:
'
setLineDashOffset
'
,
data
:
[
value
]
})
}
set
globalCompositeOperation
(
type
)
{
this
.
actions
.
push
({
method
:
'
setGlobalCompositeOperation
'
,
data
:
[
type
]
})
}
set
shadowBlur
(
level
)
{
this
.
actions
.
push
({
method
:
'
setShadowBlur
'
,
data
:
[
level
]
})
}
set
shadowColor
(
color
)
{
this
.
actions
.
push
({
method
:
'
setShadowColor
'
,
data
:
[
color
]
})
}
set
shadowOffsetX
(
x
)
{
this
.
actions
.
push
({
method
:
'
setShadowOffsetX
'
,
data
:
[
x
]
})
}
set
shadowOffsetY
(
y
)
{
this
.
actions
.
push
({
method
:
'
setShadowOffsetY
'
,
data
:
[
y
]
})
}
set
font
(
value
)
{
var
self
=
this
this
.
state
.
font
=
value
// eslint-disable-next-line
var
fontFormat
=
value
.
match
(
/^
(([\w\-]
+
\s)
*
)(\d
+r
?
px
)(\/(\d
+
\.?\d
*
(
r
?
px
)?))?\s
+
(
.*
)
/
)
if
(
fontFormat
)
{
var
style
=
fontFormat
[
1
].
trim
().
split
(
/
\s
/
)
var
fontSize
=
parseFloat
(
fontFormat
[
3
])
var
fontFamily
=
fontFormat
[
7
]
var
actions
=
[]
style
.
forEach
(
function
(
value
,
index
)
{
if
([
'
italic
'
,
'
oblique
'
,
'
normal
'
].
indexOf
(
value
)
>
-
1
)
{
actions
.
push
({
method
:
'
setFontStyle
'
,
data
:
[
value
]
})
self
.
state
.
fontStyle
=
value
}
else
if
([
'
bold
'
,
'
normal
'
].
indexOf
(
value
)
>
-
1
)
{
actions
.
push
({
method
:
'
setFontWeight
'
,
data
:
[
value
]
})
self
.
state
.
fontWeight
=
value
}
else
if
(
index
===
0
)
{
actions
.
push
({
method
:
'
setFontStyle
'
,
data
:
[
'
normal
'
]
})
self
.
state
.
fontStyle
=
'
normal
'
}
else
if
(
index
===
1
)
{
pushAction
()
}
})
if
(
style
.
length
===
1
)
{
pushAction
()
}
style
=
actions
.
map
(
function
(
action
)
{
return
action
.
data
[
0
]
}).
join
(
'
'
)
this
.
state
.
fontSize
=
fontSize
this
.
state
.
fontFamily
=
fontFamily
this
.
actions
.
push
({
method
:
'
setFont
'
,
data
:
[
`
${
style
}
${
fontSize
}
px
${
fontFamily
}
`
]
})
}
else
{
console
.
warn
(
"
Failed to set 'font' on 'CanvasContext': invalid format.
"
)
}
function
pushAction
()
{
actions
.
push
({
method
:
'
setFontWeight
'
,
data
:
[
'
normal
'
]
})
self
.
state
.
fontWeight
=
'
normal
'
}
}
get
font
()
{
return
this
.
state
.
font
}
set
fillStyle
(
color
)
{
this
.
setFillStyle
(
color
)
}
set
strokeStyle
(
color
)
{
this
.
setStrokeStyle
(
color
)
}
set
globalAlpha
(
value
)
{
value
=
Math
.
floor
(
255
*
parseFloat
(
value
))
this
.
actions
.
push
({
method
:
'
setGlobalAlpha
'
,
data
:
[
value
]
})
}
set
textAlign
(
align
)
{
this
.
actions
.
push
({
method
:
'
setTextAlign
'
,
data
:
[
align
]
})
}
set
lineCap
(
type
)
{
this
.
actions
.
push
({
method
:
'
setLineCap
'
,
data
:
[
type
]
})
}
set
lineJoin
(
type
)
{
this
.
actions
.
push
({
method
:
'
setLineJoin
'
,
data
:
[
type
]
})
}
set
lineWidth
(
value
)
{
this
.
actions
.
push
({
method
:
'
setLineWidth
'
,
data
:
[
value
]
})
}
set
miterLimit
(
value
)
{
this
.
actions
.
push
({
method
:
'
setMiterLimit
'
,
data
:
[
value
]
})
}
set
textBaseline
(
type
)
{
this
.
actions
.
push
({
method
:
'
setTextBaseline
'
,
data
:
[
type
]
})
}
}
[...
methods1
,
...
methods2
].
forEach
(
function
(
method
)
{
...
...
src/platforms/h5/components/page/transparent.js
浏览文件 @
540d65e2
...
...
@@ -46,7 +46,7 @@ export default {
transparentElemStyle
.
backgroundColor
=
`rgba(
${
this
.
_R
}
,
${
this
.
_G
}
,
${
this
.
_B
}
,
${
alpha
}
)`
borderRadiusElemsStyles
.
forEach
(
function
(
borderRadiusElemStyle
,
index
)
{
let
oldColor
=
oldColors
[
index
]
/
* eslint-disable */
/
/ eslint-disable-next-line
let
rgba
=
oldColor
.
match
(
/
[\d
+
\.]
+/g
)
rgba
[
3
]
=
(
1
-
alpha
)
*
(
rgba
.
length
===
4
?
rgba
[
3
]
:
1
)
borderRadiusElemStyle
.
backgroundColor
=
`rgba(
${
rgba
}
)`
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录