1
1
import { DrawCommand , UP } from "@thi.ng/axidraw/api" ;
2
- import { polyline } from "@thi.ng/axidraw/utils " ;
2
+ import { polyline } from "@thi.ng/axidraw/polyline " ;
3
3
import type { MultiFn1O } from "@thi.ng/defmulti" ;
4
4
import { defmulti } from "@thi.ng/defmulti/defmulti" ;
5
5
import type { Group } from "@thi.ng/geom" ;
@@ -118,7 +118,8 @@ function* __points(
118
118
opts ?: Partial < AsAxiDrawOpts >
119
119
) : IterableIterator < DrawCommand > {
120
120
if ( ! pts . length ) return ;
121
- const { clip, delay, down, speed, sort } = __axiAttribs ( attribs ) ;
121
+ const { clip, delayDown, delayUp, down, speed, sort } =
122
+ __axiAttribs ( attribs ) ;
122
123
const clipPts = clip || opts ?. clip ;
123
124
if ( clipPts ) {
124
125
pts = pts . filter ( ( p ) => ! ! pointInPolygon2 ( p , clipPts ) ) ;
@@ -127,7 +128,11 @@ function* __points(
127
128
yield UP ;
128
129
if ( down != undefined ) yield [ "pen" , down ] ;
129
130
for ( let p of sort ? ( < PointOrdering > sort ) ( pts ) : pts ) {
130
- yield * [ [ "m" , p , speed ] , [ "d" , delay ] , UP ] ;
131
+ yield * < DrawCommand [ ] > [
132
+ [ "m" , p , speed ] ,
133
+ [ "d" , delayDown ] ,
134
+ [ "up" , delayUp ] ,
135
+ ] ;
131
136
}
132
137
if ( down != undefined ) yield [ "pen" ] ;
133
138
}
@@ -138,16 +143,13 @@ function* __polyline(
138
143
opts ?: Partial < AsAxiDrawOpts >
139
144
) : IterableIterator < DrawCommand > {
140
145
if ( ! pts . length ) return ;
141
- const { clip, down, speed } = __axiAttribs ( attribs ) ;
146
+ const { clip, down, delayDown , delayUp , speed } = __axiAttribs ( attribs ) ;
142
147
const clipPts = clip || opts ?. clip ;
143
148
const chunks = clipPts ? clipPolylinePoly ( pts , clipPts ) : [ pts ] ;
144
149
if ( ! chunks . length ) return ;
145
- if ( down != undefined ) yield [ "pen" , down ] ;
146
150
for ( let chunk of chunks ) {
147
- yield * polyline ( chunk , speed ) ;
151
+ yield * polyline ( chunk , { down , delayDown , delayUp , speed } ) ;
148
152
}
149
- // reset pen to configured defaults
150
- if ( down != undefined ) yield [ "pen" ] ;
151
153
}
152
154
153
155
/** @internal */
0 commit comments