Skip to content

Commit

Permalink
different colors for extra shapes. also refactoring the lists of thes…
Browse files Browse the repository at this point in the history
…e rotating colors
  • Loading branch information
dabreegster committed May 9, 2019
1 parent 8b79c55 commit ba5de5a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
10 changes: 2 additions & 8 deletions editor/src/debug/neighborhood_summary.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::helpers::rotating_color;
use crate::render::DrawMap;
use crate::ui::UI;
use abstutil;
Expand Down Expand Up @@ -99,7 +100,7 @@ impl Region {
polygon: n.polygon.clone(),
center,
lanes: HashSet::new(),
color: COLORS[idx % COLORS.len()],
color: rotating_color(idx),
summary: Text::from_line(format!("{} - no summary yet", n.name)),
}
}
Expand Down Expand Up @@ -128,10 +129,3 @@ impl Region {
self.summary = txt;
}
}

const COLORS: [Color; 3] = [
// TODO these are awful choices
Color::RED.alpha(0.8),
Color::GREEN.alpha(0.8),
Color::BLUE.alpha(0.8),
];
10 changes: 10 additions & 0 deletions editor/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,13 @@ impl ColorScheme {
}

include!(concat!(env!("OUT_DIR"), "/init_colors.rs"));

pub fn rotating_color(idx: usize) -> Color {
// TODO these are awful choices
const COLORS: [Color; 3] = [
Color::RED.alpha(0.8),
Color::GREEN.alpha(0.8),
Color::BLUE.alpha(0.8),
];
COLORS[idx % COLORS.len()]
}
12 changes: 3 additions & 9 deletions editor/src/mission/scenario.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::game::Mode;
use crate::helpers::rotating_color;
use crate::mission::MissionEditMode;
use crate::sandbox::SandboxMode;
use crate::ui::UI;
Expand Down Expand Up @@ -76,7 +77,7 @@ impl ScenarioEditor {
neighborhoods
.iter()
.enumerate()
.map(|(idx, (_, n))| (COLORS[idx % COLORS.len()], &n.polygon))
.map(|(idx, (_, n))| (rotating_color(idx), &n.polygon))
.collect::<Vec<_>>(),
);
let mapping = neighborhoods
Expand All @@ -87,7 +88,7 @@ impl ScenarioEditor {
name.clone(),
Region {
_name: name,
color: COLORS[idx % COLORS.len()],
color: rotating_color(idx),
center: n.polygon.center(),
},
)
Expand Down Expand Up @@ -294,13 +295,6 @@ fn edit_scenario(map: &Map, scenario: &mut Scenario, mut wizard: WrappedWizard)
Some(())
}

const COLORS: [Color; 3] = [
// TODO these are awful choices
Color::RED.alpha(0.8),
Color::GREEN.alpha(0.8),
Color::BLUE.alpha(0.8),
];

// Er, the info on top of Neighbohood
pub struct Region {
_name: String,
Expand Down
8 changes: 4 additions & 4 deletions editor/src/render/extra_shape.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::helpers::ID;
use crate::helpers::{rotating_color, ID};
use crate::render::{
DrawCtx, DrawOptions, Renderable, EXTRA_SHAPE_POINT_RADIUS, EXTRA_SHAPE_THICKNESS,
};
use ezgui::{Color, GfxCtx};
use ezgui::GfxCtx;
use geom::{Circle, FindClosest, GPSBounds, PolyLine, Polygon, Pt2D};
use kml::ExtraShape;
use map_model::{DirectedRoadID, Map, LANE_THICKNESS};
Expand Down Expand Up @@ -79,10 +79,10 @@ impl Renderable for DrawExtraShape {
ID::ExtraShape(self.id)
}

fn draw(&self, g: &mut GfxCtx, opts: &DrawOptions, ctx: &DrawCtx) {
fn draw(&self, g: &mut GfxCtx, opts: &DrawOptions, _: &DrawCtx) {
let color = opts
.color(self.get_id())
.unwrap_or_else(|| ctx.cs.get_def("extra shape", Color::CYAN.alpha(0.8)));
.unwrap_or_else(|| rotating_color(self.id.0));
g.draw_polygon(color, &self.polygon);
}

Expand Down

0 comments on commit ba5de5a

Please sign in to comment.