Skip to content

Commit 7a57ce2

Browse files
committed
Fix Cohen-Sutherland algorithm implementation for d3d9
1 parent 62fbfcc commit 7a57ce2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

content/src/clip.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,25 +515,25 @@ pub fn clip_line_segment_to_rect(mut line_segment: LineSegment2F, rect: RectF)
515515
point = vec2f(rect.min_x(),
516516
lerp(line_segment.from_y(),
517517
line_segment.to_y(),
518-
(line_segment.min_x() - line_segment.from_x()) /
519-
(line_segment.max_x() - line_segment.min_x())));
518+
(rect.min_x() - line_segment.from_x()) /
519+
(line_segment.to_x() - line_segment.from_x())));
520520
} else if outcode.contains(Outcode::RIGHT) {
521521
point = vec2f(rect.max_x(),
522522
lerp(line_segment.from_y(),
523523
line_segment.to_y(),
524-
(line_segment.max_x() - line_segment.from_x()) /
525-
(line_segment.max_x() - line_segment.min_x())));
524+
(rect.max_x() - line_segment.from_x()) /
525+
(line_segment.to_x() - line_segment.from_x())));
526526
} else if outcode.contains(Outcode::TOP) {
527527
point = vec2f(lerp(line_segment.from_x(),
528528
line_segment.to_x(),
529-
(line_segment.min_y() - line_segment.from_y()) /
530-
(line_segment.max_y() - line_segment.min_y())),
529+
(rect.min_y() - line_segment.from_y()) /
530+
(line_segment.to_y() - line_segment.from_y())),
531531
rect.min_y());
532532
} else if outcode.contains(Outcode::BOTTOM) {
533533
point = vec2f(lerp(line_segment.from_x(),
534534
line_segment.to_x(),
535-
(line_segment.max_y() - line_segment.from_y()) /
536-
(line_segment.max_y() - line_segment.min_y())),
535+
(rect.max_y() - line_segment.from_y()) /
536+
(line_segment.to_y() - line_segment.from_y())),
537537
rect.max_y());
538538
}
539539

0 commit comments

Comments
 (0)