diff --git a/modules/png/graphics/filled-rectangle.scm b/modules/png/graphics/filled-rectangle.scm index d9fd6d0..f622a79 100644 --- a/modules/png/graphics/filled-rectangle.scm +++ b/modules/png/graphics/filled-rectangle.scm @@ -1,6 +1,6 @@ ;;; filled-rectangle.scm -- Filled rectangle implementation. -;; Copyright (C) 2022 Artyom V. Poptsov +;; Copyright (C) 2022-2023 Artyom V. Poptsov ;; ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -26,6 +26,7 @@ (define-module (png graphics filled-rectangle) #:use-module (oop goops) #:use-module (png image) + #:use-module (png core common) #:use-module (png graphics graphic) #:use-module (png graphics pixel) #:use-module (png graphics point) @@ -42,6 +43,20 @@ (define filled-rectangle-height rectangle-height) (define filled-rectangle-width rectangle-width) + +(define-method (%display (filled-rectangle ) (port )) + (format port "#" + (filled-rectangle-position filled-rectangle) + (filled-rectangle-width filled-rectangle) + (filled-rectangle-height filled-rectangle) + (object-address/hex-string filled-rectangle))) + +(define-method (display (filled-rectangle ) (port )) + (%display filled-rectangle port)) + +(define-method (write (filled-rectangle ) (port )) + (%display filled-rectangle port)) + (define-method (draw! (image ) (rectangle )) (let* ((position (rectangle-position rectangle)) diff --git a/tests/graphics.scm b/tests/graphics.scm index f43b74d..5698f41 100644 --- a/tests/graphics.scm +++ b/tests/graphics.scm @@ -244,6 +244,18 @@ #:width 50 #:height 100))))) + +;; Filled rectangle. + +(test-assert ": display" + (with-output-to-string + (lambda () + (display + (make + #:position (make #:x 100 #:y 200) + #:width 50 + #:height 100))))) + ;; Multiline.