// Copyright © 2015 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
using System.Diagnostics;
namespace CefSharp.Structs
{
///
/// Represents a rectangle
///
[DebuggerDisplay("X = {X}, Y = {Y}, Width = {Width}, Height = {Height}")]
public struct Rect
{
///
/// X coordinate
///
public int X { get; private set; }
///
/// Y coordinate
///
public int Y { get; private set; }
///
/// Width
///
public int Width { get; private set; }
///
/// Height
///
public int Height { get; private set; }
///
/// Rect
///
/// x coordinate
/// y coordinate
/// width
/// height
public Rect(int x, int y, int width, int height)
: this()
{
X = x;
Y = y;
Width = width;
Height = height;
}
///
/// Returns a new Rect with Scaled values
///
/// Dpi to scale by
/// New rect with scaled values
public Rect ScaleByDpi(float dpi)
{
var x = (int)Math.Ceiling(X / dpi);
var y = (int)Math.Ceiling(Y / dpi);
var width = (int)Math.Ceiling(Width / dpi);
var height = (int)Math.Ceiling(Height / dpi);
return new Rect(x, y, width, height);
}
}
}