Skip to content

Commit be6e649

Browse files
author
Isabelle Carter
committed
fixes servo#34
Added background color attributes to scene
1 parent 237ebbe commit be6e649

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

color.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution.
3+
//
4+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7+
// option. This file may not be copied, modified, or distributed
8+
// except according to those terms.
9+
10+
pub struct Color {
11+
r: f32,
12+
g: f32,
13+
b: f32,
14+
a: f32
15+
}

lib.rs

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ extern mod io_surface = "rust-io-surface";
2323
extern mod xlib = "rust-xlib";
2424

2525
pub mod layers;
26+
pub mod color;
2627
pub mod rendergl;
2728
pub mod scene;
2829
pub mod texturegl;

rendergl.rs

100644100755
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,10 @@ pub fn render_scene(render_context: RenderContext, scene: &Scene) {
440440
viewport(0 as GLint, 0 as GLint, scene.size.width as GLsizei, scene.size.height as GLsizei);
441441

442442
// Clear the screen.
443-
clear_color(0.38f32, 0.36f32, 0.36f32, 1.0f32);
443+
clear_color(scene.background_color.r,
444+
scene.background_color.g,
445+
scene.background_color.b,
446+
scene.background_color.a);
444447
clear(COLOR_BUFFER_BIT);
445448

446449
// Set up the initial modelview matrix.

scene.rs

100644100755
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,28 @@
88
// except according to those terms.
99

1010
use layers::Layer;
11+
use color::Color;
1112
use geom::size::Size2D;
1213
use geom::matrix::Matrix4;
1314

1415
pub struct Scene {
1516
root: Layer,
1617
size: Size2D<f32>,
17-
transform: Matrix4<f32>
18+
transform: Matrix4<f32>,
19+
background_color: Color
1820
}
1921

2022
pub fn Scene(root: Layer, size: Size2D<f32>, transform: Matrix4<f32>) -> Scene {
2123
Scene {
2224
root: root,
2325
size: size,
24-
transform: transform
26+
transform: transform,
27+
background_color: Color {
28+
r: 0.38f32,
29+
g: 0.36f32,
30+
b: 0.36f32,
31+
a: 1.0f32
32+
}
2533
}
2634
}
2735

0 commit comments

Comments
 (0)