| Autor |
Beitrag |
BenBE
      
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: So 18.07.04 18:46
Wie kann ich punktierte Linien zeichnen, wie diese auch von TCanvas.DrawFocusRect gezeichnet werden? TPen.Style := psDot funzt leider nicht. der zeichnet mir gestrichelte Linien von 3px Länge pro Strich.
_________________ Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
|
|
Muetze1
      
Beiträge: 346
|
Verfasst: So 18.07.04 18:57
Moin!
Dazu musst du dann die LineDDA() Funktion verwenden. Mit dieser habe ich auch eine "Marching Ants" Linie hinbekommen (diese schwarz-weissen Linien die immer wandern).
MfG
Muetze1
|
|
BenBE 
      
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: So 18.07.04 19:14
Ich hab zwar in der Hilfe die beiden relevanten Dinge (LineDDA und LineDDAProc) gefundn, aber leider blieben mir da noch einige Dinge unklar:
| Delphi-Hilfe (Sektion WinAPI) zu LineDDA hat folgendes geschrieben: | The LineDDA function determines which pixels should be highlighted for a line defined by the specified starting and ending points.
BOOL LineDDA(
int nXStart, // x-coordinate of line's starting point
int nYStart, // y-coordinate of line's starting point
int nXEnd, // x-coordinate of line's ending point
int nYEnd, // y-coordinate of line's ending point
LINEDDAPROC lpLineFunc, // address of application-defined callback function
LPARAM lpData // address of application-defined data
); |
Also so deklarieren???
Delphi-Quelltext 1:
| Function LineDDA(nXSstart, nYStart, nXEnd, nYEnd: Integer; LineDDAProc: TLineDDAProc; Data:Pointer): Boolean; stdcall; |
| Delphi-Hilfe (Sektion WinAPI) zu LineDDAProc hat folgendes geschrieben: | A LineDDAProc function is an application-defined callback function that processes coordinates from the LineDDA function. A value of type LINEDDAPROC is a pointer to such a function.
VOID CALLBACK LineDDAProc(
int X, // x-coordinate of point being evaluated
int Y, // y-coordinate of point being evaluated
LPARAM lpData // address of application-defined data
); |
Delphi-Quelltext 1: 2:
| type TLineDDAProc = Procedure(X, Y:Integer; Data:Pointer); stdcall; |
Stimmen die Deklarationen so?
Jedoch konnte ich unter D5 keine Deklaration dieser Funktion und des Prozedur-Typs finden.
Weiterhin wird aus der Hilfe leider nicht ersichtlich, ob mein Programm, oder Windows das Zeichnen der Punkte übernimmt (ich glaub aber mal mein Programm  ).
Kannst du mir mal ein Quelltextbeispiel geben?
_________________ Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
|
|
Muetze1
      
Beiträge: 346
|
Verfasst: So 18.07.04 20:05
Moin!
Ich habe einfach mal schnell meine "Marching Ants" in ein kleines Beispielprojekt ausgelagert und auf meine HP gepackt. Schau es dir an, ich male dort ja auch mit der LineDDA() Funktion rum...
Marching Ants Example
MfG
Muetze1
|
|
BenBE 
      
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: Mo 19.07.04 18:00
THX, genau, was ich gesucht hab.
_________________ Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
|
|
BenBE 
      
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: Sa 28.07.07 19:34
Da nachgefragt wurde, wie das ganze mit LineDDA funktioniert, hier mal ein kleines Beispiel zur Nachahmung von TCanvas.FocusRect: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75:
| Procedure LineDDARect(C: TCanvas; R: TRect; Counter: Integer = 0); Type PLineCallbackInfo = ^TLineCallbackInfo; TLineCallbackInfo = Packed Record Counter: Integer; Canvas: TCanvas; End;
Var Data: TLineCallbackInfo;
Procedure DottedLineCallback(X, Y: Integer; Data: PLineCallbackInfo); Stdcall; Begin With Data^ Do Begin Counter := (7 + Counter) Mod 8; If Counter And 1 <> 0 Then Begin With Canvas Do Begin Case Pen.Mode Of pmBlack: Pixels[X, Y] := clBlack; pmWhite: Pixels[X, Y] := clWhite;
pmXor: Pixels[X, Y] := ColorToRGB(Pixels[X, Y]) Xor ColorToRGB(Pen.Color); pmNotXor: Pixels[X, Y] := Not (ColorToRGB(Pixels[X, Y]) Xor ColorToRGB(Pen.Color));
pmMask: Pixels[X, Y] := ColorToRGB(Pixels[X, Y]) And ColorToRGB(Pen.Color); pmMerge: Pixels[X, Y] := MergeColors(ColorToRGB(Pixels[X, Y]), ColorToRGB(Pen.Color));
pmMaskPenNot: Pixels[X, Y] := (Not ColorToRGB(Pixels[X, Y])) And ColorToRGB(Pen.Color); pmMergePenNot: Pixels[X, Y] := MergeColors(Not ColorToRGB(Pixels[X, Y]), ColorToRGB(Pen.Color));
pmMaskNotPen: Pixels[X, Y] := ColorToRGB(Pixels[X, Y]) And (Not ColorToRGB(Pen.Color)); pmMergeNotPen: Pixels[X, Y] := MergeColors(ColorToRGB(Pixels[X, Y]), Not ColorToRGB(Pen.Color));
pmNotMask: Pixels[X, Y] := Not ColorToRGB(Pixels[X, Y]) And ColorToRGB(Pen.Color); pmNotMerge: Pixels[X, Y] := Not MergeColors(ColorToRGB(Pixels[X, Y]), ColorToRGB(Pen.Color));
pmNop: ; pmNot: Pixels[X, Y] := Not ColorToRGB(Pixels[X, Y]); pmNotCopy: Pixels[X, Y] := Not ColorToRGB(Pen.Color); Else Pixels[X, Y] := ColorToRGB(Pen.Color); End; End; End; End; End;
Begin Data.Counter := Counter; Data.Canvas := C;
LineDDA(R.Left, R.Top, R.Right - 1, R.Top, @DottedLineCallback, Integer(@Data)); LineDDA(R.Right - 1, R.Top, R.Right - 1, R.Bottom - 1, @DottedLineCallback, Integer(@Data)); LineDDA(R.Right - 1, R.Bottom - 1, R.Left, R.Bottom - 1, @DottedLineCallback, Integer(@Data)); LineDDA(R.Left, R.Bottom - 1, R.Left, R.Top, @DottedLineCallback, Integer(@Data)); End; | Hier mal noch kurz ein kleiner Nachtrag, für diejenigen, denen eine Routine in meinem obigen Source fehlt: Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19:
| Type TColorRecord = Packed Record R, G, B: Byte; Alpha: Byte; End;
Function MergeColors(C1, C2: TColor): TColor; Var TmpR, TmpG, TmpB: Word; Begin TmpR := TColorRecord(ColorToRGB(C1)).R + TColorRecord(ColorToRGB(C2)).R; TmpG := TColorRecord(ColorToRGB(C1)).G + TColorRecord(ColorToRGB(C2)).G; TmpB := TColorRecord(ColorToRGB(C1)).B + TColorRecord(ColorToRGB(C2)).B;
TColorRecord(Result).Alpha := 0; TColorRecord(Result).R := TmpR Div 2; TColorRecord(Result).G := TmpG Div 2; TColorRecord(Result).B := TmpB Div 2; End; |
_________________ Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
|
|
|