|
79 | 79 | (query obj "fillStyle"))
|
80 | 80 |
|
81 | 81 | (defmethod (setf fill-style) (value (obj clog-context2d))
|
82 |
| - (execute obj (format nil "fillStyle='~A'" value))) |
| 82 | + (execute obj (format nil "fillStyle=~A" |
| 83 | + (if (typep value 'clog-obj) |
| 84 | + (script-id value) |
| 85 | + (format nil "'~A'" value))))) |
83 | 86 |
|
84 | 87 | ;;;;;;;;;;;;;;;;;;;
|
85 | 88 | ;; canvas-filter ;;
|
@@ -448,12 +451,64 @@ https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/global
|
448 | 451 | :connection-id (clog::connection-id obj)
|
449 | 452 | :html-id web-id)))
|
450 | 453 |
|
451 |
| -;; createConicGradient |
452 |
| -;; need to add createLinearGradient |
453 |
| -;; need to add createRadialGradient |
454 |
| -;; need to add createPattern |
| 454 | +;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 455 | +;; create-conic-gradient ;; |
| 456 | +;;;;;;;;;;;;;;;;;;;;;;;;;;; |
455 | 457 |
|
456 |
| -;; drawFocusIfNeeded |
| 458 | +(defgeneric create-conic-gradient (clog-context2d start-angle x y) |
| 459 | + (:documentation "Create conic gradient")) |
| 460 | + |
| 461 | +(defmethod create-conic-gradient ((obj clog-context2d) start-angle x y) |
| 462 | + (let ((web-id (clog-connection:generate-id))) |
| 463 | + (js-execute obj (format nil "clog['~A']=~A.createConicGradient(~A,~A,~A)" |
| 464 | + web-id (script-id obj) |
| 465 | + start-angle x y)) |
| 466 | + (make-instance 'clog-canvas-gradient |
| 467 | + :connection-id (clog::connection-id obj) |
| 468 | + :html-id web-id))) |
| 469 | + |
| 470 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 471 | +;; create-linear-gradient ;; |
| 472 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 473 | + |
| 474 | +(defgeneric create-linear-gradient (clog-context2d x0 y0 x1 y1) |
| 475 | + (:documentation "Create linear gradient")) |
| 476 | + |
| 477 | +(defmethod create-linear-gradient ((obj clog-context2d) x0 y0 x1 y1) |
| 478 | + (let ((web-id (clog-connection:generate-id))) |
| 479 | + (js-execute obj (format nil "clog['~A']=~A.createLinearGradient(~A,~A,~A,~A)" |
| 480 | + web-id (script-id obj) |
| 481 | + x0 y0 x1 y1)) |
| 482 | + (make-instance 'clog-canvas-gradient |
| 483 | + :connection-id (clog::connection-id obj) |
| 484 | + :html-id web-id))) |
| 485 | + |
| 486 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 487 | +;; create-radial-gradient ;; |
| 488 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 489 | + |
| 490 | +(defgeneric create-radial-gradient (clog-context2d x0 y0 r0 x1 y1 r1) |
| 491 | + (:documentation "Create radial gradient")) |
| 492 | + |
| 493 | +(defmethod create-radial-gradient ((obj clog-context2d) x0 y0 r0 x1 y1 r1) |
| 494 | + (let ((web-id (clog-connection:generate-id))) |
| 495 | + (js-execute obj (format nil "clog['~A']=~A.createRadialGradient(~A,~A,~A,~A,~A,~A)" |
| 496 | + web-id (script-id obj) |
| 497 | + x0 y0 r0 x1 y1 r1)) |
| 498 | + (make-instance 'clog-canvas-gradient |
| 499 | + :connection-id (clog::connection-id obj) |
| 500 | + :html-id web-id))) |
| 501 | + |
| 502 | +;;;;;;;;;;;;;;;;;;;; |
| 503 | +;; create-pattern ;; |
| 504 | +;;;;;;;;;;;;;;;;;;;; |
| 505 | + |
| 506 | +(defgeneric create-pattern (clog-context2d clog-obj repetition) |
| 507 | + (:Documentation "Create pattern")) |
| 508 | + |
| 509 | +(defmethod create-pattern ((obj clog-context2d) clog-obj repetition) |
| 510 | + (execute obj (format nil "createPattern(~A,'~A')" |
| 511 | + (script-id clog-obj) repetition))) |
457 | 512 |
|
458 | 513 | ;;;;;;;;;;;;;;;;
|
459 | 514 | ;; draw-image ;;
|
@@ -807,6 +862,22 @@ https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/global
|
807 | 862 | (defmethod translate ((obj clog-context2d) x y)
|
808 | 863 | (execute obj (format nil "translate(~A,~A)" x y)))
|
809 | 864 |
|
| 865 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 866 | +;; Implementation - clog-canvas-gradient |
| 867 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 868 | + |
| 869 | +(defclass clog-canvas-gradient (clog-obj)()) |
| 870 | + |
| 871 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 872 | +;; Methods - clog-canvas-gradient |
| 873 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 874 | + |
| 875 | +(defgeneric add-color-stop (clog-canvas-gradient offset color) |
| 876 | + (:documentation "Add a color stop")) |
| 877 | + |
| 878 | +(defmethod add-color-stop ((obj clog-canvas-gradient) offset color) |
| 879 | + (execute obj (format nil "addColorStop(~A,'~A')" offset color))) |
| 880 | + |
810 | 881 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
811 | 882 | ;; Implementation - clog-image-data
|
812 | 883 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
@@ -919,9 +990,9 @@ https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/global
|
919 | 990 |
|
920 | 991 | (defclass clog-path2d (clog-obj)())
|
921 | 992 |
|
922 |
| -;;;;;;;;;;;;;;;;;;;;;; |
| 993 | +;;;;;;;;;;;;;;;;;;; |
923 | 994 | ;; create-path2d ;;
|
924 |
| -;;;;;;;;;;;;;;;;;;;;;; |
| 995 | +;;;;;;;;;;;;;;;;;;; |
925 | 996 |
|
926 | 997 | (defgeneric create-path2d (clog-canvas &key path2d)
|
927 | 998 | (:documentation "Create a new CLOG-Path2d. If CLOG-PATH2D creates a copy."))
|
|
0 commit comments