Skip to content

Commit 47a3c7d

Browse files
committed
Fix vello_toy
1 parent 2919995 commit 47a3c7d

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

sparse_strips/vello_toy/src/debug.rs

+30-14
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ use svg::node::element::{Circle, Path, Rectangle};
1616
use svg::{Document, Node};
1717
use vello_common::coarse::{Cmd, Wide, WideTile};
1818
use vello_common::color::palette::css::BLACK;
19-
use vello_common::flatten::Line;
19+
use vello_common::flatten::{Line, Point};
2020
use vello_common::kurbo::{Affine, BezPath, Cap, Join, Stroke};
2121
use vello_common::peniko::Fill;
2222
use vello_common::strip::{STRIP_HEIGHT, Strip};
23-
use vello_common::tile::{TILE_HEIGHT, TILE_WIDTH, Tiles};
23+
use vello_common::tile::{Tile, Tiles};
2424
use vello_common::{flatten, strip};
2525

2626
fn main() {
@@ -55,12 +55,18 @@ fn main() {
5555
}
5656

5757
if stages.iter().any(|s| s.requires_tiling()) {
58-
tiles.make_tiles(&line_buf);
58+
tiles.make_tiles(&line_buf, args.width, args.height);
5959
tiles.sort_tiles();
6060
}
6161

6262
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+
);
6470
}
6571

6672
if stages.iter().any(|s| s.requires_wide_tiles()) {
@@ -78,7 +84,7 @@ fn main() {
7884
}
7985

8086
if stages.contains(&Stage::TileIntersections) {
81-
draw_tile_intersections(&mut document, &tiles);
87+
draw_tile_intersections(&mut document, &tiles, &line_buf);
8288
}
8389

8490
if stages.contains(&Stage::StripAreas) {
@@ -170,8 +176,8 @@ fn draw_tile_areas(document: &mut Document, tiles: &Tiles) {
170176

171177
for i in 0..tiles.len() {
172178
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;
175181

176182
if seen.contains(&(x, y)) {
177183
continue;
@@ -182,8 +188,8 @@ fn draw_tile_areas(document: &mut Document, tiles: &Tiles) {
182188
let rect = Rectangle::new()
183189
.set("x", x)
184190
.set("y", y)
185-
.set("width", TILE_WIDTH)
186-
.set("height", TILE_HEIGHT)
191+
.set("width", Tile::WIDTH)
192+
.set("height", Tile::HEIGHT)
187193
.set("fill", color)
188194
.set("stroke", color)
189195
.set("stroke-opacity", 1.0)
@@ -196,15 +202,25 @@ fn draw_tile_areas(document: &mut Document, tiles: &Tiles) {
196202
}
197203
}
198204

199-
fn draw_tile_intersections(document: &mut Document, tiles: &Tiles) {
205+
fn draw_tile_intersections(document: &mut Document, tiles: &Tiles, line_buf: &[Line]) {
200206
for i in 0..tiles.len() {
201207
let tile = tiles.get(i);
202208

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;
205211

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+
};
208224

209225
// Add a tiny offset so start and end point don't overlap completely.
210226
for p in [(p0, -0.05, "green"), (p1, 0.05, "purple")] {

0 commit comments

Comments
 (0)