gpt4 book ai didi

canvas - Canvas 的宽度有限制吗

转载 作者:行者123 更新时间:2023-12-02 08:18:28 24 4
gpt4 key购买 nike

Canvas 的“宽度”属性值有限制吗?

在下面的示例中,我在 ScrolledWindow 中创建一个 Canvas。

# Packages
package require BWidget

# Mainframe
set mfr [MainFrame .mfr -textvariable "Test"]
pack $mfr -fill both -expand yes

# Create a Paned Window with two panes
set pw1 [PanedWindow [$mfr getframe].pw1 -side left]
set pat [$pw1 add -minsize 200]
set pai [$pw1 add -minsize 200]
pack $pw1 -fill both -expand yes -anchor nw

# Create a frame for each pane
set tft [TitleFrame $pat.tft -text "Scrollable Canvas"]
set tfi [TitleFrame $pai.tfi -text "Informations"]
pack $tft -fill both -expand yes -anchor nw
pack $tfi -fill both -expand yes -anchor nw

# Create a canvas inside a ScrolledWindow for the first pane
set swt [ScrolledWindow [$tft getframe].swt -relief sunken -borderwidth 2 -scrollbar horizontal -auto none]
set sft [ScrollableFrame $swt.sft -width 50000 -height 200]
$swt setwidget $sft
set tab [canvas [$sft getframe].tab -width 50000 -height 200 -background black]
# Draw an horizontal line on the canvas
$tab create line 0 100 50000 100 -width 1 -fill white

pack $tab -fill both -expand yes -anchor nw
pack $swt -fill both -expand yes -anchor nw

# Create a ScrolledWindow for the second pane
set swl [ScrolledWindow [$tfi getframe].swl -relief sunken -borderwidth 2 -scrollbar vertical -auto both]
pack $swl -expand yes -fill both

# Display the window manager
wm minsize . 600 350
wm deiconify .
wm protocol . WM_DELETE_WINDOW {exit}
bind . <Control-q> {exit}

在这个例子中,我使用的 Canvas 宽度为“50 000”,但是当我使用滚动条时, Canvas 的黑框会先结束。同样的问题也会影响 Canvas 上绘制的水平线。

我是不是错过了什么? Canvas 的“宽度”属性是否有已知限制?

感谢您的帮助

最佳答案

如果你让它们大于 32,000(严格来说是 32767,有符号 C short 的限制),事情就会变得有点奇怪,特别是在渲染层(并且肯定不要将 Canvas 视口(viewport)设置为那么大!)。但是,底层 Canvas 模型使用 IEEE double 来存储坐标,因此没有理由不能让事情发展到那么远。您只需缩小单个对象的大小即可。

这都是 X11 的遗产,它在相当多的关键结构中使用 16 位值作为坐标和尺寸。改变这一点在逻辑上很容易,而且在实践中需要做很多工作(假设到处都是)。

关于canvas - Canvas 的宽度有限制吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26578213/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com