Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Your heart is pure, and your mind clear, and your soul devout.


comp / comp.lang.tcl / Re: canvas: change the background of a text item

SubjectAuthor
* canvas: change the background of a text itemRalf Fassel
`* Re: canvas: change the background of a text itemRalf Fassel
 `* Re: canvas: change the background of a text itemundroidwish
  `- Re: canvas: change the background of a text itemsaito

1
Subject: canvas: change the background of a text item
From: Ralf Fassel
Newsgroups: comp.lang.tcl
Date: Wed, 30 Oct 2024 12:00 UTC
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: canvas: change the background of a text item
Date: Wed, 30 Oct 2024 13:00:43 +0100
Lines: 14
Message-ID: <ygav7x9x0k4.fsf@akutech.de>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net nd9eWiTtoOdGgIfaolT3EwNzu2dOC+X1P19L1Seom4cGNxcng=
Cancel-Lock: sha1:CRe/Ha+MiuKfoZTz6TVCJaSEkTQ= sha1:29E03cSLAnTUhSEdzWtmKqxNEXQ= sha256:DWAuhD0LwBqgM/uarQksjFDFr6xSbRWdArTu2CHLALU=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
View all headers

Is there a way to change the background of a text item on a canvas?
I can change the color of the text via -fill, but I found no way to
change the background color of the text:

pack [canvas .c] -fill both -expand yes
# red text on yellow background
.c create text 100 100 -text "Example text" -font {Helvetica 20} -fill red

=> how to change the background of the text field to yellow?
i.e. the same as ".c configure -background yellow", but restricted
to the area of the text.

TNX
R'

Subject: Re: canvas: change the background of a text item
From: Ralf Fassel
Newsgroups: comp.lang.tcl
Date: Wed, 30 Oct 2024 13:42 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: canvas: change the background of a text item
Date: Wed, 30 Oct 2024 14:42:02 +0100
Lines: 24
Message-ID: <ygar07xwvv9.fsf@akutech.de>
References: <ygav7x9x0k4.fsf@akutech.de>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net lC0XrWBW/wb8n3cvdFANTgGdusjjoDhdSSE7klCUPNtO1OhCo=
Cancel-Lock: sha1:2nrox6PM/qLOp46Qb9SSmj/+vxE= sha1:TtbX+MtW3yRWQ22IBTbqTGpexlc= sha256:KrFv7pWy3/NvLbDyZZ3uGK6GCWEcTGDbig5y/Fa/GII=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
View all headers

* Ralf Fassel <ralfixx@gmx.de>
| Is there a way to change the background of a text item on a canvas?
| I can change the color of the text via -fill, but I found no way to
| change the background color of the text:
>
| pack [canvas .c] -fill both -expand yes
| # red text on yellow background
| .c create text 100 100 -text "Example text" -font {Helvetica 20} -fill red
|
| => how to change the background of the text field to yellow?
| i.e. the same as ".c configure -background yellow", but restricted
| to the area of the text.

Ok, found a workaround on the WIKI:

https://wiki.tcl-lang.org/page/canvas+text

- create a rectangle with the bbox of the text and lower it beneath
the text.

Somehow the 'rectangle' item was not there when I scanned the canvas
manpage earlier :-/

R'

Subject: Re: canvas: change the background of a text item
From: undroidwish
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Wed, 30 Oct 2024 19:29 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: undroidwish@googlemail.com (undroidwish)
Newsgroups: comp.lang.tcl
Subject: Re: canvas: change the background of a text item
Date: Wed, 30 Oct 2024 20:29:38 +0100
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <vfu1f3$29gua$1@dont-email.me>
References: <ygav7x9x0k4.fsf@akutech.de> <ygar07xwvv9.fsf@akutech.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 30 Oct 2024 20:29:39 +0100 (CET)
Injection-Info: dont-email.me; posting-host="38dd94041acb4ab03e3767932ee76b8b";
logging-data="2409418"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+P9LNkqOauJY7+spkp5zawsbZqxcR0lBQ="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.10.0
Cancel-Lock: sha1:IOVEAac3llGfDQR7g1pE5FDhFgU=
In-Reply-To: <ygar07xwvv9.fsf@akutech.de>
Content-Language: en-US
View all headers

On 10/30/24 14:42, Ralf Fassel wrote:

> Ok, found a workaround on the WIKI:
>
> https://wiki.tcl-lang.org/page/canvas+text
> ...

thanks for digging, that's intriguing. The XLFD allowed in ancient times
for transformations, didn't know that. Not that it is relevant for now,
since we all render our texts in Tk using libxft. But until 2.3.5, that
library, too, had still problems scaling/rotating/translating
bitmap fonts (especially the color emojis).

> - create a rectangle with the bbox of the text and lower it beneath
> the text.

And yes, the challenge now is to make the rectangle (ahem, rotated, a
polygon) for a somewhat rotated text out of its bbox (if you'd like to
have a text background).

And please, enhance the wiki in this regard.

BR,
Christian

Subject: Re: canvas: change the background of a text item
From: saito
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Wed, 30 Oct 2024 21:42 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: saitology9@gmail.com (saito)
Newsgroups: comp.lang.tcl
Subject: Re: canvas: change the background of a text item
Date: Wed, 30 Oct 2024 17:42:46 -0400
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <vfu98n$2aop5$1@dont-email.me>
References: <ygav7x9x0k4.fsf@akutech.de> <ygar07xwvv9.fsf@akutech.de>
<vfu1f3$29gua$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 30 Oct 2024 22:42:48 +0100 (CET)
Injection-Info: dont-email.me; posting-host="ebeb6c6391195ad00c93906d467ee585";
logging-data="2450213"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18KMIpXZJnhkHXmQd1KOPIo"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:/u0uUDyo3zNlWJ/ieFPWs3xqlN0=
Content-Language: en-US
In-Reply-To: <vfu1f3$29gua$1@dont-email.me>
View all headers

On 10/30/2024 3:29 PM, undroidwish wrote:
> And yes, the challenge now is to make the rectangle (ahem, rotated, a
> polygon) for a somewhat rotated text out of its bbox (if you'd like to
> have a text background).
>

Not sure when it became available but you can rotate text on a canvas
using the -angle option. As for the background, the rectangle option
works. Since, in this case, you will have the coordinates for the
rectangle, you can translate the four coordinates to match the angle of
the text. Not sure at all whether bbox can help you with the rotated stuff.

Tkpath is worth checking out. As I recall, it could rotations before Tk.

1

rocksolid light 0.9.8
clearnet tor