Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 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. dummzeuch

    GExperts 1.3.19 Alpha 2 for Delphi 11 Patch 2

    Fixed the toolbars for all dialogs.
  3. That code comes from the forin template that comes with newer versions of Delphi. Sorry for the inconvenience, but since I program mostly for my own use i'm not much concerned with compatibilty with older Delphi versions and simply did not notice this as a potential problem.
  4. 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.
  5. 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]
  6. Yes: https://github.com/DelphiWorlds/Kastri/tree/master/Demos/AssetDelivery
  7. 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).
  8. 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.
×