generated from ElnuDev/rust-project
Compare commits
6 commits
78aae3de62
...
31572568da
Author | SHA1 | Date | |
---|---|---|---|
31572568da | |||
52ed2c87d3 | |||
da997bd5b6 | |||
f5e043c981 | |||
20e0b8dd08 | |||
31b9a88edb |
9 changed files with 314 additions and 22 deletions
3
dyesub-tool/assets/next.svg
Normal file
3
dyesub-tool/assets/next.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
|
||||
<path fill-rule="evenodd" d="M4.72 3.97a.75.75 0 011.06 0l7.5 7.5a.75.75 0 010 1.06l-7.5 7.5a.75.75 0 01-1.06-1.06L11.69 12 4.72 5.03a.75.75 0 010-1.06zm6 0a.75.75 0 011.06 0l7.5 7.5a.75.75 0 010 1.06l-7.5 7.5a.75.75 0 11-1.06-1.06L17.69 12l-6.97-6.97a.75.75 0 010-1.06z" clip-rule="evenodd" />
|
||||
</svg>
|
After Width: | Height: | Size: 401 B |
124
dyesub-tool/assets/nixos.svg
Normal file
124
dyesub-tool/assets/nixos.svg
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="44.00663"
|
||||
height="38.168068"
|
||||
viewBox="0 0 41.256216 35.782565"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
|
||||
sodipodi:docname="nixos.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<defs
|
||||
id="defs4" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="13.087376"
|
||||
inkscape:cx="31.442514"
|
||||
inkscape:cy="15.66395"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="g5329"
|
||||
showgrid="true"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1080"
|
||||
inkscape:window-x="1920"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:snap-global="true"
|
||||
fit-margin-top="0"
|
||||
fit-margin-left="0"
|
||||
fit-margin-right="0"
|
||||
fit-margin-bottom="0"
|
||||
units="px"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="print-logo"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
style="display:inline"
|
||||
transform="translate(-160.45368,535.40252)" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer2"
|
||||
inkscape:label="text-2"
|
||||
transform="translate(-27.871478,-422.6377)" />
|
||||
<g
|
||||
style="display:inline"
|
||||
inkscape:label="text-vegur"
|
||||
id="g5329"
|
||||
inkscape:groupmode="layer"
|
||||
transform="translate(-160.45368,535.40252)">
|
||||
<g
|
||||
transform="matrix(0.34788402,0,0,0.34788402,88.02172,-315.64249)"
|
||||
id="g892"
|
||||
style="fill:#000000">
|
||||
<path
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.709135;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="m 244.38844,-579.00705 28.88469,50.03541 -13.27432,0.12452 -7.71151,-13.44265 -7.76655,13.37082 -6.59552,-0.003 -3.37805,-5.83608 11.06498,-19.02614 -7.85472,-13.66872 z"
|
||||
id="path4861"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccccccccc" />
|
||||
<path
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.709135;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="m 254.81405,-599.61716 -28.88958,50.03257 -6.745,-11.43362 7.78592,-13.3997 -15.46274,-0.0406 -3.29545,-5.71322 3.36517,-5.84351 22.00961,0.0695 7.9101,-13.63673 z"
|
||||
id="use4863"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccccccccc" />
|
||||
<path
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.709135;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="m 257.03036,-559.62188 57.77427,0.003 -6.52931,11.55814 -15.49744,-0.043 7.69619,13.41143 -3.30007,5.71054 -6.74322,0.008 -10.94463,-19.09562 -15.76482,-0.032 z"
|
||||
id="use4865"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccccccccc" />
|
||||
<path
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.709135;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
||||
d="m 290.65703,-581.54493 -28.88469,-50.03541 13.27432,-0.12452 7.71151,13.44265 7.76655,-13.37082 6.59552,0.003 3.37805,5.83609 -11.06498,19.02614 7.85472,13.66872 z"
|
||||
id="use4867"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccccccccc" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccccccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4873"
|
||||
d="m 244.38844,-579.00705 28.88469,50.03541 -13.27432,0.12452 -7.71151,-13.44265 -7.76655,13.37082 -6.59552,-0.003 -3.37805,-5.83608 11.06498,-19.02614 -7.85472,-13.66872 z"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.709135;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccccccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="use4875"
|
||||
d="m 277.93827,-601.05655 -57.77427,-0.003 6.52931,-11.55815 15.49743,0.043 -7.69618,-13.41144 3.30007,-5.71055 6.74322,-0.007 10.94462,19.09563 15.76482,0.032 z"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.709135;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccccccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="use4877"
|
||||
d="m 280.19223,-560.94548 28.88958,-50.03256 6.745,11.43363 -7.78592,13.3997 15.46274,0.0406 3.29544,5.71322 -3.36516,5.84353 -22.00961,-0.0695 -7.9101,13.63676 z"
|
||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.709135;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 8.2 KiB |
3
dyesub-tool/assets/playpause.svg
Normal file
3
dyesub-tool/assets/playpause.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
|
||||
<path d="M15 6.75a.75.75 0 00-.75.75V18a.75.75 0 00.75.75h.75a.75.75 0 00.75-.75V7.5a.75.75 0 00-.75-.75H15zM20.25 6.75a.75.75 0 00-.75.75V18c0 .414.336.75.75.75H21a.75.75 0 00.75-.75V7.5a.75.75 0 00-.75-.75h-.75zM5.055 7.06C3.805 6.347 2.25 7.25 2.25 8.69v8.122c0 1.44 1.555 2.343 2.805 1.628l7.108-4.061c1.26-.72 1.26-2.536 0-3.256L5.055 7.061z" />
|
||||
</svg>
|
After Width: | Height: | Size: 457 B |
3
dyesub-tool/assets/previous.svg
Normal file
3
dyesub-tool/assets/previous.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
|
||||
<path fill-rule="evenodd" d="M13.28 3.97a.75.75 0 010 1.06L6.31 12l6.97 6.97a.75.75 0 11-1.06 1.06l-7.5-7.5a.75.75 0 010-1.06l7.5-7.5a.75.75 0 011.06 0zm6 0a.75.75 0 010 1.06L12.31 12l6.97 6.97a.75.75 0 11-1.06 1.06l-7.5-7.5a.75.75 0 010-1.06l7.5-7.5a.75.75 0 011.06 0z" clip-rule="evenodd" />
|
||||
</svg>
|
After Width: | Height: | Size: 400 B |
70
dyesub-tool/src/key/mod.rs
Normal file
70
dyesub-tool/src/key/mod.rs
Normal file
|
@ -0,0 +1,70 @@
|
|||
mod oyayubi;
|
||||
pub use oyayubi::OYAYUBI;
|
||||
|
||||
use std::fmt::{Display, self};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum Key<'a> {
|
||||
Oyayubi {
|
||||
latin: char,
|
||||
normal: char,
|
||||
shift: char,
|
||||
alt_shift: Option<char>,
|
||||
},
|
||||
Single {
|
||||
text: &'a str,
|
||||
u: f64,
|
||||
},
|
||||
Icon {
|
||||
icon_path: &'a str,
|
||||
u: f64,
|
||||
},
|
||||
Break,
|
||||
}
|
||||
|
||||
pub const fn oyayubi<'a>(latin: char, normal: char, shift: char, alt_shift: Option<char>) -> Key<'a> {
|
||||
Key::Oyayubi {
|
||||
latin,
|
||||
normal,
|
||||
shift,
|
||||
alt_shift,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn single<'a>(text: &'a str, u: f64) -> Key<'a> {
|
||||
Key::Single {
|
||||
text,
|
||||
u,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn icon<'a>(icon_path: &'a str, u: f64) -> Key<'a> {
|
||||
Key::Icon {
|
||||
icon_path,
|
||||
u,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Key<'a> {
|
||||
pub fn width_mod(&self) -> f64 {
|
||||
use Key::*;
|
||||
match self {
|
||||
Oyayubi { .. } => 1.0,
|
||||
Single { u, .. } => *u,
|
||||
Icon { u, .. } => *u,
|
||||
Break => 0.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Display for Key<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use Key::*;
|
||||
write!(f, "{}", match self {
|
||||
Oyayubi { latin, .. } => latin.to_string(),
|
||||
Single { text, .. } => text.to_string(),
|
||||
Icon { icon_path, .. } => icon_path.to_string(),
|
||||
Break => "".to_string(),
|
||||
})
|
||||
}
|
||||
}
|
35
dyesub-tool/src/key/oyayubi.rs
Normal file
35
dyesub-tool/src/key/oyayubi.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
use super::Key;
|
||||
use super::oyayubi as k;
|
||||
|
||||
pub const OYAYUBI: [Key; 30] = [
|
||||
k('Q', '。', 'ぁ', None),
|
||||
k('W', 'か', 'え', None),
|
||||
k('E', 'た', 'り', None),
|
||||
k('R', 'こ', 'ゃ', None),
|
||||
k('T', 'さ', 'れ', None),
|
||||
k('Y', 'ら', 'よ', Some('ぱ')),
|
||||
k('U', 'ち', 'に', None),
|
||||
k('I', 'く', 'る', None),
|
||||
k('O', 'つ', 'ま', None),
|
||||
k('P', ',', 'ぇ', Some('ぴ')),
|
||||
k('A', 'う', 'を', None),
|
||||
k('S', 'し', 'あ', None),
|
||||
k('D', 'て', 'な', None),
|
||||
k('F', 'け', 'ゅ', None),
|
||||
k('G', 'せ', 'も', None),
|
||||
k('H', 'は', 'み', None),
|
||||
k('J', 'と', 'お', None),
|
||||
k('K', 'き', 'の', None),
|
||||
k('L', 'い', 'ょ', Some('ぽ')),
|
||||
k(';', 'ん', 'っ', None), // Missing +
|
||||
k('Z', '.', 'ぅ', None),
|
||||
k('X', 'ひ', 'ー', None),
|
||||
k('C', 'す', 'ろ', None),
|
||||
k('V', 'ふ', 'や', None),
|
||||
k('B', 'へ', 'ぃ', None),
|
||||
k('N', 'め', 'ぬ', Some('ぷ')),
|
||||
k('M', 'そ', 'ゆ', None),
|
||||
k(',', 'ね', 'む', Some('ぺ')), // Missing <
|
||||
k('.', 'ほ', 'わ', None), // Missing >
|
||||
k('?', '・', 'ぉ', Some('ゎ')) // Missing /
|
||||
];
|
|
@ -1,16 +1,20 @@
|
|||
pub mod svg;
|
||||
use svg::*;
|
||||
|
||||
pub mod key;
|
||||
use key::*;
|
||||
|
||||
use askama::Template;
|
||||
use derive_more::From;
|
||||
use std::{fs::OpenOptions, io::Write};
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "document.xml")]
|
||||
struct DocumentTemplate {
|
||||
dimensions: DocumentDimensions,
|
||||
struct DocumentTemplate<'a> {
|
||||
dimensions: &'a DocumentDimensions,
|
||||
box_size: SVGMeasure,
|
||||
positions: Vec<(SVGMeasure, SVGMeasure)>,
|
||||
positions: Vec<(&'a Key<'a>, (SVGMeasure, SVGMeasure))>,
|
||||
}
|
||||
|
||||
struct DocumentDimensions {
|
||||
|
@ -24,22 +28,31 @@ enum Error {
|
|||
Template(askama::Error),
|
||||
}
|
||||
|
||||
fn positions(
|
||||
fn positions<'a>(
|
||||
keys: &'a Vec<Key>,
|
||||
size: SVGMeasure,
|
||||
margin: SVGMeasure,
|
||||
padding: SVGMeasure,
|
||||
dimensions: &DocumentDimensions,
|
||||
count: u32,
|
||||
) -> Vec<(SVGMeasure, SVGMeasure)> {
|
||||
) -> Vec<(&'a Key<'a>, (SVGMeasure, SVGMeasure))> {
|
||||
let grid = size + padding;
|
||||
let row_count = ((dimensions.width - padding * 2.0) / grid) as u32;
|
||||
(0..count)
|
||||
.map(|i| {
|
||||
(
|
||||
grid * (i % row_count).into() + padding,
|
||||
grid * (i / row_count).into() + padding,
|
||||
)
|
||||
})
|
||||
.collect()
|
||||
let mut x = margin;
|
||||
let mut y = margin;
|
||||
let mut positions = Vec::with_capacity(keys.len());
|
||||
for key in keys {
|
||||
if let Key::Break = key {
|
||||
x = margin;
|
||||
y = y + grid;
|
||||
continue;
|
||||
}
|
||||
if x + grid > dimensions.width - margin {
|
||||
x = margin;
|
||||
y = y + grid;
|
||||
}
|
||||
positions.push((key, (x, y)));
|
||||
x = x + size * key.width_mod() + padding;
|
||||
}
|
||||
positions
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
|
@ -53,13 +66,28 @@ fn main() -> Result<(), Error> {
|
|||
height: SVGMeasure::new(11.0, SVGUnit::Inch),
|
||||
};
|
||||
let box_size = SVGMeasure::new(14.0, SVGUnit::Millimeter);
|
||||
let boxes = 54;
|
||||
let padding = SVGMeasure::new(2.5, SVGUnit::Millimeter);
|
||||
let margin = SVGMeasure::new(0.25, SVGUnit::Inch);
|
||||
let document = DocumentTemplate {
|
||||
positions: positions(box_size, padding, &dimensions, boxes),
|
||||
dimensions,
|
||||
positions: positions(&KEYS, box_size, margin, padding, &dimensions),
|
||||
dimensions: &dimensions,
|
||||
box_size,
|
||||
};
|
||||
write!(file, "{}", document.render()?)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref KEYS: Vec<Key<'static>> = {
|
||||
let mut keys = OYAYUBI.to_vec();
|
||||
keys.push(Key::Break);
|
||||
keys.push(single("親指左", 3.0));
|
||||
keys.push(single("親指右", 3.0));
|
||||
keys.push(Key::Break);
|
||||
keys.push(icon("assets/nixos.svg", 1.0));
|
||||
keys.push(icon("assets/playpause.svg", 1.0));
|
||||
keys.push(icon("assets/previous.svg", 1.0));
|
||||
keys.push(icon("assets/next.svg", 1.0));
|
||||
keys
|
||||
};
|
||||
}
|
|
@ -23,11 +23,11 @@ impl SVGMeasure {
|
|||
Self { measure, unit }
|
||||
}
|
||||
|
||||
fn to_user_units(self) -> f64 {
|
||||
pub fn to_user_units(self) -> f64 {
|
||||
self.measure * self.unit.to_user_units()
|
||||
}
|
||||
|
||||
fn to_unit(self, unit: SVGUnit) -> Self {
|
||||
pub fn to_unit(self, unit: SVGUnit) -> Self {
|
||||
SVGMeasure {
|
||||
measure: self.to_user_units() / unit.to_user_units(),
|
||||
unit,
|
||||
|
|
|
@ -1,7 +1,33 @@
|
|||
<svg version="1.1"
|
||||
width="{{ dimensions.width }}" height="{{ dimensions.height }}"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
{% for (x, y) in positions %}
|
||||
<rect x="{{ x }}" y="{{ y }}" rx="2mm" width="{{ box_size }}" height="{{ box_size }}" fill="none" stroke="#cccccc" stroke-width="1pt" />
|
||||
<defs>
|
||||
<style type="text/css"><![CDATA[@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@700&display=swap');]]></style>
|
||||
</defs>
|
||||
{% for (key, (x, y)) in positions %}
|
||||
{% let width = box_size * key.width_mod() %}
|
||||
<g x="{{ x }}" y="{{ y }}" transform="translate({{ x.to_user_units() }},{{ y.to_user_units() }})" width="{{ width }}" height="{{ box_size }}">
|
||||
<rect width="{{ width }}" height="{{ box_size }}" fill="none" stroke="#cccccc" stroke-width="1pt" rx="2mm" />
|
||||
{% let dy = "0.125em" %}
|
||||
{% match key %}
|
||||
{% when crate::key::Key::Oyayubi with { latin, normal, shift, alt_shift } %}
|
||||
{% let font_size = "0.45cm" %}
|
||||
{% let latin_font_size = "0.4cm" %}
|
||||
{% let alt_shift_font_size = "0.325cm" %}
|
||||
<text x="{{ width * 0.25 }}" y="{{ box_size * 0.25 }}" dominant-baseline="middle" text-anchor="middle" style="font-family: 'M PLUS Rounded 1c'" font-size="{{ latin_font_size }}" dy="{{ dy }}">{{ latin }}</text>
|
||||
<text x="{{ width * 0.75 }}" y="{{ box_size * 0.25 }}" dominant-baseline="middle" text-anchor="middle" style="font-family: 'M PLUS Rounded 1c'" font-size="{{ font_size }}" dy="{{ dy }}">{{ shift }}</text>
|
||||
<text x="{{ width * 0.75 }}" y="{{ box_size * 0.75 }}" dominant-baseline="middle" text-anchor="middle" style="font-family: 'M PLUS Rounded 1c'" font-size="{{ font_size }}" dy="{{ dy }}">{{ normal }}</text>
|
||||
{% if let Some(alt_shift) = alt_shift %}
|
||||
<text x="{{ width / 2.0 }}" y="{{ box_size / 2.0 }}" dominant-baseline="middle" text-anchor="middle" style="font-family: 'M PLUS Rounded 1c'" font-size="{{ alt_shift_font_size }}" dy="{{ dy }}">{{ alt_shift }}</text>
|
||||
{% endif %}
|
||||
{% when crate::key::Key::Single with { text, u } %}
|
||||
{% let font_size = "0.5cm" %}
|
||||
<text x="{{ width * 0.5 }}" y="{{ box_size * 0.5 }}" dominant-baseline="middle" text-anchor="middle" style="font-family: 'M PLUS Rounded 1c'" font-size="{{ font_size }}" dy="{{ dy }}">{{ text }}</text>
|
||||
{% when crate::key::Key::Icon with { icon_path, u } %}
|
||||
{% let icon_width_mm = 7.5 %}
|
||||
<image x="{{ width.measure * 0.5 - icon_width_mm * 0.5 }}mm" y="{{ box_size.measure * 0.5 - icon_width_mm * 0.5 }}mm" href="{{ icon_path }}" width="{{ icon_width_mm }}mm" height="{{ icon_width_mm }}mm" />
|
||||
{% when crate::key::Key::Break %}
|
||||
{% endmatch %}
|
||||
</g>
|
||||
{% endfor %}
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 324 B After Width: | Height: | Size: 2.5 KiB |
Loading…
Add table
Reference in a new issue