We are going to want these for dynamic reset.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
use crate::prelude::*;
+pub const SVG_SCALE: f64 = 6.;
+
pub fn timestring_abbreviate<'x>(base: &str, this: &'x str)
-> (&'x str, bool)
{
}
}
pub use crate::display_as_debug;
+
+pub type SvgAttrs = Vec<(String,String)>;
+
+pub fn space_table_attrs(table_size: PosC<f64>) -> SvgAttrs {
+ let PosC { coords: [x, y] } = table_size.into();
+ vec![
+ ("viewBox".to_owned(), format!("0 0 {x} {y}", x=x, y=y) ),
+ ("width" .to_owned(), (SVG_SCALE * x).to_string() ),
+ ("height" .to_owned(), (SVG_SCALE * y).to_string() ),
+ ]
+}
+
+pub fn space_rect_attrs(table_size: PosC<f64>) -> SvgAttrs {
+ vec![
+ ("width" .to_owned(), table_size.x().to_string() ),
+ ("height" .to_owned(), table_size.y().to_string() ),
+ ]
+}
pub use thiserror::Error;
pub use void::Void;
-pub use crate::geometry::CoordinateOverflow;
+pub use crate::geometry::{CoordinateOverflow, PosC};
pub use crate::misc::default;
pub use crate::misc::display_as_debug;
ctoken: RawToken,
player: PlayerId,
gen: Generation,
- table_size: Pos,
+ space_attrs: SvgAttrs,
+ rect_attrs: SvgAttrs,
uses: Vec<SessionPieceContext>,
defs: Vec<(VisiblePieceId, Html)>,
nick: String,
log: Vec<SessionFormattedLogEntry>,
sse_url_prefix: String,
links: Html,
- scale: f64,
player_info_pane: Html,
fake_rng: bool,
}
None => "".into(),
};
+ let table_size = ig.gs.table_size.promote();
+
let src = SessionRenderContext {
table_colour: ig.gs.table_colour.clone(),
ctoken,
gen: ig.gs.gen,
log,
- table_size: ig.gs.table_size,
player,
defs: alldefs,
uses,
- scale: SVG_SCALE,
+ space_attrs: space_table_attrs(table_size),
+ rect_attrs: space_table_attrs(table_size),
nick,
sse_url_prefix,
player_info_pane,
pub use otter_base::geometry::{CoordinateOverflow,Region};
pub use otter_base::zcoord::{self, ZCoord};
pub use otter_base::misc as base_misc;
-pub use base_misc::default;
-pub use base_misc::display_as_debug;
+pub use base_misc::*;
pub use crate::dbgc;
pub use crate::{deref_to_field, deref_to_field_mut};
use crate::prelude::*;
-pub const SVG_SCALE: f64 = 6.;
-
pub const HELD_SURROUND_COLOUR: &str = "black";
#[derive(Clone,Copy,Debug,Eq,PartialEq,Serialize,Deserialize,EnumString)]
{% macro space() %}
<svg id="space"
xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 {{ table_size[0] }} {{ table_size[1] }}"
- width="{{ table_size[0]*scale }}"
- height="{{ table_size[1]*scale }}"
+{%- for attr in space_attrs %}
+ {{ attr.0 }}="{{ attr.1 }}"
+{%- endfor %}
>
<rect fill="{{ table_colour }}" x="0" y="0"
- width="{{ table_size[0] }}" height="{{ table_size[1] }}"/>
+{%- for attr in rect_attrs %}
+ {{ attr.0 }}="{{ attr.1 }}"
+{%- endfor %}
+ />
<g id="pieces_marker"></g>
{%- for piece in uses %}
<use id="use{{ piece.id }}" href="#piece{{ piece.id }}"