|
Last change
on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Prototype 1.1
|
-
Property mode
set to
100644
|
|
File size:
920 bytes
|
| Line | |
|---|
| 1 | import {tau} from "../math.js";
|
|---|
| 2 | import noop from "../noop.js";
|
|---|
| 3 |
|
|---|
| 4 | export default function PathContext(context) {
|
|---|
| 5 | this._context = context;
|
|---|
| 6 | }
|
|---|
| 7 |
|
|---|
| 8 | PathContext.prototype = {
|
|---|
| 9 | _radius: 4.5,
|
|---|
| 10 | pointRadius: function(_) {
|
|---|
| 11 | return this._radius = _, this;
|
|---|
| 12 | },
|
|---|
| 13 | polygonStart: function() {
|
|---|
| 14 | this._line = 0;
|
|---|
| 15 | },
|
|---|
| 16 | polygonEnd: function() {
|
|---|
| 17 | this._line = NaN;
|
|---|
| 18 | },
|
|---|
| 19 | lineStart: function() {
|
|---|
| 20 | this._point = 0;
|
|---|
| 21 | },
|
|---|
| 22 | lineEnd: function() {
|
|---|
| 23 | if (this._line === 0) this._context.closePath();
|
|---|
| 24 | this._point = NaN;
|
|---|
| 25 | },
|
|---|
| 26 | point: function(x, y) {
|
|---|
| 27 | switch (this._point) {
|
|---|
| 28 | case 0: {
|
|---|
| 29 | this._context.moveTo(x, y);
|
|---|
| 30 | this._point = 1;
|
|---|
| 31 | break;
|
|---|
| 32 | }
|
|---|
| 33 | case 1: {
|
|---|
| 34 | this._context.lineTo(x, y);
|
|---|
| 35 | break;
|
|---|
| 36 | }
|
|---|
| 37 | default: {
|
|---|
| 38 | this._context.moveTo(x + this._radius, y);
|
|---|
| 39 | this._context.arc(x, y, this._radius, 0, tau);
|
|---|
| 40 | break;
|
|---|
| 41 | }
|
|---|
| 42 | }
|
|---|
| 43 | },
|
|---|
| 44 | result: noop
|
|---|
| 45 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.