Can't make transparency work with white
Can't make transparency work with white
I'm trying to embed the HTML provided on the CodeCogs Latex page to create an image where the color of the text is white and the background is transparent. Transparency seems to work for other text colors, but not for white. Example equation:
\color{white}\mathbf{\frac{-b\pm\sqrt{b^2-4ac}}{2a}}The line of dropdown menus selects: gif, Sans Serif, 110 dpi, transparent And neither the "Inline" nor the "Compressed" boxes are checked. This yields this HTML:
<a href="http://www.codecogs.com/eqnedit.php?latex=\color{white }\mathbf{\frac{-b\pm\sqrt{b^2-4ac}}{2a}}" target="_blank"><img src="http://latex.codecogs.com/gif.latex?\color{white }\mathbf{\frac{-b\pm\sqrt{b^2-4ac}}{2a}}" title="\color{white }\mathbf{\frac{-b\pm\sqrt{b^2-4ac}}{2a}}" /></a>Am I doing something wrong, or is this a bug? --Percy
18 Oct 09, 5:19PM
Technically this is a bug, but not one that we can be fixed easily or quickly. Given its a fairly minor fault, its not one we're likely to solve for sometime I'm affraid.
The problem is with the way transparent is done. When the equation image is generated we're unable to use transparency, so transparently is added by reasigning the color white to transparent. Thats ok, so long as you use any other color than white, but when the text is also white you clearly end up with nothing.
One way to get around this is use a secret option, \fg_###### (not advertised else where) which adjusts the forground color in a different way. In \fg_######, the 6 #'s are actually pairs of numbers in hex for Red, Green and Blue respectively.
i.e.
- \fg_FF0000 is Red
- \fb_00FF00 is Green
- \fb_0000FF is Blue
http://latex.codecogs.com/gif.latex?\fg_f2f2f2 x^2+2For those wondering what on earth Percy is doing (since you don't see much in the Equation editor), then here is an html page illustrating the problem and also our crude work around:
<html> <body style="background-color:red"> <img src="http://latex.codecogs.com/gif.latex?\color{blue}\mathbf{\frac{-b\pm\sqrt{b^2-4ac}}{2a}}" /> (blue text) <br/> <img src="http://latex.codecogs.com/gif.latex?\color{white}\mathbf{\frac{-b\pm\sqrt{b^2-4ac}}{2a}}" /> (white text) <br/> <img src="http://latex.codecogs.com/gif.latex?\fg_f2f2f2 \mathbf{\frac{-b\pm\sqrt{b^2-4ac}}{2a}}" /> (off white text) </body> </html>
18 Oct 09, 6:48PM
My website uses white text on a dark blue background, and your solution solves the problem! Was not expecting an answer on Sunday. Thanks!
--Percy
19 Oct 09, 1:27AM
I have a related question. I've noticed that white text on a dark background doesn't appear as crisp as dark text on a white background. The cause appears to be that the text has some extra "stuff" around the edges that makes it look great with black text on white, but which makes it look less clear with white text on black. Another latex site I visited had something they called "aliasing" that you could turn on and off, and it seemed to make the text look better when it was white text on black. Does your Latex have something similar?
--Percy
19 Oct 09, 2:43AM
You've probably seen many cool uses of your Latex engine, and this has probably been done before, but I was able to add a [latex] code to my discussion board. Members can now include complex equations in their messages. Here's a link to my announcement of the feature:
http://www.evcforum.net/cgi-bin/dm.cgi?action=msg&t=13879
--Percy
19 Oct 09, 4:45PM
Nice website. Out of curiosity how have you implemented the [latex] option. Do you still use CodeCogs?
btw. Thanks for mentioned CodeCogs in your post ;(
Looking into the Alias suggestion you made, I realised a much simpler option. If you use png image files, then this will solve all of your problems. For example, change:
http://latex.codecogs.com/gif.latex?\color{white}x^2+3to
http://latex.codecogs.com/png.latex?\color{white}x^2+3As in The reason this works so much better is that png has an alpha channel, which gifs don't. In otherwords the png has an entirely different layer for the equation text that seperates it from the background - which you've made transparent. Thus unlike earlier, there is no issue identifying the edges of text, and regardless of background and forground colors everything works perfectly. I'm wondering if I should change the default in the equation editor to png files. png is fully suppored by all web-browsers, ms-word etc, so there shouldn't be any problems.
19 Oct 09, 5:31PM
Thanks for the .png suggestion - solves the problem, plus I can go back to using \color{white} instead of \fg_f2ffff. I didn't know that .png had this alpha channel advantage over .gif.
About my [latex] code implementation, yes I use CodeCogs. I can't say I did a thorough search, I only poked around the Internet for an hour or so, but amongst what I found you had the most complete solution.
In my [latex] code implementation, message previews replace the [latex] code with an HTML img tag which uses the CodeCogs Latex URL. When a message is finally posted then I actually store the returned image as a permanent image file so that your engine doesn't receive a request every time the message is viewed, and the HTML img tag is changed to reference that image. Saving a copy of the image file also guarantees that if your server is down or if you discontinue the service that existing messages with Latex expressions will still display properly.
--Percy
19 Oct 09, 10:59PM
I've completed the switch over to .png files, take a peek:
http://www.evcforum.net/cgi-bin/dm.cgi?action=msg&m=531777
Thanks again!
Off-topic question: would it be just as easy to hook in to some of the other stuff I've seen alluded to in places where I've been reading about Latex, like rendering of graphs, diagrams, etc.?
--Percy
20 Oct 09, 3:21AM
Looks really good.
Always interested to see how people use our service, so some questions back:
- I've not heard of dBoard before. What the backend to this. C++ or PHP? Its just that your approach above of saving a local copy of the image is smart and would be usefull feature that others might want to adopt. Could you post your code to to a new thread?
- Does your forum link to the our Equation Editor? Have you seen our javascript mechanism for firing up editor? With the phpBB option it'll insert [tex]1+2[/tex] directly into your form. We can add an option to produce [latex] tags easily. We're working on plugins for FCKEditor etc.
- What does your forum run on? We're looking to build a world wide network of servers all runing our LaTeX engine, so this becomes a 100% guaranteed service (currently we're 99.2%, due to recent disruptions). So if you have spare CPU cycles on a Linux box with public access, then let us know. We'll provide the LaTeX system for free including support, In return you'll have to allowing others to render equations from your machines. There will be load balancing across all servers, with most work done by us - so you shouldn't notice any degregation to your forum + plus you'll get all new features first.
20 Oct 09, 9:11AM
Answering your points in order:
<ul><li>The reason you haven't heard of dBoard is that my master plan for taking over the discussion board universe is a bit behind schedule. I began working on it nearly a decade ago, but my day job keeps me from putting enough time into it, and I don't have any help, so I haven't released it yet. If you know of anyone just bursting at the seams with desire to work on YABB (that name is taken, by the way), steer them my way. I started on it before many had heard of PHP, and so it is written in Perl. In my day job I use C++.
If you really think anyone would find Perl code helpful I could post it, let me know, but it's nothing any Perl coder couldn't figure out.
<li>No, the forum doesn't link to your equation editor.
<li>The forum runs on an Intel dual-core machine running Centos 5.2. I support several websites, but the discussion board is the only one with significant activity, perhaps 150 messages/day and bandwidth of maybe 30 GB/month on average, so there's plenty of spare cycles. I'd be glad to help you guys out as long as there's no significant time investment on my end, just let me know.</ul>
Thanks for the diagram example, I posted it at the forum. I notice your board puts up a hoverbox with the Latex text, I should do the same.
Added by Edit: I'm getting feedback from some members that .png's don't work with IE 6. I'm sticking with .png's, but will investigate whether I can rig IE's AlphaImageLoader to step in when IE 6 is detected.
--Percy
Login