Stop filling paths that don't have a fill attribute set
This commit is contained in:
parent
c0c0daa427
commit
7d55515f72
|
@ -140,8 +140,14 @@ struct Scene {
|
||||||
struct PathObject {
|
struct PathObject {
|
||||||
outline: Outline,
|
outline: Outline,
|
||||||
style: StyleId,
|
style: StyleId,
|
||||||
color: ColorU,
|
|
||||||
name: String,
|
name: String,
|
||||||
|
kind: PathObjectKind,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
pub enum PathObjectKind {
|
||||||
|
Fill,
|
||||||
|
Stroke,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -163,7 +169,7 @@ struct GroupStyle {
|
||||||
impl ComputedStyle {
|
impl ComputedStyle {
|
||||||
fn new() -> ComputedStyle {
|
fn new() -> ComputedStyle {
|
||||||
ComputedStyle {
|
ComputedStyle {
|
||||||
fill_color: Some(SvgColor::black()),
|
fill_color: None,
|
||||||
stroke_width: 1.0,
|
stroke_width: 1.0,
|
||||||
stroke_color: None,
|
stroke_color: None,
|
||||||
transform: Transform2D::identity(),
|
transform: Transform2D::identity(),
|
||||||
|
@ -340,9 +346,17 @@ impl Scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_shader(&self, object_index: u16) -> ObjectShader {
|
fn build_shader(&self, object_index: u16) -> ObjectShader {
|
||||||
ObjectShader {
|
let object = &self.objects[object_index as usize];
|
||||||
fill_color: self.objects[object_index as usize].color,
|
let style = self.get_style(object.style);
|
||||||
}
|
let fill_color = match object.kind {
|
||||||
|
PathObjectKind::Fill => style.fill_color,
|
||||||
|
PathObjectKind::Stroke => style.stroke_color,
|
||||||
|
};
|
||||||
|
let fill_color = match fill_color {
|
||||||
|
None => ColorU::black(),
|
||||||
|
Some(fill_color) => ColorU::from_svg_color(fill_color),
|
||||||
|
};
|
||||||
|
ObjectShader { fill_color }
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function exists to make profiling easier.
|
// This function exists to make profiling easier.
|
||||||
|
@ -386,7 +400,7 @@ impl Scene {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.bounds = self.bounds.union(&outline.bounds);
|
self.bounds = self.bounds.union(&outline.bounds);
|
||||||
self.objects.push(PathObject::new(outline, color, style, name.clone()));
|
self.objects.push(PathObject::new(outline, style, name.clone(), PathObjectKind::Fill));
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.get_style(style).stroke_color.is_some() {
|
if self.get_style(style).stroke_color.is_some() {
|
||||||
|
@ -405,14 +419,14 @@ impl Scene {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.bounds = self.bounds.union(&outline.bounds);
|
self.bounds = self.bounds.union(&outline.bounds);
|
||||||
self.objects.push(PathObject::new(outline, color, style, name));
|
self.objects.push(PathObject::new(outline, style, name, PathObjectKind::Stroke));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PathObject {
|
impl PathObject {
|
||||||
fn new(outline: Outline, color: ColorU, style: StyleId, name: String) -> PathObject {
|
fn new(outline: Outline, style: StyleId, name: String, kind: PathObjectKind) -> PathObject {
|
||||||
PathObject { outline, color, style, name }
|
PathObject { outline, style, name, kind }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue