Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Aug 2013 04:18
Simple question really, is there a way to Clip DBP Text?

"Get in the Van!" - Van B
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 28th Aug 2013 05:48
You need to be a bit more specific then that.

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Aug 2013 11:09
If text is out of bounds, clip that region from the pixels that make up the text.

"Get in the Van!" - Van B
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 28th Aug 2013 12:10
Doesn't Advanced2D have a textbox which does that?

http://forum.thegamecreators.com/?m=forum_view&t=179096&b=5



TheComet

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Aug 2013 12:23
a2Text is really really slow, actually is slowest of D3D and native Text. Native is the fastest so I want to be able to clip an area of the screen the same way a2SetClip does.

"Get in the Van!" - Van B
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 28th Aug 2013 12:23 Edited at: 28th Aug 2013 12:30
[edit] Not the best function I've ever written, but this should do what you want:




Formerly OBese87.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Aug 2013 12:27
Libervurto, nice example ish, I agree that's it's not to tidy. But I want to Clip Text, not Wrap it

"Get in the Van!" - Van B
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 28th Aug 2013 12:32 Edited at: 28th Aug 2013 12:32
What do you mean? You want a single line that clips the string and displays an ellipsis if the string is too long to fit inside the specified width?



Formerly OBese87.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Aug 2013 12:37
I thought Clipping was self explanatory But when it comes to text you could read clipping as trimming. Anyway, I need to clip a region of screen from drawing. So if text is sitting half way across say the edge of a window you'd clip or remove the pixels that overlap, so trim the pixels to fit the unclipped region.

"Get in the Van!" - Van B
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 28th Aug 2013 13:53
Not entirely sure I understand the problem:







Powered by Free Banners
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Aug 2013 14:12 Edited at: 28th Aug 2013 14:16
*Sigh* Okay, imagine a box, now fill that box with text, Actually fill it with anything that's 2d! Say I don't want any of that 2d to over lap the bounds of the box! So I remove the pixels the 2d is made up of that are beyond the bounds of the box or don't draw pixels beyond the bounds - CLIPPING!!!!

Just like this post box I'm writing in, when you scroll up and down, all the text is clipped when it's beyond the upper and lower limits of the edit bounds. Otherwise we'd have text running all over the page!



*text

"Get in the Van!" - Van B
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 28th Aug 2013 16:55 Edited at: 28th Aug 2013 17:10
Okay, I see now. I wasn't sure what you wanted to happen to the text that was "clipped". If you want it to simply cut off at the pixel level then this is very simple.


Quote: "Just like this post box I'm writing in, when you scroll up and down, all the text is clipped when it's beyond the upper and lower limits of the edit bounds. Otherwise we'd have text running all over the page!"

Yes, but the text is wrapped, not just discarded if it doesn't fit the width. Now I am confused again, do you want text wrapping or not?



Formerly OBese87.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 28th Aug 2013 17:14


Will overwrite what's already on the screen though...

Quote: "do you want text wrapping or not?"


I believe he wants
Quote: "CLIPPING!!!!"


Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 28th Aug 2013 17:17 Edited at: 28th Aug 2013 17:18
Quote: "Will overwrite what's already on the screen though..."

Well there are other ways of copying pixels from one bitmap to another, that was just the simplest for me to type.



Formerly OBese87.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Aug 2013 18:33
Haha Well I'm gonna kind of need the rest of the screen so the bitmap method isn't going to work so well.

"Get in the Van!" - Van B
thenerd
17
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 28th Aug 2013 20:17 Edited at: 28th Aug 2013 20:22
Quickly made this function (and a demo):



It's frustrating because I know it's inefficient since it creates a new image every frame. But it's a start. I'm not sure where to go from here.

Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 28th Aug 2013 20:31 Edited at: 28th Aug 2013 20:32
Sorry, I shouldn't expect people who ask for help to be able to modify my code to suit their needs. I'm not being as sarcastic as that sounds.

You can use copy bitmap to copy only a part of a bitmap from one to another, as you can see in the "make backdrop" section (which actually copies to the same bitmap). You can even use copy bitmap to scale and stretch the region you are copying. It's a bit of a clunky command for straight copying though so I opted to use an image for the actual clipped text.



Formerly OBese87.
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 28th Aug 2013 20:54 Edited at: 28th Aug 2013 20:56
I am being ignorant and lazy here, just had a Grolsch, so...

Might be worth drawing to an image like so with Matrix1:

Make Image 1, 100, 30
Draw To Image 1
Text 0, 0, "The quick brown fox jumped over the lazy dog"
Draw To Screen
Box 0,0,101,31
Paste Image 1, 1, 1
Wait Key

lol my code tag isn't working.

I am baffled at the speed issues with a2Text however, all these people experiencing slow downs; it must be the version of DBPRO I am using.

I use it everywhere with no problem, and that is before I implement produce new text rendering only when the text changes.

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 28th Aug 2013 22:15 Edited at: 28th Aug 2013 22:17
@Chris, Run this and tell me your results for fastest text:



@thenerd/Libervurto Cheers thou I should add it will be with text that changes a lot. I'm dealing with a lot of graph value updates and time clocks so there would be many updates, so creating imagines all the time wouldn't be that great.

"Get in the Van!" - Van B
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 28th Aug 2013 22:30 Edited at: 28th Aug 2013 22:34
Don't worry I believe you, I did this test before; and am aware that anti-aliased text will be slower than pixelated standard text. Standard text is about 25-50% faster.

I do not use D3D, but when I used to use it, I had problems with various plugin conflicts. At one point, its text was being drawn backwards on textures not designated to have text drawn on them.... Probably why I uninstalled D3D, but perhaps that was a 1 in 1 million occurrence that only ever happens to me.

My point is, should text be redrawn every frame anyway; and can I do without anti-aliased text in a modern world editor and video game for common household member equipped with X-Boxes, Playstations and Windows 8, Windows 8.1 and 9.1 by the time I am done with my work.

It's a decision we all make, I chose anti-aliased text and re-rendering text when required, which is why I didn't think it mattered if a2D tool a few milliseconds longer to smooth my text.

Maybe pixelated text would look alright on the Wii

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 28th Aug 2013 23:08
Quote: "I am baffled at the speed issues with a2Text however"


It's the anti-aliasing. You can switch it off with


TheComet

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 28th Aug 2013 23:47 Edited at: 28th Aug 2013 23:52
That particular command doesn't work with the text. However, doesn't D3D have text smoothing? A2D smoothing isn't all that brilliant anyway.

You could get away with pixelated text when it is small, I do not think there is much difference with small text. You could use bitmap fonts for larger text.

I've not seen many recent games who do not use per-rendered smoothed text with a bit of a drop shadow or stroke.

Edit

Come to think about it; in topical accordance, why would text need to be clipped? I've not seen a textbox anywhere that clips the pixels; they'd usually output a sub-string using the font character width to determine how many characters can fit in a box.

Interesting concept anyway.

GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 29th Aug 2013 01:19
Even if you don't use D3D for your text, you can still use the viewport commands I added. They affect D3D text, image pasting, and drawing commands

http://forum.thegamecreators.com/?m=forum_view&t=69221&b=5&msg=2206101#m2206101

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 29th Aug 2013 01:25
That looks good.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 29th Aug 2013 01:35
Quote: "Come to think about it; in topical accordance, why would text need to be clipped? I've not seen a textbox anywhere that clips the pixels; they'd usually output a sub-string using the font character width to determine how many characters can fit in a box. "

This was my immediate thinking. Why go through all of this circus and trouble. The solution is easy.

Just use the LEN command to get the string length. If it's too long then use MID$ or LEFT$ to grab the characters you want to display and tack "..." Or something else onto the end.

Don't make this about pixels. Count characters instead.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 29th Aug 2013 01:42
...unless you're making a real-time ASCII-based dungeon crawler.

TheComet

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 29th Aug 2013 01:47
Quote: "...unless you're making a real-time ASCII-based dungeon crawler."


Is this an indication of unsophistication?

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 29th Aug 2013 02:23
Quote: "*Sigh* Okay, imagine a box, now fill that box with text, Actually fill it with anything that's 2d! Say I don't want any of that 2d to over lap the bounds of the box! So I remove the pixels the 2d is made up of that are beyond the bounds of the box or don't draw pixels beyond the bounds - CLIPPING!!!!

Just like this post box I'm writing in, when you scroll up and down, all the text is clipped when it's beyond the upper and lower limits of the edit bounds. Otherwise we'd have text running all over the page!"


That was obvious from your first post. Why repeat it?

Did you actually look at my code? I assumed you had the ability to apply the technique to your problem. This seems to do what you want. Obviously you'll need to adapt it to your particular problem.





Powered by Free Banners
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 29th Aug 2013 13:46 Edited at: 29th Aug 2013 13:47
Quote: "Is this an indication of unsophistication?"

Depends from whom you suggest said indication is being... erm.. indicated. It has worked: http://www.youtube.com/watch?v=9ukhOAUseKY

Is it possible to somehow draw text to ImageKit's render targets? Copying render targets would be faster I believe.

TheComet

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 29th Aug 2013 20:39 Edited at: 29th Aug 2013 20:40
Everyones solution is related to the same principle; everything you draw on is some time of render target which are all bound to some limited extent, which the OP can choose to use and adjust to size and render to screen.

I've not tried the image kit method before, must give it a whirl.

Quote: ""Is this an indication of unsophistication?"
Depends from whom you suggest said indication is being... erm.. indicated.
unless you're making a real-time ASCII-based dungeon crawler.""


Sorry that was my unsophisticated thinking; I misunderstood the likely start to that ending sentence

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 31st Aug 2013 12:37 Edited at: 31st Aug 2013 12:38
The main reason for text clipping is because all other 2d elements clip, but text just vanished when it's beyond the clip region. So to make everything flow I wanted to clip the text.

The method I'm using at the moment is just like TheComet said but simpler I think (Letter Clipping)

I first check if the text bounds over lap the clip bounds, if not then don't display anything. Anything that over laps on the y axis just clip until it's fully within in the clip bounds. With the x bounds, just either check if it's less than the clip bounds via letter count until it's not and remove the text by the letter count and shift it by the offset of that count, and if it's beyond the width of the clip, just min the len of the str until it fits, simple.

Example: Press any key to toggle clipping on and off


I just wanted to see if there was a effective way of clipping say half way across a letter without grabbing or copying bits of the screen, though a render target is great for dynamic text. Most bits of text can be stored in images but things that change constant need could be stored in a render target. Depends how much is required on the screen.

"Get in the Van!" - Van B
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 31st Aug 2013 14:23
Why do you want to clip text anyway? Isn't it a bad thing to be losing that text?



Formerly OBese87.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 31st Aug 2013 14:30
Because my GUI uses windows that are scrollable and scalable, so everything within the space of the window needs to be clipped to the window bounds.

"Get in the Van!" - Van B
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 31st Aug 2013 23:40
Just count the number of characters and clip it with string commands.
So much easier.

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 31st Aug 2013 23:41
Quote: "Just count the number of characters and clip it with string commands.
So much easier."


Already done this

"Get in the Van!" - Van B
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 31st Aug 2013 23:47
That's what my first solution did.
Well, glad you have sorted it out now anyway.



Formerly OBese87.
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 1st Sep 2013 04:46
'Attaboy

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Sep 2013 14:42
Sasuke, don't worry I knew what you meant by clipping from your first post. I too would have thought it was self explanatory. To answer the question, no you can't really clip the text without using a plugin (as you said was too slow) or by making the text an image.

Depending on your application, you can fake it. If you have a border of a few pixels or something else drawn around the textbox, you can clip the text using LEN then the remaining pixels of the last character that extend outside the box could be hidden by having the other parts of the GUI drawn on top.

Login to post a reply

Server time is: 2026-07-06 20:17:01
Your offset time is: 2026-07-06 20:17:01