Implement Frame::stroke_text in canvas API
This commit is contained in:
parent
8f3bca299b
commit
acde7ea735
4 changed files with 41 additions and 0 deletions
|
|
@ -217,6 +217,11 @@ pub trait Backend: Sized {
|
||||||
size: Size,
|
size: Size,
|
||||||
stroke: impl Into<Stroke<'a>>,
|
stroke: impl Into<Stroke<'a>>,
|
||||||
);
|
);
|
||||||
|
fn stroke_text<'a>(
|
||||||
|
&mut self,
|
||||||
|
text: impl Into<Text>,
|
||||||
|
stroke: impl Into<Stroke<'a>>,
|
||||||
|
);
|
||||||
|
|
||||||
fn fill(&mut self, path: &Path, fill: impl Into<Fill>);
|
fn fill(&mut self, path: &Path, fill: impl Into<Fill>);
|
||||||
fn fill_text(&mut self, text: impl Into<Text>);
|
fn fill_text(&mut self, text: impl Into<Text>);
|
||||||
|
|
@ -272,6 +277,12 @@ impl Backend for () {
|
||||||
_stroke: impl Into<Stroke<'a>>,
|
_stroke: impl Into<Stroke<'a>>,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
fn stroke_text<'a>(
|
||||||
|
&mut self,
|
||||||
|
_text: impl Into<Text>,
|
||||||
|
_stroke: impl Into<Stroke<'a>>,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
fn fill(&mut self, _path: &Path, _fill: impl Into<Fill>) {}
|
fn fill(&mut self, _path: &Path, _fill: impl Into<Fill>) {}
|
||||||
fn fill_text(&mut self, _text: impl Into<Text>) {}
|
fn fill_text(&mut self, _text: impl Into<Text>) {}
|
||||||
|
|
|
||||||
|
|
@ -537,6 +537,14 @@ mod geometry {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn stroke_text<'a>(
|
||||||
|
&mut self,
|
||||||
|
text: impl Into<Text>,
|
||||||
|
stroke: impl Into<Stroke<'a>>,
|
||||||
|
) {
|
||||||
|
delegate!(self, frame, frame.stroke_text(text, stroke));
|
||||||
|
}
|
||||||
|
|
||||||
fn fill_text(&mut self, text: impl Into<Text>) {
|
fn fill_text(&mut self, text: impl Into<Text>) {
|
||||||
delegate!(self, frame, frame.fill_text(text));
|
delegate!(self, frame, frame.fill_text(text));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,17 @@ impl geometry::frame::Backend for Frame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn stroke_text<'a>(
|
||||||
|
&mut self,
|
||||||
|
text: impl Into<geometry::Text>,
|
||||||
|
stroke: impl Into<Stroke<'a>>,
|
||||||
|
) {
|
||||||
|
let text = text.into();
|
||||||
|
let stroke = stroke.into();
|
||||||
|
|
||||||
|
text.draw_with(|path, _color| self.stroke(&path, stroke));
|
||||||
|
}
|
||||||
|
|
||||||
fn push_transform(&mut self) {
|
fn push_transform(&mut self) {
|
||||||
self.stack.push(self.transform);
|
self.stack.push(self.transform);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -291,6 +291,17 @@ impl geometry::frame::Backend for Frame {
|
||||||
.expect("Stroke rectangle");
|
.expect("Stroke rectangle");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn stroke_text<'a>(
|
||||||
|
&mut self,
|
||||||
|
text: impl Into<geometry::Text>,
|
||||||
|
stroke: impl Into<Stroke<'a>>,
|
||||||
|
) {
|
||||||
|
let text = text.into();
|
||||||
|
let stroke = stroke.into();
|
||||||
|
|
||||||
|
text.draw_with(|glyph, _color| self.stroke(&glyph, stroke));
|
||||||
|
}
|
||||||
|
|
||||||
fn fill_text(&mut self, text: impl Into<geometry::Text>) {
|
fn fill_text(&mut self, text: impl Into<geometry::Text>) {
|
||||||
let text = text.into();
|
let text = text.into();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue