Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation since 11/27/21 in all areas

  1. vfbb

    Skia versus VCL for plotting points

    Hello. I adapted your test with Skia4Delphi to directly access the pixels instead of painting the pixel. The result was 45 ms on win64. procedure TfrmMain.Button3Click(Sender: TObject); procedure DrawMandelbrotPixmap(APixmap: ISkPixmap; X, Y, au, bu: Double; X2, Y2: Integer); var c1, c2, z1, z2, tmp: Double; i, j, Count, rgb: Integer; hue, saturation, value: Double; begin c2 := bu; for i := 10 to X2 - 1 do begin c1 := au; for j := 0 to Y2 - 1 do begin z1 := 0; z2 := 0; Count := 0; // count is deep of iteration of the mandelbrot set // if |z| >=2 then z is not a member of a mandelset while (((z1 * z1 + z2 * z2 < 4) and (Count <= 50))) do begin tmp := z1; z1 := z1 * z1 - z2 * z2 + c1; z2 := 2 * tmp * z2 + c2; Inc(Count); end; // The color depends on the number of iterations hue := count / 50; saturation := 0.6; value := 0.5; PCardinal(APixmap.PixelAddr[i, j])^ := HSLtoRGB(hue, saturation, value); c1 := c1 + X; end; c2 := c2 + Y; end; end; var au, ao: Double; dX, dY, bo, bu: Double; LWidth: Integer; LHeight: Integer; LTimer: TStopwatch; LBitmap: TBitmap; LSurface: ISkSurface; begin LTimer := TStopwatch.StartNew; LWidth := Image1.Width; LHeight := Image1.Height; LSurface := TSkSurface.MakeRaster(LWidth, LHeight); LBitmap := TBitmap.Create(LWidth, LHeight); try ao := 1; au := -2; bo := 1.5; bu := -1.5; // direct scaling cause of speed dX := (ao - au) / (LWidth); dY := (bo - bu) / (LHeight); DrawMandelbrotPixmap(LSurface.PeekPixels, dX, dY, au, bu, LWidth, LHeight); LBitmap.SkiaDraw( procedure (const ACanvas: ISkCanvas) begin ACanvas.DrawImage(LSurface.MakeImageSnapshot, 0, 0); end); Image1.Picture.Assign(LBitmap); finally LBitmap.Free; end; Showmessage(LTimer.Elapsed.TotalMilliseconds.ToString+' ms'); end; However, your benchmark isn't accurate, you're basically changing pixel by pixel, it's not a good way to measure drawing library performance. Also, tasks that change an image pixel by pixel almost always perform better by creating a shader to run on the GPU. This is another advantage of Skia4Delphi, as it allows you to create shaders at runtime through the Skia Shader Language (based on GLSL). Even now I'm preparing a VCL sample of an animated shader, see the performance: 27.11.2021_01.05.45_REC.mp4 27.11.2021_01.05.45_REC.mp4
  2. SudokuHelper is an application that acts like an electronic Sudoku grid. It supports 9x9, 12x12, and 16x16 Sudokus, both in the classic and Gosu variant, where cells can be marked to only accept even numbers. The application neither creates Sudokus itself nor provides a solver for them; it is just a more convenient way to solve a Sudoku from a magazine or other external source than doing it on paper, using pencil and eraser. The application's main features are: Invalid cell values are marked in red. Candidate values can be added and removed from a cell. Setting a cell's value will automatically remove candidates no longer possible in other cells. All actions can be undone, the undo stack is only limited by available memory. Named marks can be set for the current undo stack state and one can later restore the stack to such a named mark. The complete Sudoku can be saved to file, including the undo stack, and later loaded again from such a file. The project can be found on GitHub: https://github.com/PeterBelow/SudokuHelper The code is a good example (IMO) of how to uncouple the UI from the "buisness" code using interfaces, in a kind of MVC design. It is free (public domain) without restrictions.
  3. hsvandrew

    Hot Reload in Delphi?

    In my opinion hot reload is probably the most significant improvement to development since the Delphi IDE made VB look ancient. Developers are very expensive, and there are never enough hours in the day. For some reason developers spend all day making productivity tools for others, but seem to still work with spades instead of bulldozers. I can see this feature being worth at least $5000USD/year/developer which is a game changer. The fact the Delphi community doesn't see how important this is, well, it says a lot.
  4. CHackbart

    MacOS NSVisualEffectView implementation

    I managed to get it working. To do so I had to move the main view to the front and set the background color of the layer to transparent. This works also when UseGlobalMetal is enabled.
  5. futuron

    Delphi on Windows 11 on MacBook Pro 16 (2021)

    Hi Lars, not sure why you are having problems. I think I have the same setup and mine works like a charm. Compilation speed is totally absurd. My previous dev environment was on a late 2014 Macbook Pro (16GB mem, and additional Nvidia graphics). My new Laptop with an M1 Max processor (32GB mem) is a beast compared to my old laptop (and a beast to any other Windows laptop in our building - lol). Not really fair because having six years in-between, but compared to my home-game computer this this is fast! Real fast! Back to your problem, maybe telling about my setup, and the following order of getting to that setup helps: MacBook Pro 16 (M1 Max processor): macOS Monterey (version 12.0.1) installed Xcode 13 (v13.1) and inside of that I created a few signing certificates (apple development, and apple distribution certificate) Parallels Desktop Version 17.1.0 (51516) Inside Parallels: Installed "Windows 11 Pro Insider Preview" installed (thus ARM version) inside (Build 2250.rs_prerelease.211112-1650) I left everything to standard/automatic (such as CPU&Memory is set to "automatic" on my machine) graphics set to "best for external displays" as I typically run Windows/Delphi on a bit larger external display Inside Startup and Shutdown (options) I changed "on VM shutdown" to "close window" so I don't manually have to close the VM after I shut down windows Coming from VMWare I set several sharing and applications settings such that they mostly matched what I was used to Then booted Windows inside Parallels. Installed Delphi 11 Applied the November Patch Coped PAserver22.0.pkg from "C:\Program Files (x86)\Embarcadero\Studio\22.0\PAServer" to a shared folder inside Parallels so I can access it from my Mac Back to the Mac: Ran "PAserver22.0.pkg" to install PAserver Then ran the just installed PAserver-22.0 app (when I run PAserver it tells me that the version is 13.0.12.1) inside the window, pressed enter (thus not using a password), and then pressed "i" to retrieve the IP address needed in Delphi Back to Windows Started Delphi Inside Tools/Options: Connection profile manager, added host, called it MacOS, gave it the IP address found within PAserver. I didn't touch the port number or the password. The connection should then work properly Once the connection is OK then proceeded to SDK manager and installed SDK manager: added the macOS 64-bit (MacOSX 12.0) SDK, telling overwrite existing files SDK manager: also added macOS ARM 64-bit (MacOSX 12.0) SDK SDK manager: iOS device 64-bit (iPhoneOS 15.) SDK SDK's for android 32 and 64 bit along with windows 10 SDK were already installed with Delphi After that I installed all my regular components The above following-order 100% works, at least for me. So far I've compiled 32-bit windows, 64-bit windows, MacOS 64-bit, MacOS ARM!, and iOS apps without any problems. I can also package both Mac apps and iOS apps for Apple's stores! Probably today I'll try compiling for Android. And for who wonders... compilation speeds are totally nuts from my point of view. This thing is real fast. I will be saving time not having to wait as much for compiling, and packaging apps. Not even mentioning waiting for starting MS office apps (build for ARM) on the Mac-side, or running any other program on the Mac side. I ran Pixelmator the other day, did a "super ML resolution" on an image and I was floored on how fast that went. Sick! This was one of the best investments I've made for our company. Hope this helps
  6. Stano

    FB3.0 SQL

    Or Five methods converting rows to columns.txt
  7. hsauro

    Skia versus VCL for plotting points

    @angusj I finally got round to looking more seriously Image32, and it's working well so far. In fact, I think I use this instead of GDI+ in the future. Plus as you mentioned earlier it's cross-platform.
  8. Yes: https://github.com/DelphiWorlds/Kastri/tree/master/Demos/AssetDelivery
  9. Alexander Elagin

    SudokuHelper - Example for uncoupled design via interfaces

    Does not compile in 10.1 because of inline variables. What was the reason to use the cosmetic feature only available in the latest versions?
  10. I also use mutex (event in my case)+findwindow approach as the simplest solution but named pipes seem more advanced (didn't implemented them yet though) - Same system- or user-wide unique named object - Communication included for activating 1st instance with any data - More reliable than Findwindow - Suits for console apps, services - Likely x-platform (at least for Linux)
  11. PierreC

    Unable to instantiate the library twice

    I just discovered a post that details the same problem. It seems that multiple loading is not supported by P4D or rather by the python library. Sorry for the inconvenience. https://github.com/pyscripter/python4delphi/issues/287
  12. Attila Kovacs

    Delphi on Windows 11 on MacBook Pro 16 (2021)

    I did something similar the other day, installed Win11 into a HyperV container + Delphi 11 Trial with Android SDK, connected my phone via WLAN debug to the system, added a button to the form, F9 and voila, app is running on the phone. Brilliant. It's just slow AF as I'm on my old notebook 😉
  13. okoca

    Custom ListBox Layout in fmx

    for listbox or listview, every time you scroll, OnApplyItemStyleLookup is triggered, when this event is triggered, for example, does the item in the listbox appear (can user see this listbox item), You need to check the visible area, that is, the listbox will take its height, the listbox will take the position of the item and the listbox will update the number of items that fit inside the height the style information and other item information that will appear on the screen, for example update listboxitem.image or listboxitem.text/rectangle/button. Don't do this to all items, your app will start to freeze while scrolling, if you do this as i say, OnApplyItemStyleLookup It will not constantly update the same items that appear on the screen in every scroll, otherwise even if you slide the scroll by 1 pixel, it will always be triggered. Procedure TfCountrySelection.ListBox_CountryList_OnApplyItemStyleLookup(Sender: TObject); Var ListBoxItem:TListBoxItem; FlagStream:TMemoryStream; UlkeKodu:String; Flag:TObject; Begin Try ListBoxItem:=TListBoxItem(Sender); UlkeKodu:=ListBoxItem.StylesData['country_code'].AsString; if Length(UlkeKodu)>0 then Begin if (Flags.GetCountryFlagStream(Trim(UlkeKodu), FlagStream)=True) then Begin Try Flag:=ListBoxItem.FindStyleResource('Flag'); if (Flag<>Nil) And (Flag is TRectangle) then Begin TRectangle(Flag).Fill.Bitmap.Bitmap.LoadFromStream(FlagStream); End; Finally FlagStream.Free; End; End; End; Except On E:Exception Do Begin fDebug.AddExceptionLog('Exception! | '+Self.Name+'.ListBox_CountryList_OnApplyItemStyleLookup -> '+E.Message); End; End; End;
  14. Serge_G

    Custom ListBox Layout in fmx

    I had this problem long time ago but don't remember how I manage it! Indeed, a test with D10 reproduces this behavior (I only had to change a few lines of your program, and use default style removing default, renaming windows 7 to blank -> default). If you read French (google trad can be a friend), I wrote a tutorial long time ago (https://delphi.developpez.com/tutoriels/firemonkey/intro-styles-firemonkey-xe4/). Ideas : Try yo use standard stylenames i.e. txt,icon (especially this one) mystyle : here icon and text can be accessed via ListboxItem.StylesData['txt']:='Data hello'; ListBoxItem.ItemData.Bitmap.LoadFromFile('D:\XE8\icons8-planète-terre-48.png'); As you can see, stile using findstyleresource coding it works better (only speedbutton hidden) but if you code (here, I test my new style) ListboxItem.StylesData['button.text']:='Data btn'; ListboxItem.StylesData['speedbtn.text']:='speed btn'; instead of sequence // Itembtn := ListBoxItem.FindStyleResource('button') as TSpeedButton; // if Assigned(Itembtn) then // Itembtn.Text := 'Btn Hello!'; the whole stuff works as expected. Nowadays, I use more often Listview (dynamic appearance) than ListBox, Writing this other tutorial, I bang another time in this "empty object problem" I override also playing with link (disabling/enabling) and not only with the BeginUpdate/EndUpdate. However I never tested with the new versions to find out if this potential bug had been fixed.
  15. pyscripter

    GExperts 1.3.19 Alpha 2 for Delphi 11 Patch 2

    An alternative to the method Žarko Gajić described is the following code: function ScaleImageList(Source: TCustomImageList; M, D: Integer): TCustomImageList; const ANDbits: array[0..2*16-1] of Byte = ($FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF, $FF,$FF); XORbits: array[0..2*16-1] of Byte = ($00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00, $00,$00); var I: integer; Icon: HIcon; begin Result := TCustomImageList.CreateSize(MulDiv(Source.Width, M, D), MulDiv(Source.Height, M, D)); if M = D then begin Result.Assign(Source); Exit; end; Result.ColorDepth := cd32Bit; Result.DrawingStyle := Source.DrawingStyle; Result.BkColor := Source.BkColor; Result.BlendColor := Source.BlendColor; for I := 0 to Source.Count-1 do begin Icon := ImageList_GetIcon(Source.Handle, I, LR_DEFAULTCOLOR); if Icon = 0 then begin Icon := CreateIcon(hInstance,16,16,1,1,@ANDbits,@XORbits); end; ImageList_AddIcon(Result.Handle, Icon); DestroyIcon(Icon); end; end; It is simpler and I think works better.
  16. dummzeuch

    GExperts 1.3.19 Alpha 2 for Delphi 11 Patch 2

    Fixed the toolbars for all dialogs.
  17. pyscripter

    SynEdit bracket highlight

    Another issue with your code is that since you are using TArray.BinarySearch your bracket array needs to be sorted. But OCSYMBOLS: Array[0..7] Of Char = ('(', ')', '{', '}', '[', ']', '<', '>'); is not.
  18. pyscripter

    SynEdit bracket highlight

    By the way in the code above: a := SynEdit1.RowColToCharIndex(bufcoord); followed by c := SynEdit1.Text[a]; in fact twice, is not efficient. You are better-off just using c := SynEdit1.Lines[bufcoord.Line][bufcoord.Char]
  19. Hallo everyone, has anyone tried the official "DelphiLSP" Plugin for Visual Studio Code (https://marketplace.visualstudio.com/items?itemName=EmbarcaderoTechnologies.delphilsp) yet? Some time ago I have used OmniPascal (http://blog.omnipascal.com/) by Christopher Wosinski and the code completion has already worked better than in Delphi IDE. So I have hope in the official "DelphiLSP", so that I can use Visual Studio Code instead of the Delphi-IDE at least for "just programming", i.e. no Forms etc. Or does the official plugin has the same "code completion"-issues as in the Delphi IDE ?
  20. Anders Melander

    Skia versus VCL for plotting points

    I just did: TCanvas.Pixels: 320 mS skia4delphi: 130 mS TBitmap.Scanline: 60 mS
  21. David Schwartz

    awk-like processor using Delphi code?

    I've got a situation where I have a bunch of combo-boxes where the user can define conditions for rules that are applied to set attributes on a big grid of "buttons" that are used to display the state of different things. (Sort of like if you had a grid and each row has combo-boxes to select what goes in a cell. But in this case, there's a row of them at the top and data is read / saved from / to a selected row in the grid.) There are a half-dozen combo-boxes, a few edits (for literals), and a couple of check-boxes for options. The user selects the factors he wants for a rule, then saves it to the grid. (Actually, I'm using a ListView in this case.) This is a "rule editor". At "run-time", we get some data in and it gets processed by going through each row in the list and applying all of the rules to set how each button looks. There's one record per button. I created an interpreter that loads up groups of rules and processes them for each record. Given that Delphi doesn't support the use of strings as discrimanents in Case statements, what do folks do to deal with this? I've seen a dozen or so approaches over time. But in this case, I'm looking for a solution that's best suited for rapidly going through a list of rules for each incoming record. It's sort of like a table-driven parser in that respect. You need to have a map to get from the list of strings to associated integers, then use the integer values in the Case statement. In my first approach, I made the mistake of tying everything to the UI components. They're used to create and edit the rules. But when processing the data, loading each rule into the UI elements is completely unnecessary since the user isn't interested, and there's really nothing to see. I want them to simply click a button and a form pops up with a grid and all of the buttons have what they want displayed on them. The nice thing about using the combo-boxes is that you can use the ItemIndex property instead of the string in the Text property. That is, the mapping is built-in. Ideally, what I'd like is something like the syntax that the awk language offers, which sort of like a Case statement where you get a string and it falls-through a list of regular expressions. Each one that matches runs a block of code next to it. Maybe there's an interesting way of compensating for the inability to use strings with Case statements that I'm not aware of. Right now I've just got a bunch of Case statements that use a stringlist to map strings to integers. But if I change the list, I have to re-number the lines in the Case statement. Grrrrr (Yes, I know it's best to add things at the end, but I'd prefer to have things either sorted alphabetically or organized in semi-related sub-groups. I don't like having the damn programming language impose restrictions on how things appear to users!) As I think about it, what might be best is something that lets me add items to a list with a string (key) and an anonymous method that does something when that key is found, corresponding to what a string-based Case statement might do, or even what awk lines do (just more verbose).
  22. Lars Fosdal

    awk-like processor using Delphi code?

    Dictionary and anonymous methods. Link the method to the keyword. Look up via the keyword and execute the code.
  23. Uwe Raabe

    Hot Reload in Delphi?

    The current debugger lets you simply drag the execution pointer to a line before or after the current position:
  24. Joseph MItzen

    What it's like to be a Delphi Developer

    "and RAD Studio is the only tool I have found that actually makes the overall development experience extremely pleasurable. It has everything you need... well thought out, and highly customizable." I'd hate to see what he's comparing it to. Last weekend I was using a JetBrains IDE on Linux. I started creating a constant to hold a Linux path; it was really long, the file system is case-sensitive and I was trying to recall the path from memory. Somehow the Jetbrains IDE recognized that the string I was typing was a directory path and its code completion suddenly switched to offering suggestions to complete the file path. Now instead of almost certainly screwing up the path I was able to get the whole thing entered with just a few keystrokes. My jaw dropped open for a few seconds after the IDE pulled this trick on me. This came on top of discovering when I wanted to suppress a compiler warning that you can turn off warnings on a line-by-line basis for certain warnings or all of them. And this is done by specially-crafted comments so you don't even have to access a menu or use a special key combination to do it. I find it hard to imagine that RAD Studio, which still doesn't have code completion and compiler warnings sorted out after several years, and doesn't even allow key binding customization, is the only IDE that would be bearable to Joe Hecht.
×