Raphael Text Glow - raphael

Does anyone have an idea of how to get a glow to show up on text? I thought it would be pretty easy to do so but nothing is rendering on the fiddle.
Fiddle
Thanks

It looks to me as though Raphael simply does not support text glow. Check out the first lines of the glow function:
if (this.type == "text") {
return null;
}
It might be worth your while to investigate the use of print with a Cufonized font -- it'll return a path representing the text you give it instead of a tspan, and glow can be applied to paths.
Or you could settle for creating a simple drop shadow.
I've staged both of these alternatives by way of demonstration here.

You could create a rectangle behind the text and make that glow. I think that should look just fine. Use getBBox() to find out the size of the rectangle you need.
Something like this: http://jsfiddle.net/7ZPtq/51/
Or maybe use some other primitive, e.g. line.

Related

How do I draw a line on a Lazarus form?

I often use a TPanel or TGroupBox to group my form controls.
Now I need to draw just a straight line like the border of a Panel or GroupBox.
How do I do this on LAZARUS?
Thanks in advance!
Note: The technique must work on both Linux and Windows
As an optical line separator you should use either the TBevel component with Shape property set to one of the following values bsTopLine, bsBottomLine, bsLeftLine or bsRightLine depending on which line you currently need and resize it to a smaller size (in your case you can use bsTopLine or bsBottomLine and resize the bevel vertically):
Or you can use a special component called TDividerBevel which except the single line adds to this optical divider also a caption:
Here's what I've finally done but I'm not sure if this is the RIGHT way so I won't accept my answer. If there's someone else who can point out any issues with this, please let me know. I found this pretty straightforward as well :)
Place a TGroupBox on the form.
Leave the Caption property blank. Now it should look like a panel with only borders.
Use the mouse and drag the bottom border towards the top. Now it looks like a line.
Well, I personally think this method is NOT efficient as it would take up more memory space than just a real straight line. Anyway, so far it seems to work for me :)
Here's the screenshot - look towards the bottom (just above the last text box). The only issues is that on the sides of the line, it shows the lines bending. I think I should set the properties correctly than dragging with the mouse.

SKIA :: Get Text height of a text inside a canvas

I am using Skia for one of my sample program. I have a canvas and inside this I am writing text with font_size 30, this is the code snippet.
string = "Test String";
SkString text(string);
SkPaint paint;
SkScalar textWidth;
paint.setTextSize(SkIntToScalar(font_size));
paint.getFontMetrics(&metrics);
textWidth = paint.measureText(text.c_str(), text.size());
textWidth will give the exact width of the text inside the canvas. My question is how can I get the height of the text ? Please help.
I once had to look into this myself in the past, this link here should help you, even though it is java, fonts all work on the same idea as far as I know.
I assume you will want from the ascender to the baseline, Which is just the ascent. Or you may want the whole thing from top to bottom which is the ascent and descent combined,
If you were writing on lined paper, the baseline is the same as the line you write on, anything above that is the ascent, anything below is the descent.
I dont know anything about skia, But A quick look into skia, at this link here, that there is a public member called fAscent in FontMetrics, and fDescent, Maybe you can use those.
the font size your have specified as "font_size" is the height of single line text

JavaScript- drawing line chart with gRaphael

I'd like to draw a line chart with gRaphael, like the one in the lower right corner: http://g.raphaeljs.com/linechart.html
Now I'd like to change the color of the axis, but I could not find any example how to do that. Here are some examples of how to manipulate the chart, but not how to change the axis color.
Does anyone of you know how to do that?
Thanks in advance,
enne
In part from here, the following Javascript will change the fill color for your axes:
$.each(chart.axis[0].text.items, function(i, label) {
label.attr({'fill': '#D6D6D6'});
});
$.each(chart.axis[1].text.items, function(i, label) {
label.attr({'fill': '#D6D6D6'});
});
Enjoy!
After a long time of research I couldn't find a possibility to change the axis-colour. I decided to generate my own diagram with rapahel, which is easier than I thought.
Fortunately, the documentation of raphael is good enough to create a diagram in an adequate period of time.

QPainter colored text (syntax coloring)

I have a custom Qt widget which I used to display disassembly and I am looking to add syntax coloring to it.
Currently, I simply set the QPen to a solid color, construct the text I want to display, and render it to the QPainter at the appropriate coordinates.
The question is, what is the best approach to adding syntax coloring? I've thought of a few:
I could simply divide the coloring into logical blocks, each preceded by setting the QPen to the desired color.
I could have special escape characters which represent a change in the color palette, and render 1 character at a time.
I could do a modification of #1 and create a list of std::pair<QColor, QString>, then I could simply iterate the list setting the color and drawing the text as I pop items off the front of the list.
Something entirely different?
I know that each of the 3 approaches I've listed will technically work, but I'm looking for a very efficient solution. This code will be called a lot. And since this is an interactive debugger, if this code is slow, someone rapidly stepping or tracing will see a visible slowdown.
EDIT: I'm aware of QSyntaxHighlighter and QTextDocument. The main issue is that these don't generally suite my purposes very well. I have several columns which all have dividers and can be slid back and forth. To give you an idea, Here's a link to a screenshot of my debugger. As you can see it isn't really like a text document at all. In fact it is closer to a list or table. But there is already a bunch of custom drawing going on making a normal QTextDocument somewhat impractical.
EDIT: I was incorrect, It seems that QTextDocument can render directly to a QPainter. Looks like what I need!
EDIT: It is unclear how to control where and how QTextDocument or QTextLayout will draw on a QPainter. I've attempted to use them to no avail. So if someone could provide a rudimentary example, that would be very helpful.
EDIT: I was eventually able to get what I wanted using something like this:
painter.setPen(default_color);
QTextDocument doc;
doc.setDefaultFont(font());
doc.setDocumentMargin(0);
doc.setPlainText(text);
highlighter_->setDocument(&doc);
painter.save();
painter.translate(x, y);
QAbstractTextDocumentLayout::PaintContext context;
context.palette.setColor(QPalette::Text, painter.pen().color());
doc.draw(&painter, context);
painter.restore();
Qt provides a QSyntaxHighlighter that is probably exactly what you want. QSyntaxHighlighter uses a QTextDocument to mark each block of code with a specific state which can be associated with a specific presentation format.
The documentation on QSyntaxHighlighter provides a sample demonstrating how this may be accomplished and does some nice things:
Separates the model from presentation
Separates the formatting into different reusable classes (if implemented as such)
Supports the State design pattern if useful to your language
I'd use either QTextEdit or directlay its underlining engine QTextDocument.

gradients using only html and css and javascript?

Is there a way to do gradients in css/html/javascript only that will work across all the major browsers? (MS IE 5+, Firefox, Opera, Safari)?
Edit: I would like to do this for backgrounds (header, main panel, side panels). Also, would like to have vertical line gradients as well.
Edit: after reading the responses, let's open this up to Javascript solutions as well, since HTML/CSS by itself makes it tougher to achieve.
I've done this before as a gimmick, using javascript like:
var parent = document.getElementByID('foo');
for(var i=0; i< count; i++) {
var div = document.createElement('div');
div.style.position = 'absolute';
div.style.width='100%';
div.style.height = 1/count+"%";
div.style.top = i/count+"%";
div.style.zIndex = -1;
parent.appendChild(div);
}
If your requirement is just to have a gradient, you really should use a gradient image set as background-image in css. In my case, I was animating the colors and position of the gradient as well. I can't vouch for now cross-browser it is (for starters, make sure the parent has some position applied, otherwise it won't be a position-container for the absolute positioning.
I'm unclear on the implementation details you are seeking (such as background, or just a border along the side of the window, etc); however, it's possible albeit a little tedious.
One example that comes to mind would be to have n-block level elements, such as divs, and then give them each a small height (a couple of pixels, for example) and then gradually change the background color of each subsequent element.
I use the gradient CSS code generator by colorzilla: http://www.colorzilla.com/gradient-editor/
It has polyfills for IE - but not sure how far back it goes.
I think the short answer is no.
You can create something that looks like a gradient using only css, but to then use it like an image background... I think that is pushing it a bit.
EDIT (feeling silly)
I found the solution: http://en.wikipedia.org/wiki/JPEG
There are lots of ways to create a gradient now.
1. You can create image for it.
2. Use CSS3 Gradient, it can be linear, radial and repeating.
Syntax for linear :
linear-gradient: ([angle | to ] ,[ [color-stop], [color-stop]+);
Syntax for radial :
linear-gradient: ([angle | to ] ,[ [color-stop], [color-stop]+);
For IE6 to IE 9 we can use the filter property or you can also use CSS3Pie.
Following are some referances that will help:
Mozilla MDN
CSS3File