Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return an instance of the current class when calling clone/translate/… #118

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

schelmo
Copy link
Contributor

@schelmo schelmo commented Apr 28, 2022

this allows to use extended classes with methods like clone/translate/rotate/transform/merge

a basic example

class Arc extends Flatten.Arc {
  customMethod() {/*...*/}
}
class Segment extends Flatten.Segment {
  customMethod() {/*...*/}
}
class Polygon exnteds Flatten.Polygon {
  customMethod() {/*...*/}
}

const poly = new Polygon([new Arc(), new Segment()])
// not working now
poly.clone().customMethod()

for (let edge of polygon.translate(Flatten.vector(1, 1)).edges) {
  // not working now
  edge.shape.customMethod()
}

…rotate/transform/merge methods on inherited classes
# Conflicts:
#	src/classes/arc.js
#	src/classes/matrix.js
#	src/classes/point.js
#	src/classes/segment.js
#	src/classes/vector.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants