import { BorderConfig , RandomBorderConfig } from "./borderconfig" ; import { Random } from "./random" ; import { Alphabet } from "." ; import { PolygonConfig , RandomPolygonConfig } from "./PolygonConfig" ; export { Config , RandomConfig } ; class Config { constructor ( private alphabet , private sentence , private borderConfig , private polgonConfigs , private innerBoarderConfig , private innerPolygonConfig , private textSize , private lineColor ) { } GetSentence ( ) { return this . sentence . replace ( /\s+/g , "" ) ; } GetBorderConfig ( ) { return this . borderConfig ; } GetInnerBoarderConfig ( ) { return this . innerBoarderConfig ; } GetAlphabet ( ) { return this . alphabet ; } GetPolygonConfigs ( ) { return this . polgonConfigs ; } GetInnerPolygonConfig ( ) { return this . innerPolygonConfig ; } GetTextScale ( ) { return this . textSize ; } GetLineColor ( ) { return this . lineColor ; } } function RandomConfig ( sentence , random ) { const numPolys = 1 + Math . round ( random . nextFloat ( ) * 2 ) ; let polys = new Array < PolygonConfig > ( numPolys ) ; for ( let p = 0 ; p < numPolys ; p ++ ) { polys [ p ] = RandomPolygonConfig ( random ) ; } return new Config ( new Alphabet ( random ) , sentence , RandomBorderConfig ( random ) , polys , RandomBorderConfig ( random ) , random . nextFloat ( ) > 0.5 ? null : new PolygonConfig ( 3 + Math . round ( random . nextFloat ( ) * 3 ) , random . nextFloat ( ) >= 0.5 , random . nextFloat ( ) >= 0.5 ) , 1 , "red" ) ; }