3D Text
Posted: Tue Mar 07, 2023 7:54 pm
Hi Sergey,
I use an rve as a "cover page" in my app. It can have any background color. I also put text on that cover page and I thought it would be nice if I could display the text in "3D" so that text would show up no matter what color the background was. So, I came up with the code below that worked great and did just what I needed:
Other users might find that code useful to display "3D" text.
However, I was also thinking it would be helpful if I there was an option for this in regular text styles as well so it could be saved and printed this way. I was thinking you'd need 2 vars: ShadowOffset and ShadowColor. ShadowOffset would default to 0 (no shadow). A negative value would draw the shadow to the left and above the original text, a positive value would draw the shadow to the right and below the original text.
It might be too dificult to implement, but I thought I'd ask about it.
Thanks Sergey
Stan
I use an rve as a "cover page" in my app. It can have any background color. I also put text on that cover page and I thought it would be nice if I could display the text in "3D" so that text would show up no matter what color the background was. So, I came up with the code below that worked great and did just what I needed:
Code: Select all
procedure TForm1.CoverRVEStyleDrawStyleText(Sender: TRVStyle;
const s: TRVUnicodeString; Canvas: TCanvas; StyleNo, SpaceAtLeft, ALeft, ATop,
AWidth, AHeight, BaseLine, TextWidth, SpaceCount: Integer;
DrawState: TRVTextDrawStates; Printing, PreviewCorrection,
ForMetafile: Boolean; ColorMode: TRVColorMode; DefBiDiMode: TRVBiDiMode;
RefCanvas: TCanvas; LeftNoExpIndex, RightNoExpIndex: Integer;
PSaD: PRVScreenAndDevice; var DoDefault: Boolean);
var
FColor: TColor;
begin
//Draws coverRVE text as "3D"
DoDefault := false;
FColor := Canvas.Font.Color; //store default original color
//Draw text shadow using a +1 offset:
Canvas.Font.Color := clBlack;
if FColor < 1 then //we don't want black on black text
Canvas.Font.Color := clGrayText;
Canvas.TextOut( ALeft + SpaceAtLeft + 1, BaseLine + 1, s );
//Draw normal text on top of shadow text at default text pos:
Canvas.Font.Color := FColor;
Canvas.TextOut( ALeft + SpaceAtLeft, BaseLine, s );
end;
However, I was also thinking it would be helpful if I there was an option for this in regular text styles as well so it could be saved and printed this way. I was thinking you'd need 2 vars: ShadowOffset and ShadowColor. ShadowOffset would default to 0 (no shadow). A negative value would draw the shadow to the left and above the original text, a positive value would draw the shadow to the right and below the original text.
It might be too dificult to implement, but I thought I'd ask about it.
Thanks Sergey
Stan