Clojure2d:如果调整了画布大小,则在画布上绘图会默默失败

问题描述 投票:0回答:1

以下代码成功显示带有红色小方块的空白画布:

(ns test-rect
  (:require [clojure2d.core :as c2d])
  (:require '[clojure2d.extra.utils :refer [show-image]]))

(c2d/with-canvas->
  (c2d/canvas 100 100)
;  (c2d/resize 100 100)
  (c2d/set-color :red)
  (c2d/rect 50 50 10 10)
  show-image)

但是,如果我取消对 resize 的调用的注释,则不再绘制红色方块。

clojure java-2d clojure-2d
1个回答
0
投票

resize
创建一个新画布,必须将其传递到自己的
with-canvas

例如:

(let [canvas (c2d/canvas 100 100)]
  (c2d/with-canvas-> (c2d/resize canvas 100 100)
    (c2d/set-color :red)
    (c2d/rect 50 50 10 10)
    show-image))
© www.soinside.com 2019 - 2024. All rights reserved.