You've already forked lazarus-ccr
fpvectorial: Advances color support
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1556 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -52,7 +52,7 @@ type
|
|||||||
|
|
||||||
TPolylineElement = record
|
TPolylineElement = record
|
||||||
X, Y: Double;
|
X, Y: Double;
|
||||||
Color: TFPColor;
|
Color: TvColor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TSPLineElement = record
|
TSPLineElement = record
|
||||||
@ -108,7 +108,7 @@ type
|
|||||||
procedure ReadENTITIES_POINT(ATokens: TDXFTokens; AData: TvVectorialDocument);
|
procedure ReadENTITIES_POINT(ATokens: TDXFTokens; AData: TvVectorialDocument);
|
||||||
function GetCoordinateValue(AStr: shortstring): Double;
|
function GetCoordinateValue(AStr: shortstring): Double;
|
||||||
//
|
//
|
||||||
function DXFColorIndexToFPColor(AColorIndex: Integer): TFPColor;
|
function DXFColorIndexToVColor(AColorIndex: Integer): TvColor;
|
||||||
public
|
public
|
||||||
{ General reading methods }
|
{ General reading methods }
|
||||||
Tokenizer: TDXFTokenizer;
|
Tokenizer: TDXFTokenizer;
|
||||||
@ -1084,7 +1084,7 @@ begin
|
|||||||
SetLength(Polyline, curPoint+1);
|
SetLength(Polyline, curPoint+1);
|
||||||
Polyline[curPoint].X := 0;
|
Polyline[curPoint].X := 0;
|
||||||
Polyline[curPoint].Y := 0;
|
Polyline[curPoint].Y := 0;
|
||||||
Polyline[curPoint].Color := colBlack;
|
Polyline[curPoint].Color := clvBlack;
|
||||||
|
|
||||||
for i := 0 to ATokens.Count - 1 do
|
for i := 0 to ATokens.Count - 1 do
|
||||||
begin
|
begin
|
||||||
@ -1105,7 +1105,7 @@ begin
|
|||||||
62:
|
62:
|
||||||
begin
|
begin
|
||||||
if (CurToken.FloatValue >= 0) and (CurToken.FloatValue <= 15) then
|
if (CurToken.FloatValue >= 0) and (CurToken.FloatValue <= 15) then
|
||||||
Polyline[curPoint].Color := DXFColorIndexToFPColor(Trunc(CurToken.FloatValue));
|
Polyline[curPoint].Color := DXFColorIndexToVColor(Trunc(CurToken.FloatValue));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1128,7 +1128,7 @@ begin
|
|||||||
{$endif}
|
{$endif}
|
||||||
for i := 1 to Length(Polyline)-1 do
|
for i := 1 to Length(Polyline)-1 do
|
||||||
begin
|
begin
|
||||||
AData.AddLineToPath(Polyline[i].X, Polyline[i].Y);
|
AData.AddLineToPath(Polyline[i].X, Polyline[i].Y, Polyline[i].Color);
|
||||||
{$ifdef FPVECTORIALDEBUG_POLYLINE}
|
{$ifdef FPVECTORIALDEBUG_POLYLINE}
|
||||||
Write(Format(' %f,%f', [Polyline[i].X, Polyline[i].Y]));
|
Write(Format(' %f,%f', [Polyline[i].X, Polyline[i].Y]));
|
||||||
{$endif}
|
{$endif}
|
||||||
@ -1227,10 +1227,13 @@ begin
|
|||||||
Result := StrToFloat(Copy(AStr, 2, Length(AStr) - 1));}
|
Result := StrToFloat(Copy(AStr, 2, Length(AStr) - 1));}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TvDXFVectorialReader.DXFColorIndexToFPColor(AColorIndex: Integer
|
function TvDXFVectorialReader.DXFColorIndexToVColor(AColorIndex: Integer
|
||||||
): TFPColor;
|
): TvColor;
|
||||||
begin
|
begin
|
||||||
|
if (AColorIndex <= 0) and (AColorIndex <= 15) then
|
||||||
|
Result := AUTOCAD_COLOR_PALETTE[AColorIndex]
|
||||||
|
else
|
||||||
|
raise Exception.Create(Format('[TvDXFVectorialReader.DXFColorIndexToFPVColor] Invalid DXF Color Index: %d', [AColorIndex]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TvDXFVectorialReader.Create;
|
constructor TvDXFVectorialReader.Create;
|
||||||
|
@ -48,6 +48,8 @@ const
|
|||||||
FPValphaTransparent = $00;
|
FPValphaTransparent = $00;
|
||||||
FPValphaOpaque = $FF;
|
FPValphaOpaque = $FF;
|
||||||
|
|
||||||
|
clvBlack: TvColor = (Red: $00; Green: $00; Blue: $00; Alpha: FPValphaOpaque);
|
||||||
|
|
||||||
type
|
type
|
||||||
T3DPoint = record
|
T3DPoint = record
|
||||||
X, Y, Z: Double;
|
X, Y, Z: Double;
|
||||||
|
@ -11,8 +11,9 @@ uses
|
|||||||
{$ifdef USE_LCL_CANVAS}
|
{$ifdef USE_LCL_CANVAS}
|
||||||
Graphics, LCLIntf,
|
Graphics, LCLIntf,
|
||||||
{$else}
|
{$else}
|
||||||
fpcanvas, fpimage,
|
fpcanvas,
|
||||||
{$endif}
|
{$endif}
|
||||||
|
fpimage,
|
||||||
fpvectorial;
|
fpvectorial;
|
||||||
|
|
||||||
procedure DrawFPVectorialToCanvas(ASource: TvVectorialDocument;
|
procedure DrawFPVectorialToCanvas(ASource: TvVectorialDocument;
|
||||||
@ -29,6 +30,21 @@ implementation
|
|||||||
{$define FPVECTORIALDEBUG}
|
{$define FPVECTORIALDEBUG}
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
{$ifdef USE_LCL_CANVAS}
|
||||||
|
function VColorToTColor(AVColor: TvColor): TColor; inline;
|
||||||
|
begin
|
||||||
|
Result := RGBToColor(AVColor.Red, AVColor.Green, AVColor.Blue);
|
||||||
|
end;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
function VColorToFPColor(AVColor: TvColor): TFPColor; inline;
|
||||||
|
begin
|
||||||
|
Result.Red := AVColor.Red;
|
||||||
|
Result.Green := AVColor.Green;
|
||||||
|
Result.Blue := AVColor.Blue;
|
||||||
|
Result.Alpha := AVColor.Alpha;
|
||||||
|
end;
|
||||||
|
|
||||||
function Rotate2DPoint(P,Fix :TPoint; alpha:double): TPoint;
|
function Rotate2DPoint(P,Fix :TPoint; alpha:double): TPoint;
|
||||||
var
|
var
|
||||||
sinus, cosinus : Extended;
|
sinus, cosinus : Extended;
|
||||||
@ -174,7 +190,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
st2DLine, st3DLine:
|
st2DLine, st3DLine:
|
||||||
begin
|
begin
|
||||||
|
ADest.Pen.Color := {$ifdef USE_LCL_CANVAS}VColorToTColor(Cur2DSegment.Color);{$else}VColorToFPColor(Cur2DSegment.Color);{$endif}
|
||||||
ADest.LineTo(CoordToCanvasX(Cur2DSegment.X), CoordToCanvasY(Cur2DSegment.Y));
|
ADest.LineTo(CoordToCanvasX(Cur2DSegment.X), CoordToCanvasY(Cur2DSegment.Y));
|
||||||
|
ADest.Pen.Color := clBlack;
|
||||||
{$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
{$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
|
||||||
Write(Format(' L%d,%d', [CoordToCanvasX(Cur2DSegment.X), CoordToCanvasY(Cur2DSegment.Y)]));
|
Write(Format(' L%d,%d', [CoordToCanvasX(Cur2DSegment.X), CoordToCanvasY(Cur2DSegment.Y)]));
|
||||||
{$endif}
|
{$endif}
|
||||||
|
Reference in New Issue
Block a user