mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-28 22:08:54 -04:00
Implement Shape#toPath(), analogue to Path#toShape().
This way is much simpler though.
This commit is contained in:
parent
51cf1cfec6
commit
9956a6ff51
2 changed files with 20 additions and 0 deletions
|
@ -13,6 +13,8 @@
|
|||
});
|
||||
var shape = path.toShape();
|
||||
shape.position += [200, 0];
|
||||
var path = shape.toPath();
|
||||
path.position += [200, 0];
|
||||
|
||||
var path = new Path.Ellipse({
|
||||
center: [100, 200],
|
||||
|
@ -24,6 +26,8 @@
|
|||
path.rotate(20);
|
||||
var shape = path.toShape();
|
||||
shape.position += [200, 0];
|
||||
var path = shape.toPath();
|
||||
path.position += [200, 0];
|
||||
|
||||
var path = new Path.Rectangle({
|
||||
center: [100, 300],
|
||||
|
@ -35,6 +39,8 @@
|
|||
path.rotate(-20);
|
||||
var shape = path.toShape();
|
||||
shape.position += [200, 0];
|
||||
var path = shape.toPath();
|
||||
path.position += [200, 0];
|
||||
|
||||
var path = new Path.Rectangle({
|
||||
center: [100, 400],
|
||||
|
@ -47,6 +53,8 @@
|
|||
path.rotate(20);
|
||||
var shape = path.toShape();
|
||||
shape.position += [200, 0];
|
||||
var path = shape.toPath();
|
||||
path.position += [200, 0];
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -118,6 +118,18 @@ var Shape = Item.extend(/** @lends Shape# */{
|
|||
return false;
|
||||
},
|
||||
|
||||
// DOCS: #toPath()
|
||||
toPath: function() {
|
||||
var path = new Path[Base.capitalize(this._shape)]({
|
||||
center: new Point(),
|
||||
size: this._size,
|
||||
radius: this._radius
|
||||
});
|
||||
path.transform(this._matrix);
|
||||
path.setStyle(this._style);
|
||||
return path;
|
||||
},
|
||||
|
||||
_draw: function(ctx, param) {
|
||||
var style = this._style,
|
||||
fillColor = style.getFillColor(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue