Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 07/29/20 in all areas

  1. I am not sure many know that since the Windows Creators update, svg parsing and painting is natively supported and is part of Direct2D. I wanted to test this Windows feature, however, the first obstacle was that the Direct2d headers that come with Delphi are very very old. There are two open tickets in https://quality.embarcadero.com/. Direct2D 1.1 support missing (open since XE7!) Direct2D 1.2 and 1.3 support missing You may want to vote for them, since lack of good Direct2D support (includes DirectWrite) it is a bit of a shame. I then looked at other Direct2D translations and found two that are regularly updated. MfPack DelphiDX12 They both had some issues but that was a good start. It turned out that parsing and painting svg files to Canvas is quite straightforward. Once you establish a renderer (Vcl.Direct2d does this, but it is easy to do it from scratch) you can do everything with two lines of code. fDeviceContext5.CreateSvgDocument(fStream, D2D1SizeF(ClientWidth, ClientHeight), fsvgDocument); fDeviceContext5.DrawSvgDocument(fsvgDocument); You can check whether Svg is supported by: if Supports( rt, ID2D1DeviceContext5, fDeviceContext5) then And it is easy to do things like scaling, opacity, rotation, recoloring etc. The quality and speed appear to be quite good, but there are some limitations, the most important of which I think is the lack of support for the text element. I am attaching the source code of my test project (no dependencies) in case anyone wants to play with it. The Svg scales automatically as you resize the form. Svg.zip
  2. I only do occasional graphics work, and Affinity Designer is a more realistic option for me than an Adobe subscription. I am not a graphics designer, but have done quite a bit of graphics work over the years. And I would say that Affinity Designer does make it relatively easy, even for a dabbler, to produce good results. There are many good videos on youtube. I would recommend this one, to start:
  3. pyscripter

    Just-in-time compiling for Delphi's Regular Expressions

    FLRE is the fastest of all! One single pascal file which is good The author is a kind of genius But not as extensively tested as PCRE poorly documented not very well supported the performance gain compared to PCRE+JIT is not that big System.RegularExpressions has a nicer interface All-in-all I would stick to System.RegularExpressions at least if you add JIT.
  4. Remy Lebeau

    Problem closing forms..

    Show() is non-blocking, so your example would reach myForm.Free() before the Form's window is actually shown to the user. It is perfectly safe to use caFree with a modal Form. The Form object remains alive until after ShowModal() exits and control returns to the main message loop, THEN the Form is destroyed. If you want to get results from the Form, you just have to do so immediately after ShowModal() exits, which is the best time to get the results anyway. If you need the results at a later time, save them somewhere that you can get them back when needed. So, you would either: -auto-create a Form and then Show()/Hide() it when needed. Let the TApplication handle destroying the Form during app shutdown. - Create() and Show() the Form, then Free() it when you don't need it anymore, or use OnClose to caFree it. - Create() and ShowModal() the Form, and then Free() it (directly or via caFree) after ShowModal() has exited.
  5. David Schwartz

    Problem closing forms..

    Forms are objects. They behave just like objects. And IMHO, they should be treated just like any other objects. All TObjects have a Constructor and Destructor. What's normally done is: myObj := TMyObj.Create; try myObj.abc := 123; // initialize things . . . myObj.DoSomething; rslt1 := myObj.GetResult; // get stuff out of the object . . . finally myObj.Free; end; TForms are TObjects, and they also have: * OnCreate and OnDestroy. * OnShow and OnHide. * OnClose Things you create in the OnCreate method should be freed in OnDestroy. Things you create and enable in OnShow often need to be freed / disabled in OnHide. OnClose is a quirk. It's useful for some purposes, but it can often cause more problems than it's worth. Forms can be created and destroyed automatically, so they're persistent throughout the life of the application. You just use normal properties and methods to access things on the form (although most people don't bother with defining properties to interact with forms). For typical dynamic form use, this approach can be used: myForm := TMyForm.Create(NIL); try // OnCreate is called here myForm.abc := 123; // initialize things . . . myForm.Show; // OnShow ... do stuff ... OnHide // do some stuff here before calling Free . . . -- or use ShowModal -- if (myForm.ShowModal = mrOK) then // OnShow ... do stuff ... OnHide begin rslt1 := myForm.GetResult; // get stuff out of the object . . . end; finally myForm.Free; // OnDestroy is called here end; This is really clean. The structure is just like any other object whether you need to add parameters to initialize the object (form) before use or get result data afterwards. The only times I've run into issues is when I rely on the OnClose method with caFree. People don't like using 'with' because of its implicit references. Well, relying on OnClose with caFree presents similar implicit actions, and can be equally problematic. If you rely on caFree in the OnClose handler, and you decide to get some result data from the form later, you have a lot more work to do because the object myForm pointed to has been freed after ShowModal returns.
  6. Fr0sT.Brutal

    Running Tokyo 10.2.3 dcc32 from the command line

    rsvars.bat && msbuild.exe /t:build /nologo %ProjFile% beat it with call to dcc32 😜
  7. dummzeuch

    Just-in-time compiling for Delphi's Regular Expressions

    Easy: Revolutionary Socialist Party 😉
  8. pyscripter

    Just-in-time compiling for Delphi's Regular Expressions

    There is an RSP https://quality.embarcadero.com/browse/RSP-21733 that asks for PCRE JIT support in the Delphi RTL. If you want the extra PCRE performance please vote for this. Off-topic. What does RSP stand for?
  9. Remy Lebeau

    TImage Transparency question

    Put the PNG TImage on top of another TImage, or a TPanel, or whatever you want, that has the desired background image.
  10. Stefan Glienke

    Running Tokyo 10.2.3 dcc32 from the command line

    Now that is clearly shorter than calling dcc32! /irony off
×