aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/api/canvasrenderingcontext2d/miterlimit/index.html
blob: f22e3924499c0ed04b6e02213ad2d25cc4509b6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
title: CanvasRenderingContext2D.miterLimit
slug: Web/API/CanvasRenderingContext2D/miterLimit
translation_of: Web/API/CanvasRenderingContext2D/miterLimit
---
<div>{{APIRef}}</div>

<p>Свойство <strong>CanvasRenderingContext2D.miterLimit</strong> устанавливает/возвращает максимальную длину среза.</p>

<p>Длина среза это расстояние между внутренним и внешнем углом, образованным пересечением двух линий.</p>

<div class="note">
<p>For more info about miters, see <a href="/en-US/docs/Web/API/Canvas_API/Tutorial/Applying_styles_and_colors">Applying styles and color</a> in the <a href="/en-US/docs/Web/API/Canvas_API/Tutorial">Canvas tutorial</a>.</p>
</div>

<h2 id="Синтаксис">Синтаксис</h2>

<pre class="syntaxbox"><em>ctx</em>.miterLimit = <em>число</em>;</pre>

<h3 id="Options">Options</h3>

<dl>
 <dt><code>число</code></dt>
 <dd>Положительное число, определяющее максимальную длину среза. Если текущая длина среза будет превышать заданное значение, то угол будет отображаться как при значении <code>bevel</code> свойства <code>lineJoin</code>.</dd>
</dl>

<h2 id="Примеры">Примеры</h2>

<h3 id="Using_the_miterLimit_property">Using the <code>miterLimit</code> property</h3>

<p>See the chapter <a href="https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Applying_styles_and_colors#A_demo_of_the_miterLimit_property">Applying styles and color</a> in the <a href="/en-US/docs/Web/API/Canvas_API/Tutorial">Canvas tutorial</a> for more information.</p>

<div class="hidden">
<h6 id="Playable_code">Playable code</h6>

<pre class="brush: html">&lt;canvas id="canvas" width="400" height="200" class="playable-canvas"&gt;&lt;/canvas&gt;
&lt;div class="playable-buttons"&gt;
  &lt;input id="edit" type="button" value="Edit" /&gt;
  &lt;input id="reset" type="button" value="Reset" /&gt;
&lt;/div&gt;
&lt;textarea id="code" class="playable-code"&gt;
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineWidth = 15;
ctx.lineTo(100, 100);
ctx.stroke();&lt;/textarea&gt;
</pre>

<pre class="brush: js">var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var textarea = document.getElementById("code");
var reset = document.getElementById("reset");
var edit = document.getElementById("edit");
var code = textarea.value;

function drawCanvas() {
  ctx.clearRect(0, 0, canvas.width, canvas.height);
  eval(textarea.value);
}

reset.addEventListener("click", function() {
  textarea.value = code;
  drawCanvas();
});

edit.addEventListener("click", function() {
  textarea.focus();
})

textarea.addEventListener("input", drawCanvas);
window.addEventListener("load", drawCanvas);
</pre>
</div>

<p>{{EmbedLiveSample("A_demo_of_the_miterLimit_property", "400", "180", "https://mdn.mozillademos.org/files/240/Canvas_miterlimit.png", "Web/API/Canvas_API/Tutorial/Applying_styles_and_colors")}}</p>

<h2 id="Спецификации">Спецификации</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG', "scripting.html#dom-context-2d-miterlimit", "CanvasRenderingContext2D.miterLimit")}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td></td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>



<p>{{Compat("api.CanvasRenderingContext2D.miterLimit")}}</p>

<h3 id="WebKitBlink-specific_notes">WebKit/Blink-specific notes</h3>

<ul>
 <li>In WebKit- and Blink-based Browsers, a non-standard and deprecated method <code>ctx.setMiterLimit()</code> is implemented in addition to this property.</li>
</ul>

<h3 id="Gecko-specific_notes">Gecko-specific notes</h3>

<ul>
 <li>Starting Gecko 2.0 {{geckoRelease("2.0")}}, setting <code>miterLimit</code> to a negative value no longer throws an exception; instead, it properly ignores non-positive values.</li>
</ul>

<h2 id="See_also">See also</h2>

<ul>
 <li>Интерфейс, определяющий это свойство: {{domxref("CanvasRenderingContext2D")}}</li>
 <li>{{domxref("CanvasRenderingContext2D.lineCap")}}</li>
 <li>{{domxref("CanvasRenderingContext2D.lineJoin")}}</li>
</ul>