Comments (8)
I agree, i was writing this documentation today, and I found this to be confusing.
from skiasharp.
@migueldeicaza @joreg That is the Create
method. There is a constructor that is LTRB: https://developer.xamarin.com/api/constructor/SkiaSharp.SKRect.SKRect/p/System.Single/System.Single/System.Single/System.Single/
I can't overload the constructor, but I wanted to do that as a helper method in case you are coming from some other rect object. I didn't want to force the user to calculate the LTRB when he had the XYWH coordinates.
from skiasharp.
This is the SKRect definition:
public struct SKRect {
public float Left, Top, Right, Bottom;
public SKRect (float left, float top, float right, float bottom) {
Left = left;
Right = right;
Top = top;
Bottom = bottom;
}
public static SKRect Create (float width, float height) {
return new SKRect (0, 0, width, height);
}
public static SKRect Create (float x, float y, float width, float height) {
return new SKRect (x, y, x + width, y + height);
}
}
https://github.com/mono/SkiaSharp/blob/master/binding/Binding/Definitions.cs#L402-L421
from skiasharp.
I had a look some more at the Skia API and see this:
https://github.com/mono/skia/blob/xamarin-mobile-bindings/include/core/SkRect.h
static SkRect SK_WARN_UNUSED_RESULT MakeWH(SkScalar w, SkScalar h);
static SkRect SK_WARN_UNUSED_RESULT MakeIWH(int w, int h);
static SkRect SK_WARN_UNUSED_RESULT MakeSize(const SkSize& size);
static SkRect SK_WARN_UNUSED_RESULT MakeLTRB(SkScalar l, SkScalar t, SkScalar r, SkScalar b);
static SkRect SK_WARN_UNUSED_RESULT MakeXYWH(SkScalar x, SkScalar y, SkScalar w, SkScalar h);
The SKRect
type does not have a constructor, but rather several overloads of the Make (or Create) methods
I think we need to decide what we want for the constructor. Or even no constructor. I am in favour of XYWH as the constructor and LTRB as the Create as this is what .NET usually does.
from skiasharp.
So we have several options:
- No constructor (just the default)
- XYWH constructor (with CreateLTRB)
- LTRB constructor (with CreateXYWH)
I vote 2.
from skiasharp.
i'd vote for no constructor and all helpers called: From...
- no constructor because then there are not 2 different ways to create a rect
- From.... because FromXYWH, FromLTRB,... reads more suitable than Make.. or Create..
from skiasharp.
I also vote for no constructor to have everything in one place.
The same might be true for other basic shapes as well, for consistency.
from skiasharp.
I do not see an advantage on making the change, so let us keep the code as is for now.
from skiasharp.
Related Issues (20)
- [FEATURE] Support Direct3D HOT 4
- [BUG] `SKNativeObject` instances are not kept alive during native API calls
- [BUG] Annoying warning on .NET Framework 4.8 project with SkiaSharp 2.88.6 or 2.88.7 HOT 17
- [BUG] Text Missing When Running From AWS Lambda HOT 3
- [BUG] SkiaSharp 3.0 Preview 3.1 crashes the release version of the .NET MAUI app at start, debug works fine HOT 9
- [BUG] Drawing is warped during window resize on NVIDIA graphics card
- Canvas Info shows huge size when using Chrome Debugger and using Device Emulation
- [BUG] Build outputs duplicate native libraries HOT 2
- Skia Blazor Runs in debugger but not when deployed
- [BUG] SKGLElement gives black screen on Intel integrated graphics
- [BUG] SKGLView on .NET MAUI is missing a handler (the return) HOT 6
- [BUG] On iOS, with .NET 9.0 Preview 2 and 3 and SkiaSharp 3.0 Preview 2.1 / 3.1, SKGLView corrupts SkiaSharp memory and stops SkiaSharp from functioning HOT 7
- [BUG] The position draw on SKXamCanvas is not correct. #1585 Was this a bug that you worked around? HOT 3
- [PERFORMANCE] On iOS, layout speed of pages with SKGLView is slow, making layout wobbly at start (SKCanvasView is instantaneous)
- [BUG] SkiaSharp 2.88.8 (Xamarin) crashes randomly with Mali GPUs HOT 4
- [BUG] SKPaint's IsAntiAlisasing is on on Android but off on iOS by default (Xamarin / SkiaSharp 2.88.8) HOT 1
- [BUG] SkiaSharp crashes in WebAssembly if building with non-Release/Debug build config HOT 1
- [BUG] Canvas.DrawPath Cause Memory Leak on Windows 11 HOT 1
- [BUG] SKBitmap.ColorSpace is always null. Unable to check for CMYK, RGB, etc. HOT 1
- [BUG] CR2 image orientation being detected incorrectly.
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 skiasharp.