Custom Text Formatting (Previously: Getting long results in a program)
|
04-14-2024, 07:09 AM
(This post was last modified: 04-14-2024 07:14 AM by komame.)
Post: #75
|
|||
|
|||
RE: Getting long results in Program
(04-14-2024 06:18 AM)Tyann Wrote: The problem I see with the 10th parameter is the following, we need to provide a value for 'f' (background colour) by default to tell atextout that there is no background (probably a negative value) but if we provide a negative value to TEXTOUT_P for this parameter it returns an error. Tyann, I'm aware of that, and I've taken it into consideration, but this problem is very easy to solve (actually, this is not a problem at all). Let's assume that the default background value, to prevent it from appearing (no color), is set to -1. ATEXTOUT_P should return an error if someone provides the value -1 for the "f" parameter because that's not a valid color. However, note that -1 will never be passed directly into ATEXTOUT_P because it's a default value that is substituted only when ATEXTOUT_P has only 8 parameters. So, when 8 parameters are recognized, -1 will be substituted for the background color. To implement this, it's enough to add one IF condition in ATEXOUT_P, which will report an error if someone provides -1 as the background color. However, -1 inside atextout will be identified as no background. This way, you can achieve a fixed number of parameters when calling atextout. Additionally, it will be possible to have a single common call to atextout for all cases. This is because once the default variable values are established, the number of parameters will always be the same, allowing atextout to be called directly by substituting values (without using EXPR), and additionally, it will eliminate the need to convert the list into variables, which is currently done at the beginning of atextout. All this requires only a few lines of code modification. However, if we assume that both the text color and the background color have alpha channels included (in the format {color,alpha}), it would require an additional buffer (or an increase in the size of the current one), but it is also feasible and we could consider such an extension. This would require a slightly more advanced approach, but it is possible to do. In that case, we would still be left with 9 parameters. What do you think about this? Piotr Kowalewski |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 46 Guest(s)