CircleType
CircleType copied to clipboard
Adds method to make full circle for any given radius.
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.
@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?
@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;
};
@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.
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?
I'm not sure if @peterhry is online very often tbh, so might be a while before he sees this :P