@@ -16,11 +16,11 @@ use svg::node::element::{Circle, Path, Rectangle};
16
16
use svg:: { Document , Node } ;
17
17
use vello_common:: coarse:: { Cmd , Wide , WideTile } ;
18
18
use vello_common:: color:: palette:: css:: BLACK ;
19
- use vello_common:: flatten:: Line ;
19
+ use vello_common:: flatten:: { Line , Point } ;
20
20
use vello_common:: kurbo:: { Affine , BezPath , Cap , Join , Stroke } ;
21
21
use vello_common:: peniko:: Fill ;
22
22
use vello_common:: strip:: { STRIP_HEIGHT , Strip } ;
23
- use vello_common:: tile:: { TILE_HEIGHT , TILE_WIDTH , Tiles } ;
23
+ use vello_common:: tile:: { Tile , Tiles } ;
24
24
use vello_common:: { flatten, strip} ;
25
25
26
26
fn main ( ) {
@@ -55,12 +55,18 @@ fn main() {
55
55
}
56
56
57
57
if stages. iter ( ) . any ( |s| s. requires_tiling ( ) ) {
58
- tiles. make_tiles ( & line_buf) ;
58
+ tiles. make_tiles ( & line_buf, args . width , args . height ) ;
59
59
tiles. sort_tiles ( ) ;
60
60
}
61
61
62
62
if stages. iter ( ) . any ( |s| s. requires_strips ( ) ) {
63
- strip:: render ( & tiles, & mut strip_buf, & mut alpha_buf, args. fill_rule ) ;
63
+ strip:: render (
64
+ & tiles,
65
+ & mut strip_buf,
66
+ & mut alpha_buf,
67
+ args. fill_rule ,
68
+ & line_buf,
69
+ ) ;
64
70
}
65
71
66
72
if stages. iter ( ) . any ( |s| s. requires_wide_tiles ( ) ) {
@@ -78,7 +84,7 @@ fn main() {
78
84
}
79
85
80
86
if stages. contains ( & Stage :: TileIntersections ) {
81
- draw_tile_intersections ( & mut document, & tiles) ;
87
+ draw_tile_intersections ( & mut document, & tiles, & line_buf ) ;
82
88
}
83
89
84
90
if stages. contains ( & Stage :: StripAreas ) {
@@ -170,8 +176,8 @@ fn draw_tile_areas(document: &mut Document, tiles: &Tiles) {
170
176
171
177
for i in 0 ..tiles. len ( ) {
172
178
let tile = tiles. get ( i) ;
173
- let x = tile. x * TILE_WIDTH as i32 ;
174
- let y = tile. y * TILE_HEIGHT as u16 ;
179
+ let x = tile. x * Tile :: WIDTH as i32 ;
180
+ let y = tile. y * Tile :: HEIGHT ;
175
181
176
182
if seen. contains ( & ( x, y) ) {
177
183
continue ;
@@ -182,8 +188,8 @@ fn draw_tile_areas(document: &mut Document, tiles: &Tiles) {
182
188
let rect = Rectangle :: new ( )
183
189
. set ( "x" , x)
184
190
. set ( "y" , y)
185
- . set ( "width" , TILE_WIDTH )
186
- . set ( "height" , TILE_HEIGHT )
191
+ . set ( "width" , Tile :: WIDTH )
192
+ . set ( "height" , Tile :: HEIGHT )
187
193
. set ( "fill" , color)
188
194
. set ( "stroke" , color)
189
195
. set ( "stroke-opacity" , 1.0 )
@@ -196,15 +202,25 @@ fn draw_tile_areas(document: &mut Document, tiles: &Tiles) {
196
202
}
197
203
}
198
204
199
- fn draw_tile_intersections ( document : & mut Document , tiles : & Tiles ) {
205
+ fn draw_tile_intersections ( document : & mut Document , tiles : & Tiles , line_buf : & [ Line ] ) {
200
206
for i in 0 ..tiles. len ( ) {
201
207
let tile = tiles. get ( i) ;
202
208
203
- let x = tile. x * TILE_WIDTH as i32 ;
204
- let y = tile. y * TILE_HEIGHT as u16 ;
209
+ let x = tile. x * Tile :: WIDTH as i32 ;
210
+ let y = tile. y * Tile :: HEIGHT ;
205
211
206
- let p0 = tile. p0 ;
207
- let p1 = tile. p1 ;
212
+ let line = line_buf[ tile. line_idx as usize ] ;
213
+
214
+ // TODO: how to handle line intersections now lines are not explicitly segmented by tile
215
+ // generation anymore?
216
+ let p0 = Point {
217
+ x : line. p0 . x - x as f32 ,
218
+ y : line. p0 . y - y as f32 ,
219
+ } ;
220
+ let p1 = Point {
221
+ x : line. p1 . x - x as f32 ,
222
+ y : line. p1 . y - y as f32 ,
223
+ } ;
208
224
209
225
// Add a tiny offset so start and end point don't overlap completely.
210
226
for p in [ ( p0, -0.05 , "green" ) , ( p1, 0.05 , "purple" ) ] {
0 commit comments