Skip to content

Fix typo in README.md #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ The following list is a complete list of features that can be opt in and out.

| Name | Description | Additional Dependency |Default?|
|---------|--------------|--------|------------|
| datetime | Eanble the date and time coordinate support | chrono | Yes |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This readme is automatically generated with doc-template/readme.template.md. If you don't mind could you please change it there and run the doc-template/update-readme.sh please. Thanks!

| datetime | Enable the date and time coordinate support | chrono | Yes |

- Element, series and util functions

Expand Down
20 changes: 19 additions & 1 deletion src/drawing/backend_impl/piston.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ fn make_point_pair(a: BackendCoord, b: BackendCoord, scale: f64) -> [f64; 4] {
]
}

fn make_circle(center: BackendCoord, radius: u32, scale: f64) -> [f64; 4] {
circle(
center.0 as f64 * scale,
center.1 as f64 * scale,
radius as f64 * scale,
)
}

impl<'a, 'b> PistonBackend<'a, 'b> {
pub fn new(size: (u32, u32), scale: f64, context: Context, graphics: &'b mut G2d<'a>) -> Self {
Self {
Expand Down Expand Up @@ -150,7 +158,7 @@ impl<'a, 'b> DrawingBackend for PistonBackend<'a, 'b> {
style: &S,
fill: bool,
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
let rect = circle(center.0 as f64, center.1 as f64, radius as f64);
let rect = make_circle(center, radius, self.scale);
if fill {
ellipse(
make_piston_rgba(&style.as_color()),
Expand Down Expand Up @@ -204,3 +212,13 @@ pub fn draw_piston_window<F: FnOnce(PistonBackend) -> Result<(), Box<dyn std::er
}
None
}

#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_make_circle() {
assert_eq!(make_circle((1, 1), 0, 1.0), [1.0, 1.0, 0.0, 0.0]);
assert_eq!(make_circle((1, 2), 3, 4.0), [-8.0, -4.0, 24.0, 24.0]);
}
}