Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 36x 36x 36x 36x 36x 36x 36x 36x 304x 304x 304x 304x 304x 304x 36x 136x 136x 544x 544x 544x 544x 544x 544x 544x 136x 136x 36x 36x 12x 12x 12x 12x 12x 12x 12x 36x 124x 124x 124x 124x 124x 36x 147x 147x 147x 147x 147x 147x 147x 147x 147x 137x 144x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 147x 147x 36x 36x 12x 12x 12x 12x 36x 36x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 36x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 36x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 36x 1x 1x | /*
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/
*
* Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
* http://juerglehni.com/ & https://puckey.studio/
*
* Distributed under the MIT license. See LICENSE file for details.
*
* All rights reserved.
*/
// TODO: remove eslint-disable comment and deal with errors over time
/* eslint-disable */
import { Point } from '~/basic/Point';
import { Rectangle } from '~/basic/Rectangle';
import { Size } from '~/basic/Size';
import { Item } from '~/item/Item';
import { Shape } from '~/item/Shape';
import { Base } from '~/straps';
import { Numerical } from '~/util/Numerical';
import { Path } from './Path';
import { Segment } from './Segment';
Path.inject({
// @ts-expect-error
statics: new (function () {
var kappa = /*#=*/ Numerical.KAPPA,
ellipseSegments = [
new Segment([-1, 0], [0, kappa], [0, -kappa]),
new Segment([0, -1], [-kappa, 0], [kappa, 0]),
new Segment([1, 0], [0, -kappa], [0, kappa]),
new Segment([0, 1], [kappa, 0], [-kappa, 0]),
];
function createPath(segments, closed, args) {
var props = Base.getNamed(args),
path = new Path(props && (props.insert == true ? Item.INSERT : props.insert == false ? Item.NO_INSERT : null));
path._add(segments);
// No need to use setter for _closed since _add() called _changed().
path._closed = closed;
// Set named arguments at the end, since some depend on geometry to be
// defined (e.g. #clockwise)
return path.set(props, Item.INSERT);
}
function createEllipse(center, radius, args) {
var segments = new Array(4);
for (var i = 0; i < 4; i++) {
var segment = ellipseSegments[i];
segments[i] = new Segment(
segment._point.multiply(radius).add(center),
segment._handleIn.multiply(radius),
segment._handleOut.multiply(radius)
);
}
return createPath(segments, true, args);
}
return /** @lends Path */ {
/**
* {@grouptitle Shaped Paths}
*
* Creates a linear path item from two points describing a line.
*
* @name Path.Line
* @param {Point} from the line's starting point
* @param {Point} to the line's ending point
* @return {Path} the newly created path
*
* @example {@paperscript}
* var from = new Point(20, 20);
* var to = new Point(80, 80);
* var path = new Path.Line(from, to);
* path.strokeColor = 'black';
*/
/**
* Creates a linear path item from the properties described by an object
* literal.
*
* @name Path.Line
* @param {Object} object an object containing properties describing the
* path's attributes
* @return {Path} the newly created path
*
* @example {@paperscript}
* var path = new Path.Line({
* from: [20, 20],
* to: [80, 80],
* strokeColor: 'black'
* });
*/
Line: function (/* from, to */) {
var args = arguments;
return createPath(
[new Segment(Point.readNamed(args, 'from')), new Segment(Point.readNamed(args, 'to'))],
false,
args
);
},
/**
* Creates a circular path item.
*
* @name Path.Circle
* @param {Point} center the center point of the circle
* @param {Number} radius the radius of the circle
* @return {Path} the newly created path
*
* @example {@paperscript}
* var path = new Path.Circle(new Point(80, 50), 30);
* path.strokeColor = 'black';
*/
/**
* Creates a circular path item from the properties described by an
* object literal.
*
* @name Path.Circle
* @param {Object} object an object containing properties describing the
* path's attributes
* @return {Path} the newly created path
*
* @example {@paperscript}
* var path = new Path.Circle({
* center: [80, 50],
* radius: 30,
* strokeColor: 'black'
* });
*/
Circle: function (/* center, radius */) {
var args = arguments,
center = Point.readNamed(args, 'center'),
radius = Base.readNamed(args, 'radius');
return createEllipse(center, new Size(radius), args);
},
/**
* Creates a rectangular path item, with optionally rounded corners.
*
* @name Path.Rectangle
* @param {Rectangle} rectangle the rectangle object describing the
* geometry of the rectangular path to be created
* @param {Size} [radius=null] the size of the rounded corners
* @return {Path} the newly created path
*
* @example {@paperscript}
* var rectangle = new Rectangle(new Point(20, 20), new Size(60, 60));
* var path = new Path.Rectangle(rectangle);
* path.strokeColor = 'black';
*
* @example {@paperscript} // The same, with rounder corners
* var rectangle = new Rectangle(new Point(20, 20), new Size(60, 60));
* var cornerSize = new Size(10, 10);
* var path = new Path.Rectangle(rectangle, cornerSize);
* path.strokeColor = 'black';
*/
/**
* Creates a rectangular path item from a point and a size object.
*
* @name Path.Rectangle
* @param {Point} point the rectangle's top-left corner.
* @param {Size} size the rectangle's size.
* @return {Path} the newly created path
*
* @example {@paperscript}
* var point = new Point(20, 20);
* var size = new Size(60, 60);
* var path = new Path.Rectangle(point, size);
* path.strokeColor = 'black';
*/
/**
* Creates a rectangular path item from the passed points. These do not
* necessarily need to be the top left and bottom right corners, the
* constructor figures out how to fit a rectangle between them.
*
* @name Path.Rectangle
* @param {Point} from the first point defining the rectangle
* @param {Point} to the second point defining the rectangle
* @return {Path} the newly created path
*
* @example {@paperscript}
* var from = new Point(20, 20);
* var to = new Point(80, 80);
* var path = new Path.Rectangle(from, to);
* path.strokeColor = 'black';
*/
/**
* Creates a rectangular path item from the properties described by an
* object literal.
*
* @name Path.Rectangle
* @param {Object} object an object containing properties describing the
* path's attributes
* @return {Path} the newly created path
*
* @example {@paperscript}
* var path = new Path.Rectangle({
* point: [20, 20],
* size: [60, 60],
* strokeColor: 'black'
* });
*
* @example {@paperscript}
* var path = new Path.Rectangle({
* from: [20, 20],
* to: [80, 80],
* strokeColor: 'black'
* });
*
* @example {@paperscript}
* var path = new Path.Rectangle({
* rectangle: {
* topLeft: [20, 20],
* bottomRight: [80, 80]
* },
* strokeColor: 'black'
* });
*
* @example {@paperscript}
* var path = new Path.Rectangle({
* topLeft: [20, 20],
* bottomRight: [80, 80],
* radius: 10,
* strokeColor: 'black'
* });
*/
Rectangle: function (/* rectangle */) {
var args = arguments,
rect = Rectangle.readNamed(args, 'rectangle'),
radius = Size.readNamed(args, 'radius', 0, { readNull: true }),
bl = rect.getBottomLeft(true),
tl = rect.getTopLeft(true),
tr = rect.getTopRight(true),
br = rect.getBottomRight(true),
segments;
if (!radius || radius.isZero()) {
segments = [new Segment(bl), new Segment(tl), new Segment(tr), new Segment(br)];
} else {
radius = Size.min(radius, rect.getSize(true).divide(2));
var rx = radius.width,
ry = radius.height,
hx = rx * kappa,
hy = ry * kappa;
segments = [
new Segment(bl.add(rx, 0), null, [-hx, 0]),
new Segment(bl.subtract(0, ry), [0, hy]),
new Segment(tl.add(0, ry), null, [0, -hy]),
new Segment(tl.add(rx, 0), [-hx, 0], null),
new Segment(tr.subtract(rx, 0), null, [hx, 0]),
new Segment(tr.add(0, ry), [0, -hy], null),
new Segment(br.subtract(0, ry), null, [0, hy]),
new Segment(br.subtract(rx, 0), [hx, 0]),
];
}
return createPath(segments, true, args);
},
/**
* @deprecated use {@link #Path.Rectangle(rectangle, size)} instead.
*/
RoundRectangle: '#Rectangle',
/**
* Creates an elliptical path item.
*
* @name Path.Ellipse
* @param {Rectangle} rectangle the rectangle circumscribing the ellipse
* @return {Path} the newly created path
*
* @example {@paperscript}
* var rectangle = new Rectangle(new Point(20, 20), new Size(180, 60));
* var path = new Path.Ellipse(rectangle);
* path.fillColor = 'black';
*/
/**
* Creates an elliptical path item from the properties described by an
* object literal.
*
* @name Path.Ellipse
* @param {Object} object an object containing properties describing the
* path's attributes
* @return {Path} the newly created path
*
* @example {@paperscript}
* var path = new Path.Ellipse({
* point: [20, 20],
* size: [180, 60],
* fillColor: 'black'
* });
*
* @example {@paperscript} // Placing by center and radius
* var shape = new Path.Ellipse({
* center: [110, 50],
* radius: [90, 30],
* fillColor: 'black'
* });
*/
Ellipse: function (/* rectangle */) {
var args = arguments,
ellipse = Shape._readEllipse(args);
return createEllipse(ellipse.center, ellipse.radius, args);
},
/**
* @deprecated use {@link #Path.Ellipse(rectangle)} instead.
*/
Oval: '#Ellipse',
/**
* Creates a circular arc path item.
*
* @name Path.Arc
* @param {Point} from the starting point of the circular arc
* @param {Point} through the point the arc passes through
* @param {Point} to the end point of the arc
* @return {Path} the newly created path
*
* @example {@paperscript}
* var from = new Point(20, 20);
* var through = new Point(60, 20);
* var to = new Point(80, 80);
* var path = new Path.Arc(from, through, to);
* path.strokeColor = 'black';
*
*/
/**
* Creates an circular arc path item from the properties described by an
* object literal.
*
* @name Path.Arc
* @param {Object} object an object containing properties describing the
* path's attributes
* @return {Path} the newly created path
*
* @example {@paperscript}
* var path = new Path.Arc({
* from: [20, 20],
* through: [60, 20],
* to: [80, 80],
* strokeColor: 'black'
* });
*/
Arc: function (/* from, through, to */) {
var args = arguments,
from = Point.readNamed(args, 'from'),
through = Point.readNamed(args, 'through'),
to = Point.readNamed(args, 'to'),
props = Base.getNamed(args),
// See createPath() for an explanation of the following sequence
path = new Path(props && props.insert == false && Item.NO_INSERT);
path.moveTo(from);
path.arcTo(through, to);
return path.set(props);
},
/**
* Creates a regular polygon shaped path item.
*
* @name Path.RegularPolygon
* @param {Point} center the center point of the polygon
* @param {Number} sides the number of sides of the polygon
* @param {Number} radius the radius of the polygon
* @return {Path} the newly created path
*
* @example {@paperscript}
* var center = new Point(50, 50);
* var sides = 3;
* var radius = 40;
* var triangle = new Path.RegularPolygon(center, sides, radius);
* triangle.fillColor = 'black';
*/
/**
* Creates a regular polygon shaped path item from the properties
* described by an object literal.
*
* @name Path.RegularPolygon
* @param {Object} object an object containing properties describing the
* path's attributes
* @return {Path} the newly created path
*
* @example {@paperscript}
* var triangle = new Path.RegularPolygon({
* center: [50, 50],
* sides: 10,
* radius: 40,
* fillColor: 'black'
* });
*/
RegularPolygon: function (/* center, sides, radius */) {
var args = arguments,
center = Point.readNamed(args, 'center'),
sides = Base.readNamed(args, 'sides'),
radius = Base.readNamed(args, 'radius'),
step = 360 / sides,
three = sides % 3 === 0,
vector = new Point(0, three ? -radius : radius),
offset = three ? -1 : 0.5,
segments = new Array(sides);
for (var i = 0; i < sides; i++) segments[i] = new Segment(center.add(vector.rotate((i + offset) * step)));
return createPath(segments, true, args);
},
/**
* Creates a star shaped path item.
*
* The largest of `radius1` and `radius2` will be the outer radius of
* the star. The smallest of radius1 and radius2 will be the inner
* radius.
*
* @name Path.Star
* @param {Point} center the center point of the star
* @param {Number} points the number of points of the star
* @param {Number} radius1
* @param {Number} radius2
* @return {Path} the newly created path
*
* @example {@paperscript}
* var center = new Point(50, 50);
* var points = 12;
* var radius1 = 25;
* var radius2 = 40;
* var path = new Path.Star(center, points, radius1, radius2);
* path.fillColor = 'black';
*/
/**
* Creates a star shaped path item from the properties described by an
* object literal.
*
* @name Path.Star
* @param {Object} object an object containing properties describing the
* path's attributes
* @return {Path} the newly created path
*
* @example {@paperscript}
* var path = new Path.Star({
* center: [50, 50],
* points: 12,
* radius1: 25,
* radius2: 40,
* fillColor: 'black'
* });
*/
Star: function (/* center, points, radius1, radius2 */) {
var args = arguments,
center = Point.readNamed(args, 'center'),
points = Base.readNamed(args, 'points') * 2,
radius1 = Base.readNamed(args, 'radius1'),
radius2 = Base.readNamed(args, 'radius2'),
step = 360 / points,
vector = new Point(0, -1),
segments = new Array(points);
for (var i = 0; i < points; i++)
segments[i] = new Segment(center.add(vector.rotate(step * i).multiply(i % 2 ? radius2 : radius1)));
return createPath(segments, true, args);
},
};
})(),
});
|