From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../shadowoffsety/index.html | 166 +++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 files/zh-cn/web/api/canvasrenderingcontext2d/shadowoffsety/index.html (limited to 'files/zh-cn/web/api/canvasrenderingcontext2d/shadowoffsety') diff --git a/files/zh-cn/web/api/canvasrenderingcontext2d/shadowoffsety/index.html b/files/zh-cn/web/api/canvasrenderingcontext2d/shadowoffsety/index.html new file mode 100644 index 0000000000..61a9bc37a1 --- /dev/null +++ b/files/zh-cn/web/api/canvasrenderingcontext2d/shadowoffsety/index.html @@ -0,0 +1,166 @@ +--- +title: CanvasRenderingContext2D.shadowOffsetY +slug: Web/API/CanvasRenderingContext2D/shadowOffsetY +translation_of: Web/API/CanvasRenderingContext2D/shadowOffsetY +--- +
{{APIRef}}
+ +

CanvasRenderingContext2D.shadowOffsetY 是 Canvas 2D API 描述阴影垂直偏移距离的属性。

+ +

语法

+ +
ctx.shadowOffsetY = offset;
+
+ +
+
offset
+
阴影垂直偏移距离的float类型的值。 默认值是 0。  {{jsxref("Infinity")}} 或者{{jsxref("NaN")}} 都会被忽略。
+
+ +

示例

+ +

使用 shadowOffsetY 属性

+ +

这是一段简单的代码片段,使用 shadowOffsetY 属性绘制阴影垂直偏移量。注意:将shadowColor属性设置成不透明,阴影才会被绘制。

+ +

HTML

+ +
<canvas id="canvas"></canvas>
+
+ +

JavaScript

+ +
var canvas = document.getElementById("canvas");
+var ctx = canvas.getContext("2d");
+
+ctx.shadowColor = "black";
+ctx.shadowOffsetY = 10;
+ctx.shadowBlur = 10;
+
+ctx.fillStyle = "green";
+ctx.fillRect(10, 10, 100, 100);
+
+ +

修改下面的代码并在线查看 canvas 的变化:

+ + + +

{{ EmbedLiveSample('Playable_code', 700, 360) }}

+ +

规范描述

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "scripting.html#dom-context-2d-shadowoffsety", "CanvasRenderingContext2D.shadowOffsetY")}}{{Spec2('HTML WHATWG')}} 
+ +

浏览器兼容性

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
+
+ +

参见

+ + -- cgit v1.2.3-54-g00ecf