CircleType icon indicating copy to clipboard operation
CircleType copied to clipboard

Adds method to make full circle for any given radius.

Open danny-pearson opened this issue 4 years ago • 5 comments

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

danny-pearson avatar Nov 19 '20 04:11 danny-pearson

@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 avatar Feb 10 '21 10:02 strarsis

@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 avatar Feb 26 '21 00:02 danny-pearson

@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.

strarsis avatar Feb 26 '21 00:02 strarsis

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 avatar Feb 26 '21 00:02 danny-pearson

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

danny-pearson avatar Feb 26 '21 00:02 danny-pearson