Skip to content

Commit

Permalink
Doc comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Corry committed Dec 13, 2023
1 parent 3bc3803 commit 658e451
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/pixel-display.toit
Original file line number Diff line number Diff line change
Expand Up @@ -855,12 +855,26 @@ abstract class Canvas:
if x2 <= 0 and y2 <= 0 and right >= width_ and bottom >= height_: return CANVAS-IN-AREA
return OVERLAP

/**
Given an x position and a width in the coordinate system of the
canvas, calculates the leftmost and rightmost pixels that are visible, so
that superflous drawing operations can be optimized away
The block is called with the left and right pixel positions.
The function may conservatively add a pixel on one side.
*/
visible-x-range x/int w/int [block] -> none:
transform.invert.xywh 0 0 width_ + 1 height_ + 1: | x2 _ w2 _ |
transform.invert.xywh 0 0 (width_ + 1) (height_ + 1): | x2 _ w2 _ |
block.call
max x x2
min (x + w) (x2 + w2)

/**
Given a y position and a height in the coordinate system of the
canvas, calculates the top and bottom pixels that are visible, so
that superflous drawing operations can be optimized away
The block is called with the top and bottom pixel positions.
The function may conservatively add a pixel on one side.
*/
visible-y-range y/int h/int [block] -> none:
transform.invert.xywh 0 0 (width_ + 1) (height_ + 1): | _ y2 _ h2 |
block.call
Expand Down

0 comments on commit 658e451

Please sign in to comment.