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

Adds method to make full circle for any given radius. #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danny-pearson
Copy link

@danny-pearson danny-pearson commented Nov 19, 2020

I hope you don't mind me submitting this, I was looking for a way of doing this with the package at work today but it felt a bit too hacky. I really like the the ease of using this library, and I feel like this would be a nice feature to add :)

This adds a new fullCircle() method which will create equal spacing between each letter, making a full circle for any given radius.

Screenshot 2020-11-19 at 03 12 07

@strarsis
Copy link

@danny-pearson: Awesome! I also need something like that. How would one do this with the existing methods? First calculating the right radius of the element?

@danny-pearson
Copy link
Author

@strarsis I just added it to the prototype in the project I needed it for :)

CircleType.prototype.fullCircle = function () {
  const diff = 2 * Math.PI * (this._radius - this._minRadius);
  const buffer = diff / this._letters.length;

  this._metrics = this._metrics.map((m) => ({ ...m, width: m.width + buffer }));

  this._invalidate();

  return this;
};

@strarsis
Copy link

@danny-pearson: Great! I would have to use your fork until this has been merged.

@peterhry: Can you merge this? This is a really useful feature.

@danny-pearson
Copy link
Author

You wouldn't really need to use the fork, I just imported CircleType from the existing package, added that bit I just sent where I needed it and used the package as normal :)

Or you could just create a new class that extends CircleType and add the method to that?

@danny-pearson
Copy link
Author

I'm not sure if @peterhry is online very often tbh, so might be a while before he sees this :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants