itemname: String,
labels: IndexVec<FaceId, String>, // if .len()==1, always use [0]
image: Arc<dyn InertPieceTrait>, // if image.nfaces()==1, always use face 0
- outline: CircleShape,
+ surround_outline: CircleShape,
cooldown_radius: f64,
cooldown_time: Duration,
}
} else {
throw!(SpecError::InvalidSizeScale)
};
- let outline = CircleShape { diam: radius * 2. };
+ let surround_outline = CircleShape { diam: radius * 2. };
let cooldown_radius = radius + COOLDOWN_EXTRA_RADIUS;
let cooldown_time = {
.into();
let our_occ_image = Arc::new(Die {
- nfaces, cooldown_time, cooldown_radius, outline,
+ nfaces, cooldown_time, cooldown_radius, surround_outline,
itemname: itemname.clone(),
image: image_occ_image,
labels: index_vec![occ_label.into()],
};
let die = Die {
- nfaces, cooldown_time, cooldown_radius, outline,
+ nfaces, cooldown_time, cooldown_radius, surround_outline,
itemname, labels,
image: image.into()
};
#[dyn_upcast]
impl OutlineTrait for Die {
+ // We have done our own adjustable radius adjustment, so we
+ // apply that to surround_outline's outline_path, rather than its
+ // surround_path.
+ #[throws(IE)]
+ fn surround_path(&self) -> Html { self.surround_outline.outline_path(1.0)? }
+
delegate! {
- to self.outline {
+ to self.image {
+ // `outline_path` won't be called at all,
+ // since we provide `surround_path`
fn outline_path(&self, scale: f64) -> Result<Html, IE>;
fn thresh_dragraise(&self) -> Result<Option<Coord>, IE>;
fn bbox_approx(&self) -> Result<Rect, IE>;
// This is used:
// 1. To generate the path for SimpleShape's renderings
// 2. This call here in the default impl of surround_path
+ // 3. Things that use an Outline to represent a surround (eg dice.rs)
fn outline_path(&self, scale: f64) -> Result<Html, IE>;
// Used for the piece selection outline
fn surround_path(&self) -> Result<Html, IE> {