Comments (5)
Thank you very much for both examples. Before I could report the misalignment, there was a second, better, solution. Thank you very much.
from skia4delphi.
Hi @Echelon78!
You can use the code:
uses
System.Math.Vectors, Skia;
procedure Hatching(const ACanvas: ISkCanvas);
var
paint: ISkPaint;
lattice: TMatrix;
bounds: TRectF;
begin
paint := TSkPaint.Create;
paint.Color := TAlphaColors.Black;
lattice := TMatrix.CreateRotation(45) * TMatrix.CreateScaling(8, 8);
paint.PathEffect := TSkPathEffect.Make2DLine(1, lattice);
paint.AntiAlias := True;
bounds := TRect.Create(0, 0, 250, 250);
ACanvas.Clear(TAlphaColors.White);
ACanvas.DrawRect(bounds, paint);
end;
from skia4delphi.
This result is a little unexpected, the traces are not aligned with the rect bounds when compared to the fiddle result. Some differences with fiddle can occur because fiddle always uses the newest skia (the current version we use, the m88, is almost 1 year older). I'll be able to investigate this in the future, but for now this difference can easily be worked around by changing the previous code to:
uses
System.Math.Vectors, Skia;
procedure Hatching(const ACanvas: ISkCanvas);
var
paint: ISkPaint;
lattice: TMatrix;
bounds: TRectF;
begin
paint := TSkPaint.Create;
paint.Color := TAlphaColors.Black;
lattice := TMatrix.CreateRotation(45) * TMatrix.CreateScaling(8, 8);
paint.PathEffect := TSkPathEffect.Make2DLine(1, lattice);
paint.AntiAlias := True;
bounds := TRect.Create(0, 0, 250, 250);
ACanvas.Clear(TAlphaColors.White);
ACanvas.Save;
try
ACanvas.ClipRect(bounds);
bounds.Inflate(8,8);
ACanvas.DrawRect(bounds, paint);
finally
ACanvas.Restore;
end;
end;
from skia4delphi.
@Echelon78
Today I was doing other examples and I discovered by chance why our example was not working exactly like fiddle: although there is no documentation, TMatrix.CreateRotation works with radians and not with degree. So just add the DegToRad(, looking like this:
uses
System.Math, System.Math.Vectors, Skia;
procedure Hatching(const ACanvas: ISkCanvas);
var
paint: ISkPaint;
lattice: TMatrix;
bounds: TRectF;
begin
paint := TSkPaint.Create;
paint.Color := TAlphaColors.Black;
lattice := TMatrix.CreateRotation(DegToRad(45)) * TMatrix.CreateScaling(8, 8);
paint.PathEffect := TSkPathEffect.Make2DLine(1, lattice);
paint.AntiAlias := True;
bounds := TRect.Create(0, 0, 250, 250);
ACanvas.Clear(TAlphaColors.White);
ACanvas.Save;
try
ACanvas.ClipRect(bounds);
bounds.Inflate(8,8);
ACanvas.DrawRect(bounds, paint);
finally
ACanvas.Restore;
end;
end;
from skia4delphi.
Added this example in new Demo. :)
from skia4delphi.
Related Issues (20)
- TSkPath.Contains() does not work properly in some situations HOT 1
- Enabling Skia causes other controls to redraw abnormally HOT 2
- MacOS: Exception in libsk4d.dylib in skia::textlayout::TextWrapper::lookAhead
- TSkSVG not displaying SVG file properly HOT 4
- In Delphi 12 IDE crashes when you drag and drop TSkAnimatedPaintbox to Form HOT 1
- ACCESS Violation after adding SKIA to Uses clause HOT 3
- Text extent fails under MacOS(!) HOT 3
- SKIA for Android: GPU SkImage Rendering Failure on TGLCanvas vs. Vulkan HOT 10
- Android Crash on Delphi 11.3 for Transferred Bricks Game Demo Project HOT 2
- Universal MAC Dylib HOT 4
- ISkRuntimeEffect changes from 3.4.0 to 6.0.0 HOT 3
- Request for SkFontMg.matchFamilyStyleCharacter equivalent
- Request for SkTextBlob.bounds eqivalent
- How to enable GPU in VCL? HOT 1
- Getting an indexed color from TSkPaint.Shader.MakeGradientLinear HOT 1
- Crashes Delphi 11.1, skia versão 6.0 HOT 2
- error: program is too large HOT 2
- TSkSvg with an SVG with french special caracters HOT 4
- Japanese fonts are not displayed correctly when Skia is enabled.
- Blackscreen on iPad Pro 11" (3rd Gen) with biggest display zoom, setting "more surface" and GlobalMetal=true HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from skia4delphi.