A lens draws what is under it finer, not bigger
Magnifying the pixels under a lens showed each one as a block, so a fine line went to two pixels wide and a curve to steps. What is under a lens is the ops drawn before it in its buffer, so it now draws them again, as many times finer as it magnifies, over the box it reads from, and reads that: the picture bending the shapes would give, through the same rasteriser, so knockouts, stencils and remaps under it are what they were. A raster has a :scale for it beside its :origin. The redraw is at most four times finer and four stages' worth of pixels; a warp that magnifies nothing reads the buffer as it is. A fill also skips a shape wholly to one side of its raster rather than walking every row to find that out, which is most of what a redraw over a small box would otherwise cost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5f3c97431e
commit
943dc93d7d
2 changed files with 175 additions and 61 deletions
|
|
@ -54,6 +54,17 @@
|
|||
(is (= [:lens] (pick/hit (:ops d) [12 12] [:lens]))
|
||||
"unless the glass is what is selected, which is how it is dragged")))
|
||||
|
||||
(deftest a-lens-draws-what-is-under-it-finer-not-bigger
|
||||
;; A line half a pixel wide is one pixel on the stage, and twice the size it
|
||||
;; is one pixel still: magnifying the pixel would make it two. The lens's
|
||||
;; middle is over the line, where it magnifies twice.
|
||||
(let [line [:line (sq 20.2 10 20.7 30) 4]
|
||||
glass [:lens (sq 10 10 30 30) [:warp :lens]]
|
||||
d (drawn (shapes wall line glass))
|
||||
across (row d 20 17 24)]
|
||||
(is (= [2 2 2 2 4 2 2 2 2] (row (drawn (shapes wall line)) 20 16 25)) "one pixel without the lens")
|
||||
(is (= 1 (count (filter #{4} across))) (str "and one under it: " across))))
|
||||
|
||||
(deftest a-lens-bulges-and-has-no-seam
|
||||
;; A round glass of radius 10 about (50, 50): magnified in the middle, as it
|
||||
;; is at its rim and outside it, and squeezed in between.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue