Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Gold textured color for form



Permlink Replies: 3 - Last Post: Apr 25, 2016 9:58 AM Last Post By: Remy Lebeau (Te...
John Shyer

Posts: 137
Registered: 1/29/10
Gold textured color for form
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 22, 2016 11:13 AM
Hello,

About 10 or more years ago I somehow created a form with a gold color and lightly textured on Delphi 5. That code is long gone and I cannot remember how I did it, nor can I find anything close in manipulating the color chart. Does anyone have a TColor code for the color "gold" and also how does one texture the form?

Thank you in advance, John Shyer
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Gold textured color for form
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2016 7:56 AM   in response to: John Shyer in response to: John Shyer
John Shyer wrote:

Hello,

About 10 or more years ago I somehow created a form with a gold color
and lightly textured on Delphi 5. That code is long gone and I
cannot remember how I did it, nor can I find anything close in
manipulating the color chart. Does anyone have a TColor code for the
color "gold" and also how does one texture the form?

You can use the form's OnPaint event to paint the form background
(using the form.Canvas) any way you want. If you need something fance
it is often easiest to use some professional image processing program
to create a bitmap you then use to fill the form background.

D5 is to old that I don't remember whether this worked in these
versions already: in the form designer, go to the object inspector,
find the form's Color property and double-click on its current value.
That should pop up the color selection dialog, first in its compact
form. Click on the large button near the bottom ("define colors" or
such, I only have the german version handy at the moment) to expand the
dialog to show the color spectrum on the right. Pick a color you like
and click OK and it is transferred to the Color property as a hex
string.

$0020DBDB for example looks fairly golden to me <g>. How it looks like
also depends on variables such as the monitor's color temperature and
image quality in general.

To "texture" the form background you can paint on it using a pattern
brush. That is: you create a small black and white bitmap (8x8 pixels)
and assign that to the form.canvas.brush.bitmap property. When you fill
the form client area with this brush the bitmap is tiled across the
form and the black pixels are rendered in the current canvas background
color and the white pixels in the foreground color (or vice versa,
don't remember). I should have an example somewhere, a moment please...

procedure TForm1.FormPaint(Sender: TObject);
var
bmp: TBitmap;
i,k, offset: Integer;
begin
bmp:= TBitmap.Create;
try
bmp.width := 8;
bmp.height:= 8;
bmp.monochrome := true;
offset := 0;
for i:= 0 to 7 do begin
for k:= 0 to 7 do
if ((k+offset) mod 4) <> 0 then
bmp.canvas.Pixels[k,i] := clWhite
else
bmp.canvas.Pixels[k,i] := clBlack;
Inc(offset)
end;
Canvas.Brush.Color := $20DBDB;
Canvas.Font.Color := $10C0C0; {darker than brush color }
Canvas.Brush.Bitmap := bmp;
SetBkColor(Canvas.Handle, $20DBDB);
SetTextColor(Canvas.Handle, $10C0C0);
PatBlt(Canvas.handle,
ClientRect.left, ClientRect.top, ClientWidth, ClientHeight,
PATCOPY);
finally
bmp.free;
end;
end;


--
Peter Below
TeamB

John Shyer

Posts: 137
Registered: 1/29/10
Re: Gold textured color for form
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2016 11:54 AM   in response to: John Shyer in response to: John Shyer
Dear Dr. Below,

Thank you very much for your very detailed answer. I am now using Delphi XE and Delphi XE6, the Delphi 5 went out a long time ago. I am working to integrate your solution into my form. Thank you again for your help.

Sincerely, John Shyer

John Shyer wrote:
Hello,

About 10 or more years ago I somehow created a form with a gold color and lightly textured on Delphi 5. That code is long gone and I cannot remember how I did it, nor can I find anything close in manipulating the color chart. Does anyone have a TColor code for the color "gold" and also how does one texture the form?

Thank you in advance, John Shyer
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Gold textured color for form
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 25, 2016 9:58 AM   in response to: John Shyer in response to: John Shyer
John wrote:

Does anyone have a TColor code for the color "gold"

The RTL in modern Delphi versions actually has a Gold color constant defined
(see TColorRec.Gold and TAlphaColorRec.Gold):

TColor($00D7FF)


how does one texture the form?

Define "textured".

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02