1
0
Fork 0

feat(core): Add cbqc named export

This exports the constant `0.55342686` which is the value to best
approximate a (quarter) circle with a cubic Bézier curve.

See: https://spencermortensen.com/articles/bezier-circle/
This commit is contained in:
Joost De Cock 2023-10-17 10:03:05 +02:00
parent e808375b60
commit 49618755be
4 changed files with 14 additions and 0 deletions

View file

@ -136,6 +136,7 @@
#### Added
- Allow plugins to provide their own packing implementation
- Added named export `cbqc` which exports the constant to approximate a circle with Cubic Bézier curves
#### Fixed

View file

@ -2,6 +2,7 @@ Unreleased:
Added:
core:
- Allow plugins to provide their own packing implementation
- Added named export `cbqc` which exports the constant to approximate a circle with Cubic Bézier curves
plugin-bin-pack:
- First release of the plugin providing the default packing implementation
plugin-ringsector:

View file

@ -15,6 +15,7 @@ import {
beamsIntersect,
beamIntersectsCurve,
capitalize,
cbqc,
circlesIntersect,
curveEdge,
curveIntersectsX,
@ -62,6 +63,7 @@ export {
beamsIntersect,
beamIntersectsCurve,
capitalize,
cbqc,
circlesIntersect,
curveEdge,
curveIntersectsX,

View file

@ -2,8 +2,18 @@ import { Bezier } from 'bezier-js'
import { Path } from './path.mjs'
import { Point } from './point.mjs'
/*
* See: https://en.wikipedia.org/wiki/Golden_ratio
*/
export const goldenRatio = 1.618034
/*
* cbqc = Cubic Bezier Quarter Circle
* The value to best approximate a (quarter) circle with cubic Bézier curves
* See: https://spencermortensen.com/articles/bezier-circle/
*/
export const cbqc = 0.55191502449351
//////////////////////////////////////////////
// PUBLIC METHODS //
//////////////////////////////////////////////