Re: SDLx::Text - replace old text?
Le Friday 23 December 2011 21:02:17, Kartik Thakore a écrit : Regarding the surface, SDLx::App is a SDLx::Surface. That's what I was referring to. I don't think it's safe to make any assumptions about what's behind the text, so it should be the module user's responsibility to clear whatever is behind it. Hmm can we just not make the blit for clearing the text surface? Cause it wraps an sdl::surface. Don't go that way: next thing user will ask is to restore what was behind the text on the surface. Dominique -- http://config-model.wiki.sourceforge.net/ -o- http://search.cpan.org/~ddumont/ http://www.ohloh.net/accounts/ddumont -o- http://ddumont.wordpress.com/ signature.asc Description: This is a digitally signed message part.
Re: SDLx::Text - replace old text?
Le Thursday 22 December 2011 00:17:07, Alex a écrit : First, the text Hello World! is drawn to the surface. Then, I alter the text and draw it again. But the old hello world text still remains on the surface. I don't want that. I want Hello World! to disappear and Susan so show up. You have to draw a black rectangle on $app before writing Susan. I don't think there's another way. HTH Dominique -- http://config-model.wiki.sourceforge.net/ -o- http://search.cpan.org/~ddumont/ http://www.ohloh.net/accounts/ddumont -o- http://ddumont.wordpress.com/ signature.asc Description: This is a digitally signed message part.
Re: SDLx::Text - replace old text?
Hi Alex, This is actually the correct behavior. You need to redraw the background before writing the new text. The easiest way to do that is with: $app-draw_rect( undef, 0x00FF ); The undef there indicates that the entire surface should be used as the rectangle. See draw_rect in SDLx::Surface for more information. Cheers, Jeff On Wed, Dec 21, 2011 at 6:17 PM, Alex cap...@gmx.de wrote: Dear all! I want to replace an SDLx::Text by some other text. Do I have to redraw the whole surface that was covered by the old text in order to replace it by a new text? The following script demonstrates my problem: [code] #!perl use strict; use warnings; use SDL; use SDL; use SDLx::App; use SDLx::Text; my $app = SDLx::App-new( exit_on_quit = 1, ); my $message = SDLx::Text-new; $message-write_to( $app, Hello, World! ); $app-update; $message-text('Susan'); $message-write_to( $app ); $app-update(); $app-run(); [/code] First, the text Hello World! is drawn to the surface. Then, I alter the text and draw it again. But the old hello world text still remains on the surface. I don't want that. I want Hello World! to disappear and Susan so show up. How do I do that? Best regards, Alex
Re: SDLx::Text - replace old text?
But the surface is not an SDLx::Surface ... maybe we should change that at least on the text surface. I think that once you decide to rewrite on the text surface it should do that. How about we add $text-clear(); ? On Fri, Dec 23, 2011 at 2:37 PM, Jeffrey Palmer jeffrey.t.pal...@gmail.comwrote: Hi Alex, This is actually the correct behavior. You need to redraw the background before writing the new text. The easiest way to do that is with: $app-draw_rect( undef, 0x00FF ); The undef there indicates that the entire surface should be used as the rectangle. See draw_rect in SDLx::Surface for more information. Cheers, Jeff On Wed, Dec 21, 2011 at 6:17 PM, Alex cap...@gmx.de wrote: Dear all! I want to replace an SDLx::Text by some other text. Do I have to redraw the whole surface that was covered by the old text in order to replace it by a new text? The following script demonstrates my problem: [code] #!perl use strict; use warnings; use SDL; use SDL; use SDLx::App; use SDLx::Text; my $app = SDLx::App-new( exit_on_quit = 1, ); my $message = SDLx::Text-new; $message-write_to( $app, Hello, World! ); $app-update; $message-text('Susan'); $message-write_to( $app ); $app-update(); $app-run(); [/code] First, the text Hello World! is drawn to the surface. Then, I alter the text and draw it again. But the old hello world text still remains on the surface. I don't want that. I want Hello World! to disappear and Susan so show up. How do I do that? Best regards, Alex
Re: SDLx::Text - replace old text?
I just realized this was discussed on Github, so you can probably ignore what I wrote. Regarding the surface, SDLx::App is a SDLx::Surface. That's what I was referring to. I don't think it's safe to make any assumptions about what's behind the text, so it should be the module user's responsibility to clear whatever is behind it. On Fri, Dec 23, 2011 at 2:39 PM, Kartik Thakore thakore.kar...@gmail.com wrote: But the surface is not an SDLx::Surface ... maybe we should change that at least on the text surface. I think that once you decide to rewrite on the text surface it should do that. How about we add $text-clear(); ? On Fri, Dec 23, 2011 at 2:37 PM, Jeffrey Palmer jeffrey.t.pal...@gmail.com wrote: Hi Alex, This is actually the correct behavior. You need to redraw the background before writing the new text. The easiest way to do that is with: $app-draw_rect( undef, 0x00FF ); The undef there indicates that the entire surface should be used as the rectangle. See draw_rect in SDLx::Surface for more information. Cheers, Jeff On Wed, Dec 21, 2011 at 6:17 PM, Alex cap...@gmx.de wrote: Dear all! I want to replace an SDLx::Text by some other text. Do I have to redraw the whole surface that was covered by the old text in order to replace it by a new text? The following script demonstrates my problem: [code] #!perl use strict; use warnings; use SDL; use SDL; use SDLx::App; use SDLx::Text; my $app = SDLx::App-new( exit_on_quit = 1, ); my $message = SDLx::Text-new; $message-write_to( $app, Hello, World! ); $app-update; $message-text('Susan'); $message-write_to( $app ); $app-update(); $app-run(); [/code] First, the text Hello World! is drawn to the surface. Then, I alter the text and draw it again. But the old hello world text still remains on the surface. I don't want that. I want Hello World! to disappear and Susan so show up. How do I do that? Best regards, Alex -- Jeffrey T. Palmer
Re: SDLx::Text - replace old text?
On Dec 23, 2011 2:43 PM, Jeffrey Palmer jeffrey.t.pal...@gmail.com wrote: I just realized this was discussed on Github, so you can probably ignore what I wrote. Regarding the surface, SDLx::App is a SDLx::Surface. That's what I was referring to. I don't think it's safe to make any assumptions about what's behind the text, so it should be the module user's responsibility to clear whatever is behind it. Hmm can we just not make the blit for clearing the text surface? Cause it wraps an sdl::surface. On Fri, Dec 23, 2011 at 2:39 PM, Kartik Thakore thakore.kar...@gmail.com wrote: But the surface is not an SDLx::Surface ... maybe we should change that at least on the text surface. I think that once you decide to rewrite on the text surface it should do that. How about we add $text-clear(); ? On Fri, Dec 23, 2011 at 2:37 PM, Jeffrey Palmer jeffrey.t.pal...@gmail.com wrote: Hi Alex, This is actually the correct behavior. You need to redraw the background before writing the new text. The easiest way to do that is with: $app-draw_rect( undef, 0x00FF ); The undef there indicates that the entire surface should be used as the rectangle. See draw_rect in SDLx::Surface for more information. Cheers, Jeff On Wed, Dec 21, 2011 at 6:17 PM, Alex cap...@gmx.de wrote: Dear all! I want to replace an SDLx::Text by some other text. Do I have to redraw the whole surface that was covered by the old text in order to replace it by a new text? The following script demonstrates my problem: [code] #!perl use strict; use warnings; use SDL; use SDL; use SDLx::App; use SDLx::Text; my $app = SDLx::App-new( exit_on_quit = 1, ); my $message = SDLx::Text-new; $message-write_to( $app, Hello, World! ); $app-update; $message-text('Susan'); $message-write_to( $app ); $app-update(); $app-run(); [/code] First, the text Hello World! is drawn to the surface. Then, I alter the text and draw it again. But the old hello world text still remains on the surface. I don't want that. I want Hello World! to disappear and Susan so show up. How do I do that? Best regards, Alex -- Jeffrey T. Palmer