Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 02-17-2018, 06:11 AM
lex lex is offline
Junior Member
 
Join Date: Feb 2012
Posts: 27
Default SmoothLineTo Canvas

TMoveCanvas has a FTopLeft that everything inside the object references to
I want a procedure smoothLineTo(
FMoved is the Pointer of last position moved to
"If (cEnd.X > cEnd.Y) then" is to separate and idenify the longest side
as cEnd is the Line vector to be drawn
aColor gives me access to the colour faster
I need a quick way to identify the colour strength of the pixel and the pixel above it or below it may be.
I need a faster way to paint the pixel than through the Tcanvas object.


Code:
Type
 aColor = record
  case Integer of
  0: (Y, B, G, R: byte);
  1: (C: TColor);
 end;

procedure TMoveCanvas.SmoothLineTo(X, Y: Integer);
Var
   cEnd: TPoint;
   I, G, R, S: Integer;
   C1, C2: TColor;

 Function GetColour(Colour: TColor; Strength: Word): TColor;
 Var Y, B, G, R: byte;
 begin
  aColor(Colour).B * (Strength div 1000)


 end;

begin
 If (X = FMoved.X) or (Y = FMoved.Y) then
  Begin
   FCanvas.LineTo(X - TFTopLeft.X, Y - TFTopLeft.Y);
   FMoved := Point(X, Y);
   Exit;
  end;
 cEnd.X := X - FMoved.X;// - TFTopLeft.X;
 cEnd.Y := Y - FMoved.Y;

 If (cEnd.X <> cEnd.Y) then
 If (cEnd.X > cEnd.Y) then
  begin
    G := 1000 * cEnd.X div cEnd.Y;
    For I := 0 to cEnd.X do
     Begin
      R := I * G;
      S := R and 1000;

     end

  end else
  begin


  end;
end;
Reply With Quote
  #2  
Old 02-19-2018, 08:28 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,303
Default

Sorry, but I really have no idea what you're looking for.
And since this code doesn't do anything except drawing a line (FCanvas.MoveTo) and the rest is all pseudo code (with variable names without meaning) it's hard to figure out what you're after.
You want faster routines for things you don't even use at this point. Perhaps if you provide your slow routines in use without all this pseudo stuff will give us a better understanding what you're after...
Reply With Quote
  #3  
Old 02-19-2018, 09:50 AM
lex lex is offline
Junior Member
 
Join Date: Feb 2012
Posts: 27
Default

because I do not know how to
access the canvas to draw many dots with the different intensity of colors
in a fast manor.
If I draw with the Delphi pixel its two slow
I considering using threads too speed things up and holding the print method open until the thread has finished by using the canvas lock feature and sleep.
Reply With Quote
  #4  
Old 02-19-2018, 11:27 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,303
Default

In the code you posted above is nothing of printing dots in any place.
Only thing you do is draw a line.
So again, what does the "slow" code look like?

And what is this code supposed to do, in here it looks like you redraw the entire thing over and over. And how many times is this code executed? For example, if it's executed in an WM_PAINT this is very slow. Since it retriggers itself over and over. You should lock your Canvas (normally this will increase speed aswell).
If it's done in a WM_MOUSEMOVE this is very slow, since that is executed too many times (FMoved has changed) and again a retrigger over and over. In the case you should introduce a UM_ENDMOUSEMOVE event and react on that.
Basically, I think your code is executed too many times, as it should only be executed 1 time. And in this you think it's slow, but it should be fine I guess.

But again, all assumptions since your original question is missing a lot of this infomation.
Reply With Quote
  #5  
Old 02-19-2018, 10:01 PM
lex lex is offline
Junior Member
 
Join Date: Feb 2012
Posts: 27
Default

I have may be 50 lines to draw and its got to be fast of cause
I'm using DoubleBuffered (2 canva's) to remove flicker.
this is a professional result now

I made this project once that I did not worry about details
I have a good tool bar
I remember previous opened files
Made a number of objects to take code out of the main code so details are easier to focus on.
I do not see it hard to move it to Delphi XE8 and do a linix version
Reply With Quote
  #6  
Old 02-20-2018, 07:53 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,303
Default

Again, no answers to my questions/suggestions
But DoubleBuffered was enough?
Reply With Quote
Reply

Tags
canvas

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 02:19 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2018, vBulletin Solutions, Inc.