Jump to content

inheritance


Recommended Posts

I have been working on rendering fonts onto the canvas. After getting a few pointers I managed to get what I am after.

However, I have been hacking direct into the smartcl.legacy

procedure TCanvas.TextOut(dx,dy: integer;aText: string;aColor:TColor);
var
  mTemp:  Variant;
begin
  mTemp:=FDC.fillStyle;
  FDC.fillStyle:=ColorToWebStr(aColor);

  FDC.lineWidth:=4;
  FDC.shadowBlur := 7;
  FDC.shadowColor := 'black';

  FDC.strokeText(aText,dx,dy);
  FDC.shadowBlur:=0;
  FDC.fillStyle:="white";
  FDC.FillText(aText,dx,dy);
  FDC.fillStyle:=mTemp;

I thought i could simply inherit

 

type TMyCanvas = class(Tcanvas)
      procedure MyTextOut(dx,dy: integer;aText: string;aColor:TColor);
      end;

procedure TMyCanvas.MyTextOut(dx,dy: integer;aText: string;aColor:TColor);
var
  mTemp:  Variant;
begin
  FDC.lineWidth:=4;
  FDC.shadowBlur := 7;
  FDC.shadowColor := 'black';

  FDC.strokeText(aText,dx,dy);
  FDC.shadowBlur:=0;
  FDC.fillStyle:="white";
  FDC.FillText(aText,dx,dy);
  FDC.fillStyle:=mTemp;
end;

However, I get an error FDC not visible in this scope. What basic 101 am I violating?

 

Syntax Error: Member symbol "FDC" is not visible from this scope [line: 54, column: 10, file: Form1]

 

Link to post
Share on other sites

I managed to a solution which is probably better

 

  var Context := JCanvasRenderingContext2D(LBitmap.canvas.context.handle.getContext('2d'));


    Context.font:="75px verdana";
Context.shadowColor:="black";
Context.shadowBlur:=7;
Context.lineWidth:=5;
Context.strokeText("TEstMe",25,100);
Context.shadowBlur:=0;
Context.fillStyle:="white";
Context.fillText("TEstMe",25,100);

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...