本文整理汇总了C#中NGraphics.Size类的典型用法代码示例。如果您正苦于以下问题:C# Size类的具体用法?C# Size怎么用?C# Size使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Size类属于NGraphics命名空间,在下文中一共展示了Size类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArcTo
public ArcTo(Size radius, bool largeArc, bool sweepClockwise, Point point)
{
Radius = radius;
LargeArc = largeArc;
SweepClockwise = sweepClockwise;
Point = point;
}
示例2: RadialGradientBrush
public RadialGradientBrush (Point relCenter, Size relRadius, params GradientStop[] stops)
{
Center = relCenter;
Focus = relCenter;
Radius = relRadius;
Stops.AddRange (stops);
}
示例3: WICBitmapCanvas
public WICBitmapCanvas (Size size, double scale = 1.0, bool transparency = true, Direct2DFactories factories = null)
: this (
// DIPs = pixels / (DPI/96.0)
new WIC.Bitmap ((factories ?? Direct2DFactories.Shared).WICFactory, (int)(Math.Ceiling (size.Width * scale)), (int)(Math.Ceiling (size.Height * scale)), transparency ? WIC.PixelFormat.Format32bppPBGRA : WIC.PixelFormat.Format32bppBGR, WIC.BitmapCreateCacheOption.CacheOnLoad),
new D2D1.RenderTargetProperties (D2D1.RenderTargetType.Default, new D2D1.PixelFormat (DXGI.Format.Unknown, D2D1.AlphaMode.Unknown), (float)(96.0 * scale), (float)(96.0 * scale), D2D1.RenderTargetUsage.None, D2D1.FeatureLevel.Level_DEFAULT))
{
}
示例4: ScaleDownProportional
public static Size ScaleDownProportional (this Size size, Size max)
{
if (size.Width <= max.Width && size.Height <= max.Height) {
return size;
}
return size.ScaleProportional (max);
}
示例5: Scale
public static void Scale (this ICanvas canvas, Size scale, Point point)
{
if (scale.Width != 1 || scale.Height != 1) {
canvas.Translate (point);
canvas.Scale (scale);
canvas.Translate (-point);
}
}
示例6: Drawing
public Drawing(Size size, DrawingFunc func)
{
if (func == null) {
throw new ArgumentNullException ("func");
}
this.size = size;
this.func = func;
}
示例7: Drawing
public Drawing (Size size, DrawingFunc func, IPlatform textPlatform)
{
if (func == null) {
throw new ArgumentNullException ("func");
}
this.size = size;
this.func = func;
this.textPlatform = textPlatform ?? new NullPlatform ();
}
示例8: ScaleProportional
public static Size ScaleProportional (this Size size, Size max)
{
double fitScale = size.ScaleThatFits (max);
if (fitScale == 1) {
return size;
}
Size scaledSize = new Size (size.Width * fitScale, size.Height * fitScale);
return scaledSize;
}
示例9: CreateImageCanvas
public IImageCanvas CreateImageCanvas(Size size, double scale = 1.0, bool transparency = true)
{
var pixelWidth = (int)Math.Ceiling (size.Width * scale);
var pixelHeight = (int)Math.Ceiling (size.Height * scale);
var bitmap = Bitmap.CreateBitmap (pixelWidth, pixelHeight, Bitmap.Config.Argb8888);
if (!transparency) {
bitmap.EraseColor (Colors.Black.Argb);
}
return new BitmapCanvas (bitmap, scale);
}
示例10: CreateImageCanvas
public IImageCanvas CreateImageCanvas(Size size, double scale = 1.0, bool transparency = true)
{
var pixelWidth = (int)Math.Ceiling (size.Width * scale);
var pixelHeight = (int)Math.Ceiling (size.Height * scale);
var bitmapInfo = transparency ? CGImageAlphaInfo.PremultipliedFirst : CGImageAlphaInfo.NoneSkipFirst;
var bitsPerComp = 8;
var bytesPerRow = transparency ? 4 * pixelWidth : 4 * pixelWidth;
var colorSpace = CGColorSpace.CreateDeviceRGB ();
var bitmap = new CGBitmapContext (IntPtr.Zero, pixelWidth, pixelHeight, bitsPerComp, bytesPerRow, colorSpace, bitmapInfo);
return new CGBitmapContextCanvas (bitmap, scale);
}
示例11: ScaleThatFits
public static double ScaleThatFits (this Size size, Size max)
{
if (size == max || max.Width == 0 || max.Height == 0 || size.Width == 0 || size.Height == 0) {
return 1;
}
double widthScale = max.Width / size.Width;
double heightScale = max.Height / size.Height;
double fitScale = (double)Math.Min (widthScale, heightScale);
return fitScale;
}
示例12: CreateImage
public static IImage CreateImage(this IPlatform platform, Func<int, int, Color> colorFunc, Size size, double scale = 1.0)
{
var w = (int)Math.Ceiling (size.Width);
var h = (int)Math.Ceiling (size.Height);
var colors = new Color[w * h];
for (var y = 0; y < h; y++) {
var o = y * w;
for (var x = 0; x < w; x++) {
colors [o + x] = colorFunc (x, y);
}
}
return platform.CreateImage (colors, w, scale);
}
示例13: Draw
public override void Draw (CGRect rect)
{
base.Draw (rect);
if (_formsControl != null) {
using (CGContext context = UIGraphics.GetCurrentContext ()) {
context.SetAllowsAntialiasing (true);
context.SetShouldAntialias (true);
context.SetShouldSmoothFonts (true);
var outputSize = new Size (rect.Width, rect.Height);
var finalCanvas = _formsControl.RenderSvgToCanvas (outputSize, ScreenScale, CreatePlatformImageCanvas);
var image = finalCanvas.GetImage ();
var uiImage = image.GetUIImage ();
Control.Image = uiImage;
}
}
}
示例14: Read
void Read (XDocument doc)
{
var svg = doc.Root;
var ns = svg.Name.Namespace;
//
// Find the defs (gradients)
//
foreach (var d in svg.Descendants ()) {
var idA = d.Attribute ("id");
if (idA != null) {
defs [ReadString (idA).Trim ()] = d;
}
}
//
// Get the dimensions
//
var widthA = svg.Attribute ("width");
var heightA = svg.Attribute ("height");
var width = ReadNumber (widthA);
var height = ReadNumber (heightA);
var size = new Size (width, height);
var viewBox = new Rect (size);
var viewBoxA = svg.Attribute ("viewBox") ?? svg.Attribute ("viewPort");
if (viewBoxA != null) {
viewBox = ReadRectangle (viewBoxA.Value);
}
if (widthA != null && widthA.Value.Contains ("%")) {
size.Width *= viewBox.Width;
}
if (heightA != null && heightA.Value.Contains ("%")) {
size.Height *= viewBox.Height;
}
//
// Add the elements
//
Graphic = new Graphic (size, viewBox);
AddElements (Graphic.Children, svg.Elements (), null, Brushes.Black);
}
示例15: ForeignObject
public ForeignObject (Point pos, Size size) : base(null, null)
{
this.pos = pos;
this.size = size;
}