pub struct Easel {
    pub mouse: Enigo,
    pub mouse_wait: Duration,
    pub easel_coords: EaselCoords,
    pub orientation: Orientation,
    pub brush_size: i32,
    pub current_color: PaletteColor,
    pub current_tool: Tool,
}
Expand description

A structure keeping track of the current state of the easel and provides means to change the state of the easel via mouse clicks.

Fields

mouse: Enigo

The object for manipulating the mouse.

mouse_wait: Duration

The amount of time to wait between mouse moves and clicks.

easel_coords: EaselCoords

A mapping of where elements of the easel are in screen coordinates.

orientation: Orientation

The current orientation of the easel: landscape or portrait.

brush_size: i32

The current brush size.

current_color: PaletteColor

The active color of the brush.

current_tool: Tool

The active tool for drawing.

Implementations

Create a new easel. When creating a new easel, it’s important to set the mouse wait properly. If you start seeing lines being drawn from the easel towards the color palette, you likely need to increase the mouse wait time.

Initial experimentation has shown that, regardless of FPS, anything lower than 6 ms causes the game to not recognize that the mouse button has been released and will make many, many mistakes in drawing.

Arguments
  • path: Path to the JSON file containing the coordinates of easel elements in-game.
  • mouse: An Enigo structure used to manipulate the mouse position.
  • mouse_wait: The time to wait between mouse operations.

Toggles the orientation of the easel.

Changes the current tool.

Returns the current bounds of the easel in screen coordinates.

Changes from the current color to the desired color. Does nothing if the current color is the same as the desired color.

Changes the brush size in fixed steps by clicking on the brushes to increase or decrease the size.

Arguments
  • brush_size - The size from 0 to NUM_BRUSH_STEPS to change the brush size to.
Example
use enigo::*;
use passpartout_printer::easel::Easel;
use std::time::Duration;
use std::error::Error;

let mut easel = Easel::new("coords.json".into(), Enigo::new(), Duration::from_millis(6))?;
easel.change_brush_size(0); // shrinks the brush to its minimum size

Draws a line on the easel of the particular color.

Arguments
  • start_line: The starting point of the line in image coordinates.
  • end_line: The end point of the line in image coordinates.
  • color: The color of the line.
Example
use passpartout_printer::{
    easel::Easel,
    coords::Coord,
    colors::PaletteColor,
};
use enigo::*;
use std::time::Duration;
use image::Rgba;
use std::error::Error;

// Draw a black diagonal line from the upper-left corner
// 100 pixels away.
let mut easel = Easel::new("coords.json".into(), Enigo::new(), Duration::from_millis(6))?;
let color = PaletteColor::Black;
let start = Coord::new(0, 0);
let end = Coord::new(100, 100);
easel.draw_line(start, end, &color);

Draws an arbitrary shape to the easel. This draws the shape as one continuous stroke.

Arguments
  • points: The points defining the polygon.
  • color: The color of the shape.
  • close_shape: Whether or not to connect the first and last points.
  • fill: Whether or not to fill the shape. Implies close_shape.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.