mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-18 18:38:05 +08:00
Another round of polishing (#101)
* Implement basic refactorings * Simplify some match statements * Rename `ix` to `index` If we're not going with a single letter name, then a full word makes more sense. * Rename `as_hex` to `to_hex` `as_` implies lossless reinterpretation while the function does a conversion that loses information * Replace `for_each` with for loops for loops are a lot easier to read and maintain. * factor out x and y coords in Line::render this is arguably more ergonomic * Remove redundant `format!(format_args!())`
This commit is contained in:
committed by
Keavon Chambers
parent
c9fea54ec5
commit
47458115b8
@@ -62,7 +62,7 @@ impl std::fmt::Display for ShapePoints {
|
||||
#[doc(hidden)]
|
||||
pub struct ShapePathIter {
|
||||
shape: ShapePoints,
|
||||
ix: usize,
|
||||
index: usize,
|
||||
}
|
||||
|
||||
impl Iterator for ShapePathIter {
|
||||
@@ -74,11 +74,11 @@ impl Iterator for ShapePathIter {
|
||||
let sine = theta.sin();
|
||||
Vec2::new(v.x * cosine - v.y * sine, v.x * sine + v.y * cosine)
|
||||
}
|
||||
self.ix += 1;
|
||||
match self.ix {
|
||||
self.index += 1;
|
||||
match self.index {
|
||||
1 => Some(PathEl::MoveTo(self.shape.center + self.shape.extent)),
|
||||
_ => {
|
||||
let radians = self.shape.apothem_offset_angle() * ((self.ix * 2 + (self.shape.sides % 2) as usize) as f64);
|
||||
let radians = self.shape.apothem_offset_angle() * ((self.index * 2 + (self.shape.sides % 2) as usize) as f64);
|
||||
let offset = rotate(&self.shape.extent, radians);
|
||||
let point = self.shape.center + offset;
|
||||
Some(PathEl::LineTo(point))
|
||||
|
||||
Reference in New Issue
Block a user