Skip to content

Commit

Permalink
Image alpha channel usage - remove "transparent color"
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Feb 11, 2024
1 parent 94e6c09 commit 7aca860
Show file tree
Hide file tree
Showing 56 changed files with 2,679 additions and 2,862 deletions.
12 changes: 12 additions & 0 deletions Examples/form.simba
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ var
List: TLazListBox;
Lbl: TLazLabel;
Panel: TLazPanel;
Img: TLazImage;
SimbaImg: TImage;
begin
Form := TLazForm.Create();
Form.SetCaption('Example form');
Expand All @@ -49,6 +51,16 @@ begin
Form.SetColor(Colors.DARK_GREY);
Form.SetBorderStyle(bsSingle); // Do not allow resizing

SimbaImg := TImage.CreateFromTarget([0,0,400,400]);

Img := TLazImage.Create(Form);
Img.SetParent(Form);
Img.SetBounds(400,200,200,200);
Img.SetStretch(True);
Img.GetPicture().SetBitmap(SimbaImg.ToLazBitmap());

SimbaImg.Free();

Button := TLazButton.Create(Form);
Button.SetParent(Form);
Button.SetAutoSize(True);
Expand Down
23 changes: 23 additions & 0 deletions Examples/image_drawtext.simba
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var
myImage: TImage;
myBox: TBox;
begin
myImage := TImage.Create(500,1000);
myImage.Fill(Colors.DARK_GRAY);

myImage.SetFontAntialiasing(True);
myImage.SetFontSize(20);

myImage.DrawTextLines(TImage.FontNames, [10,10], Colors.BLACK);

myBox := [225,25,450,240];
myImage.DrawBox(myBox, Colors.RED);
myImage.DrawText(FormatDateTime('c', Now()), myBox, [ETextDrawAlignment.CENTER, ETextDrawAlignment.VERTICAL_CENTER], Colors.BLACK);

myImage.SetFontBold(True);
myImage.SetFontSize(50);
myImage.DrawText(IntToStr(Random(10000)), [225, 300], Colors.NAVY);

myImage.Show();
myImage.Free();
end.
104 changes: 54 additions & 50 deletions Source/Simba.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<TextDesc Value=""/>
</XPManifest>
<Icon Value="0"/>
<Resources Count="11">
<Resources Count="12">
<Resource_0 FileName="..\Examples\array.simba" Type="RCDATA" ResourceName="EXAMPLE_ARRAY"/>
<Resource_1 FileName="..\Examples\function.simba" Type="RCDATA" ResourceName="EXAMPLE_FUNCTION"/>
<Resource_2 FileName="..\Examples\loop.simba" Type="RCDATA" ResourceName="EXAMPLE_LOOP"/>
Expand All @@ -29,6 +29,7 @@
<Resource_8 FileName="..\Examples\json.simba" Type="RCDATA" ResourceName="EXAMPLE_JSON"/>
<Resource_9 FileName="..\Examples\form.simba" Type="RCDATA" ResourceName="EXAMPLE_FORM"/>
<Resource_10 FileName="..\Examples\irc.simba" Type="RCDATA" ResourceName="EXAMPLE_IRC"/>
<Resource_11 FileName="..\Examples\image_drawtext.simba" Type="RCDATA" ResourceName="EXAMPLE_DRAWTEXT"/>
</Resources>
</General>
<VersionInfo>
Expand All @@ -47,7 +48,7 @@
<Filename Value="../Simba-Win32"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;editor"/>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;editor;shapebuilders"/>
<Libraries Value="../Third-Party/lape/extensions/ffi/bin/win32"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;forms;codetools;targets;matchtemplate;algorithms;editor;finders;package;imagebox;colormath;components;image;array;matrix"/>
<UnitOutputDirectory Value="$(ProjPath)../build/$(BuildMode)/$(TargetCPU)-$(TargetOS)"/>
Expand Down Expand Up @@ -97,7 +98,7 @@
<Filename Value="../Simba-Win64"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;editor"/>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;editor;shapebuilders"/>
<Libraries Value="../Third-Party/lape/extensions/ffi/bin/win64"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;forms;codetools;targets;matchtemplate;algorithms;editor;finders;package;imagebox;colormath;components;image;array;matrix"/>
<UnitOutputDirectory Value="$(ProjPath)../build/$(BuildMode)/$(TargetCPU)-$(TargetOS)"/>
Expand Down Expand Up @@ -147,7 +148,7 @@
<Filename Value="../Simba-Linux64"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;editor"/>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;editor;shapebuilders"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;forms;codetools;targets;matchtemplate;algorithms;editor;finders;package;imagebox;colormath;components;image;array;matrix"/>
<UnitOutputDirectory Value="$(ProjPath)../build/$(BuildMode)/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
Expand Down Expand Up @@ -195,7 +196,7 @@
<Filename Value="../Simba-Linux-AArch64"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;editor"/>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;editor;shapebuilders"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;forms;codetools;targets;matchtemplate;algorithms;editor;finders;package;imagebox;colormath;components;image;array;matrix"/>
<UnitOutputDirectory Value="$(ProjPath)../build/$(BuildMode)/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
Expand Down Expand Up @@ -242,7 +243,7 @@
<Filename Value="../Simba"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;editor"/>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;editor;shapebuilders"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;forms;codetools;targets;matchtemplate;algorithms;editor;finders;package;imagebox;colormath;components;image;array;matrix"/>
<UnitOutputDirectory Value="$(ProjPath)../build/$(BuildMode)/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
Expand Down Expand Up @@ -295,7 +296,7 @@
<Filename Value="../Simba"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;editor"/>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;editor;shapebuilders"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;forms;codetools;targets;matchtemplate;algorithms;editor;finders;package;imagebox;colormath;components;image;array;matrix"/>
<UnitOutputDirectory Value="$(ProjPath)../build/$(BuildMode)/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
Expand Down Expand Up @@ -377,7 +378,7 @@
<PackageName Value="LCL"/>
</Item5>
</RequiredPackages>
<Units Count="119">
<Units Count="121">
<Unit0>
<Filename Value="Simba.lpr"/>
<IsPartOfProject Value="True"/>
Expand Down Expand Up @@ -817,130 +818,138 @@
<IsPartOfProject Value="True"/>
</Unit89>
<Unit90>
<Filename Value="../Third-Party/fpqoi_simba.pas"/>
<IsPartOfProject Value="True"/>
</Unit90>
<Unit91>
<Filename Value="forms/simba.settingsform_codetools.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="SimbaCodetoolsFrame"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Frame"/>
</Unit90>
<Unit91>
<Filename Value="codetools/simba.ide_codetools_keywords.pas"/>
<IsPartOfProject Value="True"/>
</Unit91>
<Unit92>
<Filename Value="codetools/simba.ide_codetools_keywords.pas"/>
<Filename Value="script/simba.script_pluginmethods.pas"/>
<IsPartOfProject Value="True"/>
</Unit92>
<Unit93>
<Filename Value="script/simba.script_pluginmethods.pas"/>
<Filename Value="targets/simba.target_plugin.pas"/>
<IsPartOfProject Value="True"/>
</Unit93>
<Unit94>
<Filename Value="targets/simba.target_plugin.pas"/>
<Filename Value="simba.externalimage.pas"/>
<IsPartOfProject Value="True"/>
</Unit94>
<Unit95>
<Filename Value="simba.externalimage.pas"/>
<Filename Value="simba.circle.pas"/>
<IsPartOfProject Value="True"/>
</Unit95>
<Unit96>
<Filename Value="simba.circle.pas"/>
<Filename Value="simba.quad.pas"/>
<IsPartOfProject Value="True"/>
</Unit96>
<Unit97>
<Filename Value="simba.quad.pas"/>
<IsPartOfProject Value="True"/>
</Unit97>
<Unit98>
<Filename Value="forms/simba.findinfilesform.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="SimbaFindInFilesForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit97>
<Unit98>
<Filename Value="image/simba.image_gaussblur.pas"/>
<IsPartOfProject Value="True"/>
</Unit98>
<Unit99>
<Filename Value="image/circlefilled.inc"/>
<Filename Value="forms/simba.downloadsimbaform.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="SimbaDownloadSimbaForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit99>
<Unit100>
<Filename Value="image/circle.inc"/>
<Filename Value="image/simba.image_bitmaparealoader.pas"/>
<IsPartOfProject Value="True"/>
</Unit100>
<Unit101>
<Filename Value="image/simba.image_gaussblur.pas"/>
<Filename Value="image/simba.image_utils.pas"/>
<IsPartOfProject Value="True"/>
</Unit101>
<Unit102>
<Filename Value="forms/simba.downloadsimbaform.pas"/>
<Filename Value="components/simba.component_toolbar.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="SimbaDownloadSimbaForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit102>
<Unit103>
<Filename Value="image/polygonfilled.inc"/>
<Filename Value="simba.ide_maintoolbar.pas"/>
<IsPartOfProject Value="True"/>
</Unit103>
<Unit104>
<Filename Value="image/boxfilled.inc"/>
<Filename Value="simba.ide_mainmenubar.pas"/>
<IsPartOfProject Value="True"/>
</Unit104>
<Unit105>
<Filename Value="image/simba.image_bitmaparealoader.pas"/>
<Filename Value="simba.internetsocket.pas"/>
<IsPartOfProject Value="True"/>
</Unit105>
<Unit106>
<Filename Value="image/simba.image_utils.pas"/>
<Filename Value="simba.stringmap.pas"/>
<IsPartOfProject Value="True"/>
</Unit106>
<Unit107>
<Filename Value="components/simba.component_toolbar.pas"/>
<Filename Value="script/imports/simba.import_stringmap.pas"/>
<IsPartOfProject Value="True"/>
</Unit107>
<Unit108>
<Filename Value="simba.ide_maintoolbar.pas"/>
<Filename Value="imagebox/simba.imagebox_new.pas"/>
<IsPartOfProject Value="True"/>
</Unit108>
<Unit109>
<Filename Value="simba.ide_mainmenubar.pas"/>
<Filename Value="simba.nativeinterface.pas"/>
<IsPartOfProject Value="True"/>
</Unit109>
<Unit110>
<Filename Value="simba.internetsocket.pas"/>
<Filename Value="simba.nativeinterface_windows.pas"/>
<IsPartOfProject Value="True"/>
</Unit110>
<Unit111>
<Filename Value="simba.stringmap.pas"/>
<Filename Value="simba.nativeinterface_darwin.pas"/>
<IsPartOfProject Value="True"/>
</Unit111>
<Unit112>
<Filename Value="script/imports/simba.import_stringmap.pas"/>
<Filename Value="simba.nativeinterface_linux.pas"/>
<IsPartOfProject Value="True"/>
</Unit112>
<Unit113>
<Filename Value="imagebox/simba.imagebox_new.pas"/>
<Filename Value="simba.box.pas"/>
<IsPartOfProject Value="True"/>
</Unit113>
<Unit114>
<Filename Value="simba.nativeinterface.pas"/>
<Filename Value="shapebuilders/shapebuilder_circle.inc"/>
<IsPartOfProject Value="True"/>
</Unit114>
<Unit115>
<Filename Value="simba.nativeinterface_windows.pas"/>
<Filename Value="shapebuilders/shapebuilder_circlefilled.inc"/>
<IsPartOfProject Value="True"/>
</Unit115>
<Unit116>
<Filename Value="simba.nativeinterface_darwin.pas"/>
<Filename Value="shapebuilders/shapebuilder_polygonfilled.inc"/>
<IsPartOfProject Value="True"/>
</Unit116>
<Unit117>
<Filename Value="simba.nativeinterface_linux.pas"/>
<Filename Value="shapebuilders/shapebuilder_boxedge.inc"/>
<IsPartOfProject Value="True"/>
</Unit117>
<Unit118>
<Filename Value="simba.box.pas"/>
<Filename Value="shapebuilders/shapebuilder_boxfilled.inc"/>
<IsPartOfProject Value="True"/>
</Unit118>
<Unit119>
<Filename Value="shapebuilders/shapebuilder_linegap.inc"/>
<IsPartOfProject Value="True"/>
</Unit119>
<Unit120>
<Filename Value="image/simba.image_stringconv.pas"/>
<IsPartOfProject Value="True"/>
</Unit120>
</Units>
</ProjectOptions>
<CompilerOptions>
Expand All @@ -949,7 +958,7 @@
<Filename Value="../Simba-Debug"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;editor"/>
<IncludeFiles Value="$(ProjOutDir);$(LazarusDir)/components/synedit;../Third-Party/lape;editor;shapebuilders"/>
<Libraries Value="../Third-Party/lape/extensions/ffi/bin/win64"/>
<OtherUnitFiles Value="$(ProjPath);../Third-Party;../Third-Party/lape;../Third-Party/lape/extensions/ffi;script/imports;script/imports/lcl;script;forms;codetools;targets;matchtemplate;algorithms;editor;finders;package;imagebox;colormath;components;image;array;matrix"/>
<UnitOutputDirectory Value="$(ProjPath)../build/$(BuildMode)/$(TargetCPU)-$(TargetOS)"/>
Expand All @@ -969,11 +978,6 @@
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
Expand Down
Binary file modified Source/Simba.res
Binary file not shown.
6 changes: 5 additions & 1 deletion Source/array/simba.array_point.pas
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,12 @@ function TPointArrayHelper.Connect: TPointArray;
if (Length(Self) > 1) then
begin
for I := 0 to High(Self) - 1 do
begin
Buffer.Add(TPointArray.CreateFromLine(Self[I], Self[I+1]));
Buffer.Pop(); // dont duplicate self[I+1]
end;
Buffer.Add(TPointArray.CreateFromLine(Self[High(Self)], Self[0]));
Buffer.Pop(); // dont duplicate self[0]
end;

Result := Buffer.ToArray(False);
Expand Down Expand Up @@ -869,7 +873,7 @@ function TPointArrayHelper.ShapeFill: TPointArray;
for Row in Rows() do
for I := 1 to High(Row) do
if TSimbaGeometry.PointInPolygon((Row[I-1] + Row[I]) div 2, Self) then
HorzLine(Row[0].Y, Row[I-1].X, Row[I].X);
HorzLine(Row[0].Y, Row[I-1].X + 1, Row[I].X - 1);

Result := Buffer.ToArray(False);
end;
Expand Down
1 change: 0 additions & 1 deletion Source/codetools/simba.ide_codetools_parser.pas
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ TCodeParser = class(TmwSimplePasPar)
constructor Create; override;
destructor Destroy; override;
end;
TPluginParser = class(TCodeParser);

TCodeParserArray = array of TCodeParser;
TCodeParserList = specialize TSimbaObjectList<TCodeParser>;
Expand Down
4 changes: 3 additions & 1 deletion Source/colormath/simba.colormath.pas
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface
{$POP}

PChannelMultipliers = ^TChannelMultipliers;
TChannelMultipliers = array [0..2] of Single;
TChannelMultipliers = array[0..2] of Single;

const
DefaultMultipliers: TChannelMultipliers = (1, 1, 1);
Expand All @@ -38,6 +38,8 @@ interface
function AsString: String;
end;

// note: TColor stuff should not include alpha

TColor = Graphics.TColor;
PColor = ^TColor;

Expand Down

0 comments on commit 7aca860

Please sign in to comment.