Skip to content

Commit

Permalink
Move function that gets letter rotations to util
Browse files Browse the repository at this point in the history
  • Loading branch information
peterhry committed Nov 26, 2017
1 parent 0783e8b commit 4a21135
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ circleType.radius(384);
console.log(circleType.container);
//=> <div style="position: relative; height: 3.18275em;">...</div>

// Disbale the force height option
// Disable the force height option
circleType.forceHeight(false);

console.log(circleType.container);
Expand Down
2 changes: 1 addition & 1 deletion dist/circletype.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 3 additions & 12 deletions src/class.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import radiansToDegrees from './utils/radiansToDegrees';
import getRect from './utils/getRect';
import splitNode from './utils/splitNode';
import sagitta from './utils/sagitta';
import chord from './utils/chord';
import getLetterRotations from './utils/getLetterRotations';

const { PI, max, min } = Math;

Expand Down Expand Up @@ -235,7 +235,7 @@ class CircleType {
* console.log(circleType.container);
* //=> <div style="position: relative; height: 3.18275em;">...</div>
*
* // Disbale the force height option
* // Disable the force height option
* circleType.forceHeight(false);
*
* console.log(circleType.container);
Expand Down Expand Up @@ -314,18 +314,9 @@ class CircleType {
_layout() {
const { _radius, _dir } = this;
const originY = _dir === -1 ? (-_radius + this._lineHeight) : _radius;

const origin = `center ${originY / this._fontSize}em`;

const innerRadius = _radius - this._lineHeight;
const { rotations, θ } = this._metrics.reduce((data, { width }) => {
const rotation = radiansToDegrees(width / innerRadius);

return {
θ: data.θ + rotation,
rotations: data.rotations.concat([ data.θ + (rotation / 2) ]),
};
}, { θ: 0, rotations: [] });
const { rotations, θ } = getLetterRotations(this._metrics, innerRadius);

this._letters.forEach((letter, index) => {
const { style } = letter;
Expand Down

0 comments on commit 4a21135

Please sign in to comment.