@@ -182,8 +182,12 @@ function floatToString(value, fmt, ret_fmt) {
182182class DrawOptions {
183183
184184 constructor ( opt ) {
185- this . opt = isStr ( opt ) ? opt . toUpperCase ( ) . trim ( ) : '' ;
186- this . part = '' ;
185+ if ( isStr ( opt ) ) {
186+ this . origin = opt . trim ( ) ;
187+ this . opt = this . origin . toUpperCase ( ) ;
188+ } else
189+ this . opt = this . origin = '' ;
190+ this . part = this . partO = '' ;
187191 }
188192
189193 /** @summary Returns true if remaining options are empty or contain only separators symbols. */
@@ -192,12 +196,18 @@ class DrawOptions {
192196 /** @summary Returns remaining part of the draw options. */
193197 remain ( ) { return this . opt ; }
194198
199+ /** @summary Remove [pos, pos2) part from the string */
200+ #cut( pos , pos2 ) {
201+ this . opt = this . opt . slice ( 0 , pos ) + this . opt . slice ( pos2 ) ;
202+ this . origin = this . origin . slice ( 0 , pos ) + this . origin . slice ( pos2 ) ;
203+ }
204+
195205 /** @summary Checks if given option exists */
196206 check ( name , postpart ) {
197207 const pos = this . opt . indexOf ( name ) ;
198208 if ( pos < 0 )
199209 return false ;
200- this . opt = this . opt . slice ( 0 , pos ) + this . opt . slice ( pos + name . length ) ;
210+ this . #cut ( pos , pos + name . length ) ;
201211 this . part = '' ;
202212 if ( ! postpart )
203213 return true ;
@@ -217,7 +227,8 @@ class DrawOptions {
217227 }
218228 if ( pos2 > pos ) {
219229 this . part = this . opt . slice ( pos , pos2 ) ;
220- this . opt = this . opt . slice ( 0 , pos ) + this . opt . slice ( pos2 ) ;
230+ this . partO = this . origin . slice ( pos , pos2 ) ;
231+ this . #cut( pos , pos2 ) ;
221232 }
222233
223234 if ( is_array ) {
@@ -249,6 +260,9 @@ class DrawOptions {
249260 return false ;
250261 }
251262
263+ /** @summary Returns (original) part after found options. */
264+ getPart ( origin ) { return origin ? this . partO : this . part ; }
265+
252266 /** @summary Returns remaining part of found option as integer. */
253267 partAsInt ( offset , dflt ) {
254268 let mult = 1 ;
0 commit comments