11// https://www.blobmaker.app/
22
33import { rand } from "./internal/math/rand" ;
4- import { Point } from "./internal/math/geometry " ;
4+ import { Coord } from "./internal/types " ;
55import { rad } from "./internal/math/unit" ;
66import { smooth } from "./internal/svg/smooth" ;
77import { renderEditable } from "./internal/svg/render" ;
@@ -72,7 +72,7 @@ blobs.editable = (opt: BlobOptions): XmlElement => {
7272 const angle = 360 / count ;
7373 const radius = opt . size / Math . E ;
7474
75- const points : Point [ ] = [ ] ;
75+ const points : Coord [ ] = [ ] ;
7676 for ( let i = 0 ; i < count ; i ++ ) {
7777 const rand = 1 - 0.8 * opt . contrast * rgen ( ) ;
7878
@@ -82,9 +82,11 @@ blobs.editable = (opt: BlobOptions): XmlElement => {
8282 } ) ;
8383 }
8484
85+ // https://math.stackexchange.com/a/873589/235756
86+ const smoothingStrength = ( ( 4 / 3 ) * Math . tan ( rad ( angle / 4 ) ) ) / Math . sin ( rad ( angle / 2 ) ) ;
8587 const smoothed = smooth ( points , {
8688 closed : true ,
87- strength : ( ( 4 / 3 ) * Math . tan ( rad ( angle / 4 ) ) ) / Math . sin ( rad ( angle / 2 ) ) ,
89+ strength : smoothingStrength ,
8890 } ) ;
8991
9092 return renderEditable ( smoothed , {
@@ -123,7 +125,7 @@ blobs.path = (opt: PathOptions) => {
123125 const angle = 360 / count ;
124126 const radius = opt . size / Math . E ;
125127
126- const points : Point [ ] = [ ] ;
128+ const points : Coord [ ] = [ ] ;
127129 for ( let i = 0 ; i < count ; i ++ ) {
128130 const rand = 1 - 0.8 * opt . contrast * rgen ( ) ;
129131
0 commit comments