Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
2c45d350
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2c45d350
编写于
7月 21, 2017
作者:
M
Michel Kaporin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add fromHSLA and fromHex methods to API
上级
04908183
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
50 addition
and
15 deletion
+50
-15
src/vs/editor/contrib/colorPicker/browser/elements/colorPickerBody.ts
...r/contrib/colorPicker/browser/elements/colorPickerBody.ts
+10
-9
src/vs/editor/contrib/hover/browser/modesContentHover.ts
src/vs/editor/contrib/hover/browser/modesContentHover.ts
+20
-0
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+2
-2
src/vs/workbench/api/node/extHostTypes.ts
src/vs/workbench/api/node/extHostTypes.ts
+18
-4
未找到文件。
src/vs/editor/contrib/colorPicker/browser/elements/colorPickerBody.ts
浏览文件 @
2c45d350
...
...
@@ -219,8 +219,9 @@ export class ColorPickerBody extends Disposable {
export
class
SaturationBox
{
public
domNode
:
HTMLElement
;
public
saturationSelection
:
HTMLElement
;
private
saturationCanvas
:
HTMLCanvasElement
;
private
saturationCtx
:
CanvasRenderingContext2D
;
private
whiteGradient
:
CanvasGradient
;
...
...
@@ -230,24 +231,24 @@ export class SaturationBox {
this
.
domNode
=
$
(
'
.saturation-wrap
'
);
dom
.
append
(
widgetNode
,
this
.
domNode
);
// Create canvas, draw selected color
this
.
saturationCanvas
=
document
.
createElement
(
'
canvas
'
);
this
.
saturationCanvas
.
className
=
'
saturation-box
'
;
dom
.
append
(
this
.
domNode
,
this
.
saturationCanvas
);
// Add selection circle
this
.
saturationSelection
=
$
(
'
.saturation-selection
'
);
dom
.
append
(
this
.
domNode
,
this
.
saturationSelection
);
}
public
layout
():
void
{
// Create canvas, draw selected color
const
canvas
=
document
.
createElement
(
'
canvas
'
);
canvas
.
className
=
'
saturation-box
'
;
dom
.
append
(
this
.
domNode
,
canvas
);
const
actualW
=
this
.
domNode
.
offsetWidth
*
this
.
pixelRatio
,
actualH
=
this
.
domNode
.
offsetHeight
*
this
.
pixelRatio
;
c
anvas
.
width
=
actualW
;
c
anvas
.
height
=
actualH
;
this
.
saturationC
anvas
.
width
=
actualW
;
this
.
saturationC
anvas
.
height
=
actualH
;
this
.
saturationCtx
=
c
anvas
.
getContext
(
'
2d
'
);
this
.
saturationCtx
=
this
.
saturationC
anvas
.
getContext
(
'
2d
'
);
this
.
saturationCtx
.
rect
(
0
,
0
,
actualW
,
actualH
);
// Create black and white gradients on top
...
...
src/vs/editor/contrib/hover/browser/modesContentHover.ts
浏览文件 @
2c45d350
...
...
@@ -225,6 +225,9 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
this
.
_highlightDecorations
=
this
.
_editor
.
deltaDecorations
(
this
.
_highlightDecorations
,
[]);
this
.
_isChangingDecorations
=
false
;
this
.
_colorPicker
=
null
;
if
(
this
.
_colorPicker
)
{
this
.
_colorPicker
.
dispose
();
}
}
_withResult
(
result
:
Hover
[],
complete
:
boolean
):
void
{
...
...
@@ -237,6 +240,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
}
}
private
l
=
true
;
private
_renderMessages
(
renderRange
:
Range
,
messages
:
Hover
[]):
void
{
// update column from which to show
...
...
@@ -309,6 +313,22 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
options
:
ModesContentHoverWidget
.
_DECORATION_OPTIONS
}]);
this
.
_isChangingDecorations
=
false
;
if
(
this
.
l
)
{
this
.
l
=
false
;
this
.
_renderMessages
(
new
Range
(
4
,
5
,
4
,
5
),
[{
contents
:
[{
language
:
'
css
'
,
value
:
'
asdasdasdasdadasdsdasdasdasdadasdsdasdasdasdadasdsdasdasdasdadasdsdasdasdasdadasdsdasdasdasdadasd
'
}],
range
:
{
endColumn
:
10
,
endLineNumber
:
5
,
startColumn
:
1
,
startLineNumber
:
5
}
}]);
}
}
private
static
_DECORATION_OPTIONS
=
ModelDecorationOptions
.
register
({
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
2c45d350
...
...
@@ -261,8 +261,8 @@ declare module 'vscode' {
constructor
(
red
:
number
,
green
:
number
,
blue
:
number
,
alpha
?:
number
);
// static fromHSL(h, s, l
): Color;
// static fromHex(hex
): Color;
static
fromHSLA
(
hue
:
number
,
saturation
:
number
,
luminosity
:
number
,
alpha
?:
number
):
Color
;
static
fromHex
(
hex
:
string
):
Color
;
}
// TODO@Michel
...
...
src/vs/workbench/api/node/extHostTypes.ts
浏览文件 @
2c45d350
...
...
@@ -7,6 +7,7 @@
import
*
as
crypto
from
'
crypto
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
Color
as
CommonColor
,
HSLA
}
from
'
vs/base/common/color
'
;
import
{
illegalArgument
}
from
'
vs/base/common/errors
'
;
import
*
as
vscode
from
'
vscode
'
;
...
...
@@ -1016,10 +1017,10 @@ export class DocumentLink {
}
export
class
Color
{
red
:
number
;
green
:
number
;
blue
:
number
;
alpha
:
number
;
re
adonly
re
d
:
number
;
readonly
green
:
number
;
readonly
blue
:
number
;
readonly
alpha
:
number
;
constructor
(
red
:
number
,
green
:
number
,
blue
:
number
,
alpha
?:
number
)
{
this
.
red
=
red
;
...
...
@@ -1027,6 +1028,19 @@ export class Color {
this
.
blue
=
blue
;
this
.
alpha
=
alpha
;
}
static
fromHSLA
(
hue
:
number
,
saturation
:
number
,
luminosity
:
number
,
alpha
?:
number
):
Color
{
if
(
!
alpha
)
{
alpha
=
1
;
}
const
color
=
CommonColor
.
fromHSLA
(
new
HSLA
(
hue
,
saturation
,
luminosity
,
alpha
)).
toRGBA
();
return
new
Color
(
color
.
r
,
color
.
g
,
color
.
b
,
color
.
a
/
255
);
}
static
fromHex
(
hex
:
string
):
Color
{
const
color
=
CommonColor
.
fromHex
(
hex
).
toRGBA
();
return
new
Color
(
color
.
r
,
color
.
g
,
color
.
b
,
color
.
a
/
255
);
}
}
export
class
ColorInfo
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录