Skip to content

Commit a630fd8

Browse files
Remove unused API
1 parent 669f7b5 commit a630fd8

2 files changed

Lines changed: 17 additions & 16 deletions

File tree

src/renderer/app_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<'a> AppState<'a> {
157157
let (edge_x, edge_y) = self.mouse_state.position();
158158
let radius = compute_distance(pixel_coord, (edge_x, edge_y));
159159

160-
let circle = Circle::from_pixel_coordinate(
160+
let circle = Circle::from_pixel_space(
161161
pixel_coord,
162162
radius,
163163
(self.size.width as f32, self.size.height as f32),

src/renderer/shape.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl EditorState {
113113
) -> Option<&Element> {
114114
self.element_stack.iter().rev().find(|e| {
115115
let circle = e.inner();
116-
let circle_in_pixel_coords = circle.convert_into_pixel_coordinate(window_dimension);
116+
let circle_in_pixel_coords = circle.in_pixel_space(window_dimension);
117117

118118
compute_distance(circle_in_pixel_coords.center(), point)
119119
<= circle_in_pixel_coords.radius()
@@ -161,9 +161,9 @@ impl EditorState {
161161

162162
pub fn copy_shape(&mut self, circle: Circle, window_dimensions: (f32, f32)) -> usize {
163163
let circle = circle
164-
.convert_into_pixel_coordinate(window_dimensions)
164+
.in_pixel_space(window_dimensions)
165165
.translate((40.0, 40.0))
166-
.convert_into_normalized_coordinate(window_dimensions);
166+
.in_normalized_space(window_dimensions);
167167

168168
self.create_shape(circle)
169169
}
@@ -175,30 +175,31 @@ pub fn compute_distance(from: Coordinate, to: Coordinate) -> f32 {
175175

176176
// Stored as (x, y)
177177
pub type Coordinate = (f32, f32);
178+
pub type WindowDimension = (f32, f32);
178179

179-
#[derive(Debug, Clone)]
180+
#[derive(Debug, Clone, Copy)]
180181
pub struct Circle {
181182
center: Coordinate,
182183
radius: f32,
183184
}
184185

185186
impl Circle {
186-
pub fn from_pixel_coordinate(
187-
center: Coordinate,
188-
radius: f32,
189-
window_dimensions: (f32, f32),
187+
pub fn from_pixel_space(
188+
center_in_pixel_space: Coordinate,
189+
radius_in_pixel_space: f32,
190+
window_dimension: WindowDimension,
190191
) -> Self {
191-
let (w, h) = window_dimensions;
192-
let (cx, cy) = center;
192+
let (w, h) = window_dimension;
193+
let (cx, cy) = center_in_pixel_space;
193194

194195
Self {
195196
center: (cx / w, cy / h),
196-
radius: radius / w.min(h),
197+
radius: radius_in_pixel_space / w.min(h),
197198
}
198199
}
199200

200-
pub fn convert_into_normalized_coordinate(&self, window_dimensions: (f32, f32)) -> Self {
201-
let (w, h) = window_dimensions;
201+
pub fn in_normalized_space(&self, window_dimension: WindowDimension) -> Self {
202+
let (w, h) = window_dimension;
202203
let (cx, cy) = self.center;
203204

204205
Self {
@@ -207,8 +208,8 @@ impl Circle {
207208
}
208209
}
209210

210-
pub fn convert_into_pixel_coordinate(&self, window_dimensions: (f32, f32)) -> Self {
211-
let (w, h) = window_dimensions;
211+
pub fn in_pixel_space(&self, window_dimension: WindowDimension) -> Self {
212+
let (w, h) = window_dimension;
212213
let (cx, cy) = self.center;
213214

214215
Self {

0 commit comments

Comments
 (0)