Commit 89d9a213 authored by Paolo Borelli's avatar Paolo Borelli

node: introduce different types for light sources

parent b556a565
......@@ -102,7 +102,7 @@ node_create_fn!(
);
node_create_fn!(
create_distant_light,
LightSource,
DistantLight,
LightSource::new_distant_light
);
node_create_fn!(
......@@ -140,11 +140,7 @@ node_create_fn!(
node_create_fn!(create_offset, FilterPrimitiveOffset, Offset::new);
node_create_fn!(create_path, Path, NodePath::new);
node_create_fn!(create_pattern, Pattern, NodePattern::new);
node_create_fn!(
create_point_light,
LightSource,
LightSource::new_point_light
);
node_create_fn!(create_point_light, PointLight, LightSource::new_point_light);
node_create_fn!(create_polygon, Polygon, NodePoly::new_closed);
node_create_fn!(create_polyline, Polyline, NodePoly::new_open);
node_create_fn!(
......@@ -158,7 +154,7 @@ node_create_fn!(
FilterPrimitiveSpecularLighting,
Lighting::new_specular
);
node_create_fn!(create_spot_light, LightSource, LightSource::new_spot_light);
node_create_fn!(create_spot_light, SpotLight, LightSource::new_spot_light);
node_create_fn!(create_stop, Stop, NodeStop::new);
node_create_fn!(create_style, Style, NodeStyle::new);
node_create_fn!(create_svg, Svg, NodeSvg::new);
......
......@@ -226,10 +226,10 @@ impl Filter for Lighting {
cssparser::Color::RGBA(rgba) => rgba,
};
let mut light_sources = node
.children()
.rev()
.filter(|c| c.get_type() == NodeType::LightSource);
let mut light_sources = node.children().rev().filter(|c| match c.get_type() {
NodeType::DistantLight | NodeType::PointLight | NodeType::SpotLight => true,
_ => false,
});
let light_source = light_sources.next();
if light_source.is_none() || light_sources.next().is_some() {
return Err(FilterError::InvalidLightSourceCount);
......
......@@ -183,11 +183,11 @@ pub enum NodeType {
ComponentTransferFunctionG,
ComponentTransferFunctionR,
Defs,
DistantLight,
Ellipse,
Filter,
Group,
Image,
LightSource,
Line,
LinearGradient,
Link,
......@@ -195,10 +195,12 @@ pub enum NodeType {
Mask,
Path,
Pattern,
PointLight,
Polygon,
Polyline,
RadialGradient,
Rect,
SpotLight,
Stop,
Style,
Svg,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment