| 97 | | |
|---|
| 98 | | (defclass allocation-area-gfx-handler (editor-only-handler object-handler) |
|---|
| 99 | | ()) |
|---|
| 100 | | |
|---|
| 101 | | (defmethod handle-object ((handler allocation-area-gfx-handler) allocation-area) |
|---|
| 102 | | (cl-gd:with-image* ((allocation-area-width allocation-area) |
|---|
| 103 | | (allocation-area-height allocation-area) t) |
|---|
| 104 | | (with-slots (left top width height) allocation-area |
|---|
| 105 | | (let ((colors (make-vga-colors)) |
|---|
| 106 | | (vertices (mapcan #'(lambda (point) (list (- (car point) left) |
|---|
| 107 | | (- (cdr point) top))) |
|---|
| 108 | | (coerce (allocation-area-vertices allocation-area) 'list)))) |
|---|
| 109 | | (loop with dest-y = 0 |
|---|
| 110 | | for y = (+ top dest-y) |
|---|
| 111 | | for tile-y = (* 90 (floor y 90)) |
|---|
| 112 | | until (> tile-y (+ top height)) |
|---|
| 113 | | for copy-height = (cond |
|---|
| 114 | | ((< tile-y top) |
|---|
| 115 | | (+ 90 (- tile-y top))) |
|---|
| 116 | | ((> (+ tile-y 90) (+ top height)) |
|---|
| 117 | | (- (+ tile-y 90) (+ top height))) |
|---|
| 118 | | (t |
|---|
| 119 | | 90)) |
|---|
| 120 | | for source-y = (if (< tile-y top) (- 90 copy-height) 0) |
|---|
| 121 | | do (loop with dest-x = 0 |
|---|
| 122 | | for x = (+ left dest-x) |
|---|
| 123 | | for tile-x = (* 90 (floor x 90)) |
|---|
| 124 | | until (> tile-x (+ left width)) |
|---|
| 125 | | for copy-width = (cond |
|---|
| 126 | | ((< tile-x left) |
|---|
| 127 | | (+ 90 (- tile-x left))) |
|---|
| 128 | | ((> (+ tile-x 90) (+ left width)) |
|---|
| 129 | | (- (+ tile-x 90) (+ left width))) |
|---|
| 130 | | (t |
|---|
| 131 | | 90)) |
|---|
| 132 | | for source-x = (if (< tile-x left) (- 90 copy-width) 0) |
|---|
| 133 | | do (cl-gd:copy-image (image-tile-image (get-map-tile x y)) |
|---|
| 134 | | cl-gd:*default-image* |
|---|
| 135 | | source-x source-y |
|---|
| 136 | | dest-x dest-y |
|---|
| 137 | | copy-width copy-height) |
|---|
| 138 | | do (incf dest-x copy-width)) |
|---|
| 139 | | do (incf dest-y copy-height)) |
|---|
| 140 | | (cl-gd:draw-polygon vertices :color (elt colors 1)) |
|---|
| 141 | | (emit-image-to-browser cl-gd:*default-image* :png))))) |
|---|