;;;; You should have received a copy of the GNU General Public License
;;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
-(in-package :graphics)
+(in-package :rulp.graphics)
+
+(defparameter *tr-s-rectangle* (sdl2:make-rect 0 0 60 130)) ; FIXME: hardcoded,
+ ; defparameter over
+ ; font for
+ ; generalization
+(defparameter *tr-d-rectangle* (sdl2:make-rect 0 0 10 10))
(defun coordinate-to-grid-index (value)
"translate a coordinate into the chess coordinate as a string"
`(let ((value-indexes (tr-parse-string ,value)))
(loop :for character :in value-indexes
:for character-position :from 0 :to (length value-indexes)
- :do (let ((source-rectangle (sdl2:make-rect (* character 60) 0 60 130))
- (destination-rectangle (sdl2:make-rect (+ ,x (* character-position ,width)) ,y ,width ,height)))
- (sdl2:render-copy ,renderer *tr-texture*
- :source-rect source-rectangle
- :dest-rect destination-rectangle)
- (sdl2:free-rect source-rectangle)
- (sdl2:free-rect destination-rectangle)))))
+ :do (setf (sdl2:rect-x *tr-s-rectangle*) (* character 60)
+ (sdl2:rect-x *tr-d-rectangle*) (+ ,x (* character-position ,width))
+ (sdl2:rect-y *tr-d-rectangle*) ,y
+ (sdl2:rect-width *tr-d-rectangle*) ,width
+ (sdl2:rect-height *tr-d-rectangle*) ,height)
+ (sdl2:render-copy ,renderer *tr-texture*
+ :source-rect *tr-s-rectangle*
+ :dest-rect *tr-d-rectangle*))))