aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cargo_vcs_info.json7
-rw-r--r--.github/dependabot.yml7
-rw-r--r--Android.bp8
-rw-r--r--Cargo.toml33
-rw-r--r--Cargo.toml.orig22
-rw-r--r--METADATA14
-rw-r--r--src/svg.rs57
7 files changed, 88 insertions, 60 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 58b45c5..4ee3b83 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,6 @@
{
"git": {
- "sha1": "47289e89a1078f330fcb6a3886b0ae34dc3f69e2"
- }
-}
+ "sha1": "740a302591a902b11398d32926365330927b9372"
+ },
+ "path_in_vcs": "plotters-svg"
+} \ No newline at end of file
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
deleted file mode 100644
index 5cde165..0000000
--- a/.github/dependabot.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-version: 2
-updates:
-- package-ecosystem: cargo
- directory: "/"
- schedule:
- interval: daily
- open-pull-requests-limit: 10
diff --git a/Android.bp b/Android.bp
index 3df1865..00131e9 100644
--- a/Android.bp
+++ b/Android.bp
@@ -23,10 +23,16 @@ rust_library {
host_supported: true,
crate_name: "plotters_svg",
cargo_env_compat: true,
- cargo_pkg_version: "0.3.1",
+ cargo_pkg_version: "0.3.3",
srcs: ["src/lib.rs"],
edition: "2018",
rustlibs: [
"libplotters_backend",
],
+ apex_available: [
+ "//apex_available:platform",
+ "//apex_available:anyapex",
+ ],
+ product_available: true,
+ vendor_available: true,
}
diff --git a/Cargo.toml b/Cargo.toml
index c4a7dbb..011f0ad 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,29 +3,38 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies
+# to registry (e.g., crates.io) dependencies.
#
-# If you believe there's an error in this file please file an
-# issue against the rust-lang/cargo repository. If you're
-# editing this file be aware that the upstream Cargo.toml
-# will likely look very different (and much more reasonable)
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "plotters-svg"
-version = "0.3.1"
+version = "0.3.3"
authors = ["Hao Hou <haohou302@gmail.com>"]
description = "Plotters SVG backend"
homepage = "https://plotters-rs.github.io"
readme = "README.md"
license = "MIT"
-repository = "https://github.com/plotters-rs/plotters-svg.git"
+repository = "https://github.com/plotters-rs/plotters.git"
+
+[dependencies.image]
+version = "0.24.2"
+features = [
+ "jpeg",
+ "png",
+ "bmp",
+]
+optional = true
+default-features = false
+
[dependencies.plotters-backend]
-version = "^0.3.*"
-[dev-dependencies.plotters]
-version = "^0.3.0"
-features = ["ttf"]
-default_features = false
+version = "0.3"
+
+[dev-dependencies]
[features]
+bitmap_encoder = ["image"]
debug = []
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 516f314..dfdc2cd 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,21 +1,31 @@
[package]
name = "plotters-svg"
-version = "0.3.1"
+version = "0.3.3"
authors = ["Hao Hou <haohou302@gmail.com>"]
edition = "2018"
license = "MIT"
description = "Plotters SVG backend"
homepage = "https://plotters-rs.github.io"
-repository = "https://github.com/plotters-rs/plotters-svg.git"
+repository = "https://github.com/plotters-rs/plotters.git"
readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-[dependencies]
-plotters-backend = "^0.3.*"
+[dependencies.plotters-backend]
+#path = "../plotters-backend"
+version = "0.3"
+
+[dependencies.image]
+version = "0.24.2"
+optional = true
+default-features = false
+features = ["jpeg", "png", "bmp"]
[features]
debug = []
+bitmap_encoder = ["image"]
-[dev-dependencies]
-plotters = {version = "^0.3.0", default_features = false, features = ["ttf"]}
+[dev-dependencies.plotters]
+default_features = false
+features = ["ttf"]
+path = "../plotters"
diff --git a/METADATA b/METADATA
index c2d4460..9f51ecd 100644
--- a/METADATA
+++ b/METADATA
@@ -1,3 +1,7 @@
+# This project was upgraded with external_updater.
+# Usage: tools/external_updater/updater.sh update rust/crates/plotters-svg
+# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+
name: "plotters-svg"
description: "Plotters SVG backend"
third_party {
@@ -7,13 +11,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/plotters-svg/plotters-svg-0.3.1.crate"
+ value: "https://static.crates.io/crates/plotters-svg/plotters-svg-0.3.3.crate"
}
- version: "0.3.1"
+ version: "0.3.3"
license_type: NOTICE
last_upgrade_date {
- year: 2021
- month: 8
- day: 9
+ year: 2022
+ month: 12
+ day: 13
}
}
diff --git a/src/svg.rs b/src/svg.rs
index 02bba02..43bf36a 100644
--- a/src/svg.rs
+++ b/src/svg.rs
@@ -13,6 +13,7 @@ use std::fs::File;
use std::io::Cursor;
use std::io::{BufWriter, Error, Write};
use std::path::Path;
+use std::fmt::Write as _;
fn make_svg_color(color: BackendColor) -> String {
let (r, g, b) = color.rgb;
@@ -45,7 +46,7 @@ impl Target<'_> {
}
enum SVGTag {
- SVG,
+ Svg,
Circle,
Line,
Polygon,
@@ -59,7 +60,7 @@ enum SVGTag {
impl SVGTag {
fn to_tag_name(&self) -> &'static str {
match self {
- SVGTag::SVG => "svg",
+ SVGTag::Svg => "svg",
SVGTag::Circle => "circle",
SVGTag::Line => "line",
SVGTag::Polyline => "polyline",
@@ -92,14 +93,14 @@ impl<'a> SVGBackend<'a> {
}
fn open_tag(&mut self, tag: SVGTag, attr: &[(&str, &str)], close: bool) {
let buf = self.target.get_mut();
- buf.push_str("<");
+ buf.push('<');
buf.push_str(tag.to_tag_name());
for (key, value) in attr {
- buf.push_str(" ");
+ buf.push(' ');
buf.push_str(key);
buf.push_str("=\"");
Self::escape_and_push(buf, value);
- buf.push_str("\"");
+ buf.push('\"');
}
if close {
buf.push_str("/>\n");
@@ -122,7 +123,7 @@ impl<'a> SVGBackend<'a> {
fn init_svg_file(&mut self, size: (u32, u32)) {
self.open_tag(
- SVGTag::SVG,
+ SVGTag::Svg,
&[
("width", &format!("{}", size.0)),
("height", &format!("{}", size.1)),
@@ -314,7 +315,7 @@ impl<'a> DrawingBackend for SVGBackend<'a> {
(
"points",
&path.into_iter().fold(String::new(), |mut s, (x, y)| {
- s.push_str(&format!("{},{} ", x, y));
+ write!(s, "{},{} ", x, y).ok();
s
}),
),
@@ -340,7 +341,7 @@ impl<'a> DrawingBackend for SVGBackend<'a> {
(
"points",
&path.into_iter().fold(String::new(), |mut s, (x, y)| {
- s.push_str(&format!("{},{} ", x, y));
+ write!(s, "{},{} ", x, y).ok();
s
}),
),
@@ -472,7 +473,7 @@ impl<'a> DrawingBackend for SVGBackend<'a> {
);
Self::escape_and_push(self.target.get_mut(), text);
- self.target.get_mut().push_str("\n");
+ self.target.get_mut().push('\n');
self.close_tag();
@@ -486,18 +487,19 @@ impl<'a> DrawingBackend for SVGBackend<'a> {
(w, h): (u32, u32),
src: &'b [u8],
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
- use image::png::PNGEncoder;
+ use image::codecs::png::PngEncoder;
+ use image::ImageEncoder;
let mut data = vec![0; 0];
{
let cursor = Cursor::new(&mut data);
- let encoder = PNGEncoder::new(cursor);
+ let encoder = PngEncoder::new(cursor);
- let color = image::ColorType::RGB(8);
+ let color = image::ColorType::Rgb8;
- encoder.encode(src, w, h, color).map_err(|e| {
+ encoder.write_image(src, w, h, color).map_err(|e| {
DrawingErrorKind::DrawingError(Error::new(
std::io::ErrorKind::Other,
format!("Image error: {}", e),
@@ -578,7 +580,10 @@ impl Drop for SVGBackend<'_> {
mod test {
use super::*;
use plotters::element::Circle;
- use plotters::prelude::*;
+ use plotters::prelude::{
+ ChartBuilder, Color, IntoDrawingArea, IntoFont, SeriesLabelPosition, TextStyle, BLACK,
+ BLUE, RED, WHITE,
+ };
use plotters::style::text_anchor::{HPos, Pos, VPos};
use std::fs;
use std::path::Path;
@@ -603,8 +608,8 @@ mod test {
let root = SVGBackend::with_string(&mut content, (500, 500)).into_drawing_area();
let mut chart = ChartBuilder::on(&root)
- .caption("This is a test", ("sans-serif", 20))
- .set_all_label_area_size(40)
+ .caption("This is a test", ("sans-serif", 20u32))
+ .set_all_label_area_size(40u32)
.build_cartesian_2d(0..10, 0..10)
.unwrap();
@@ -674,9 +679,9 @@ mod test {
.unwrap();
let mut chart = ChartBuilder::on(&root)
- .caption("All anchor point positions", ("sans-serif", 20))
- .set_all_label_area_size(40)
- .build_cartesian_2d(0..100, 0..50)
+ .caption("All anchor point positions", ("sans-serif", 20u32))
+ .set_all_label_area_size(40u32)
+ .build_cartesian_2d(0..100i32, 0..50i32)
.unwrap();
chart
@@ -763,9 +768,9 @@ mod test {
let root = SVGBackend::with_string(&mut content, (width, height)).into_drawing_area();
let mut chart = ChartBuilder::on(&root)
- .caption("All series label positions", ("sans-serif", 20))
- .set_all_label_area_size(40)
- .build_cartesian_2d(0..50, 0..50)
+ .caption("All series label positions", ("sans-serif", 20u32))
+ .set_all_label_area_size(40u32)
+ .build_cartesian_2d(0..50i32, 0..50i32)
.unwrap();
chart
@@ -776,16 +781,16 @@ mod test {
.unwrap();
chart
- .draw_series(std::iter::once(Circle::new((5, 15), 5, &RED)))
+ .draw_series(std::iter::once(Circle::new((5, 15), 5u32, &RED)))
.expect("Drawing error")
.label("Series 1")
- .legend(|(x, y)| Circle::new((x, y), 3, RED.filled()));
+ .legend(|(x, y)| Circle::new((x, y), 3u32, RED.filled()));
chart
- .draw_series(std::iter::once(Circle::new((5, 15), 10, &BLUE)))
+ .draw_series(std::iter::once(Circle::new((5, 15), 10u32, &BLUE)))
.expect("Drawing error")
.label("Series 2")
- .legend(|(x, y)| Circle::new((x, y), 3, BLUE.filled()));
+ .legend(|(x, y)| Circle::new((x, y), 3u32, BLUE.filled()));
for pos in vec![
SeriesLabelPosition::UpperLeft,