本文整理汇总了C#中CGRect.Intersect方法的典型用法代码示例。如果您正苦于以下问题:C# CGRect.Intersect方法的具体用法?C# CGRect.Intersect怎么用?C# CGRect.Intersect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGRect
的用法示例。
在下文中一共展示了CGRect.Intersect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawRect
public void DrawRect(CGRect aRect, bool selected)
{
NSGraphics.RectClip (aRect);
aRect.Intersect (Frame);
Color.Set ();
NSGraphics.RectFill (aRect);
if (selected) {
NSColor.Black.Set ();
NSGraphics.FrameRectWithWidth (Frame, 4.0f);
}
if (IsLocked){
float xSize = (Frame.Width > 10.0f) ? 5.0f : 3.0f;
NSBezierPath path = new NSBezierPath ();
NSColor.Black.Set ();
path.LineWidth = 3.0f;
path.MoveTo (new CGPoint (MidX (Frame) - xSize, MidY (Frame) - xSize));
path.LineTo (new CGPoint (MidX (Frame) + xSize, MidY (Frame) + xSize));
path.MoveTo (new CGPoint (MidX (Frame) - xSize, MidY (Frame) + xSize));
path.LineTo (new CGPoint (MidX (Frame) + xSize, MidY (Frame) - xSize));
path.Stroke ();
}
}
示例2: Draw
public override void Draw(CGRect rect)
{
using (var context = UIGraphics.GetCurrentContext ()) {
// get the scale from the context by getting the current transform matrix, then asking for
// its "a" component, which is one of the two scale components. We could also ask for "d".
// This assumes (safely) that the view is being scaled equally in both dimensions.
var scale = context.GetCTM ().xx;
CATiledLayer tiledLayer = (CATiledLayer)this.Layer;
var tileSize = tiledLayer.TileSize;
// Even at scales lower than 100%, we are drawing into a rect in the coordinate system of the full
// image. One tile at 50% covers the width (in original image coordinates) of two tiles at 100%.
// So at 50% we need to stretch our tiles to double the width and height; at 25% we need to stretch
// them to quadruple the width and height; and so on.
// (Note that this means that we are drawing very blurry images as the scale gets low. At 12.5%,
// our lowest scale, we are stretching about 6 small tiles to fill the entire original image area.
// But this is okay, because the big blurry image we're drawing here will be scaled way down before
// it is displayed.)
tileSize.Width /= scale;
tileSize.Height /= scale;
// calculate the rows and columns of tiles that intersect the rect we have been asked to draw
int firstCol = (int)Math.Floor (rect.GetMinX () / tileSize.Width);
int lastCol = (int)Math.Floor ((rect.GetMaxX () - 1) / tileSize.Width);
int firstRow = (int)Math.Floor (rect.GetMinY () / tileSize.Height);
int lastRow = (int)Math.Floor ((rect.GetMaxY () - 1) / tileSize.Height);
for (int row = firstRow; row <= lastRow; row++) {
for (int col = firstCol; col <= lastCol; col++) {
UIImage tile = TileForScale ((float)scale, row, col);
var tileRect = new CGRect (tileSize.Width * col, tileSize.Height * row, tileSize.Width, tileSize.Height);
// if the tile would stick outside of our bounds, we need to truncate it so as to avoid
// stretching out the partial tiles at the right and bottom edges
tileRect.Intersect (this.Bounds);
tile.Draw (tileRect);
}
}
}
}