chiark / gitweb /
include dragraise in pelem dataset
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 8 Jul 2020 00:40:56 +0000 (01:40 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 8 Jul 2020 00:54:23 +0000 (01:54 +0100)
src/pieces.rs
templates/script.ts

index 4c6cf4c325425a80ead73776f2cadc2658cc4431..b4dc7899910c3494a6839c8b0abe13d686ae84a1 100644 (file)
@@ -9,6 +9,7 @@ define_index_type! {
 struct SimpleShape {
   desc : String,
   shape : String,
+  approx_dia : Coord,
   colours : IndexVec<FaceId,Colour>,
 }
 
@@ -16,9 +17,11 @@ const SELECT_SCALE : f64 = 1.1;
 
 impl Piece for SimpleShape {
   fn svg_piece(&self, pri : &PieceRenderInstructions) -> String {
-    format!(r##"<use fill="{}" href="#{}"/>"##,
+    format!(r##"<use fill="{}" href="#{}" data-dragraise="{}"/>"##,
             self.colours[pri.face],
-            pri.id_x("base"))
+            pri.id_x("base"),
+            self.approx_dia / 2,
+    )
   }
   fn svg_select(&self, pri : &PieceRenderInstructions) -> String {
     format!(r##"<g transform="scale({})"><use href="#{}"/></g>"##,
@@ -43,12 +46,14 @@ pub fn xxx_make_pieces() -> Vec<(Pos, Box<dyn Piece>)> {
     ([ 90, 80 ],
      Box::new(SimpleShape {
        desc : "circle".to_owned(),
+       approx_dia : 20,
        shape : r#"<circle cx="0" cy="0" r="10"/>"#.to_owned(),
        colours : index_vec![ "red".to_string(), "grey".to_string() ],
      })),
     ([ 90, 60 ],
      Box::new(SimpleShape {
        desc : "square".to_owned(),
+       approx_dia : 20,
        shape : r#"<rect x="-10" y="-10" width="20" height="20"/>"#.to_owned(),
        colours : index_vec![ "blue".to_string(), "grey".to_string() ],
      })),
index 01cfd2fba9e38e9d36c3c450a4a0dc6fc263ef60..934c19713b39c27eaa0de746694a1ec63b567558 100644 (file)
@@ -23,6 +23,7 @@
 //
 //   pelem
 //   #piece{}
+//         .dragraise   dragged more than this ?  raise to top!
 //      <g id="piece{}" >
 //      currently-displayed version of the piece
 //      to allow addition/removal of selected indication