Jump to content
Sign in to follow this  
Czar

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]

 

Share this post


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);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×