diff --git a/clog-canvas.lisp b/clog-canvas.lisp index d7b5d9d..7875ab8 100644 --- a/clog-canvas.lisp +++ b/clog-canvas.lisp @@ -21,12 +21,14 @@ ;; create-canvas ;; ;;;;;;;;;;;;;;;;;;; -(defgeneric create-canvas (clog-obj &key auto-place) +(defgeneric create-canvas (clog-obj &key width height auto-place) (:documentation "Create a new CLOG-Canvas as child of CLOG-OBJ if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ.")) -(defmethod create-canvas ((obj clog-obj) &key (auto-place t)) - (create-child obj "" +(defmethod create-canvas ((obj clog-obj) + &key (width 300) (height 150) (auto-place t)) + (create-child obj (format nil "" + width height) :clog-type 'clog-canvas :auto-place auto-place)) @@ -34,14 +36,7 @@ ;; Implementation - clog-context2d ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defclass clog-context2d () - ((connection-id - :reader connection-id - :initarg :connection-id) - (html-id - :reader html-id - :initarg :html-id)) - (:documentation "CLOG Context Objects.")) +(defclass clog-context2d (clog-obj)()) ;;;;;;;;;;;;;;;;;;;;;; ;; create-context2d ;; @@ -61,4 +56,3 @@ (make-instance 'clog-context2d :connection-id (connection-id obj) :html-id web-id))) - diff --git a/tutorial/10-tutorial.lisp b/tutorial/10-tutorial.lisp index 2f174b6..2332aa7 100644 --- a/tutorial/10-tutorial.lisp +++ b/tutorial/10-tutorial.lisp @@ -5,9 +5,13 @@ (in-package :clog-user) (defun on-new-window (body) - (let* ((canvas (create-canvas body)) + (let* ((canvas (create-canvas body :width 600 :height 400)) (cx (create-context2d canvas))) - ) + + (set-border canvas :thin :solid :black) + + (clog::execute cx "fillStyle='green'") + (clog::execute cx "fillRect(10, 10, 150, 100)")) (run body))