static IEnumerable <Rect> _generateImageTileRects(Rect outputRect, Rect fundamentalRect, ImageRepeat repeat) { int startX = 0; int startY = 0; int stopX = 0; int stopY = 0; float strideX = fundamentalRect.width; float strideY = fundamentalRect.height; if (repeat == ImageRepeat.repeat || repeat == ImageRepeat.repeatX) { startX = ((outputRect.left - fundamentalRect.left) / strideX).floor(); stopX = ((outputRect.right - fundamentalRect.right) / strideX).ceil(); } if (repeat == ImageRepeat.repeat || repeat == ImageRepeat.repeatY) { startY = ((outputRect.top - fundamentalRect.top) / strideY).floor(); stopY = ((outputRect.bottom - fundamentalRect.bottom) / strideY).ceil(); } for (int i = startX; i <= stopX; ++i) { for (int j = startY; j <= stopY; ++j) { yield return(fundamentalRect.shift(new Offset(i * strideX, j * strideY))); } } }
public override RectCallback getRectCallback(RenderBox referenceBox) { return(() => { RenderObject cell = referenceBox; AbstractNodeMixinDiagnosticableTree table = cell.parent; Matrix4 transform = Matrix4.identity(); while (table is RenderObject && !(table is RenderTable)) { RenderObject parentBox = table as RenderObject; parentBox.applyPaintTransform(cell, transform); D.assert(table == cell.parent); cell = parentBox; table = table.parent; } if (table is RenderTable renderTable) { TableCellParentData cellParentData = cell.parentData as TableCellParentData; Rect rect = renderTable.getRowBox(cellParentData.y); // The rect is in the table's coordinate space. We need to change it to the // TableRowInkWell's coordinate space. renderTable.applyPaintTransform(cell, transform); Offset offset = MatrixUtils.getAsTranslation(transform); if (offset != null) { return rect.shift(-offset); } } return Rect.zero; } ); }
void paintBackground(Canvas canvas, PaintRecord record, Offset baseOffset) { if (record.style.background == null) { return; } var metrics = record.metrics; Rect rect = Rect.fromLTRB(0, metrics.ascent, record.runWidth, metrics.descent); rect = rect.shift(record.shiftedOffset(baseOffset)); canvas.drawRect(rect, record.style.background); }
void _paintShadows(Canvas canvas, Rect rect) { if (this._decoration.boxShadow == null) { return; } foreach (BoxShadow boxShadow in this._decoration.boxShadow) { Paint paint = boxShadow.toPaint(); Rect bounds = rect.shift(boxShadow.offset).inflate(boxShadow.spreadRadius); this._paintBox(canvas, bounds, paint); } }
public RevealedOffset getOffsetToReveal(RenderObject target, float alignment, Rect rect = null) { rect = rect ?? target.paintBounds; if (!(target is RenderBox)) { return(new RevealedOffset(offset: this.offset.pixels, rect: rect)); } RenderBox targetBox = (RenderBox)target; Matrix3 transform = targetBox.getTransformTo(this); Rect bounds = transform.mapRect(rect); Size contentSize = this.child.size; float leadingScrollOffset = 0.0f; float targetMainAxisExtent = 0.0f; float mainAxisExtent = 0.0f; switch (this.axisDirection) { case AxisDirection.up: mainAxisExtent = this.size.height; leadingScrollOffset = contentSize.height - bounds.bottom; targetMainAxisExtent = bounds.height; break; case AxisDirection.right: mainAxisExtent = this.size.width; leadingScrollOffset = bounds.left; targetMainAxisExtent = bounds.width; break; case AxisDirection.down: mainAxisExtent = this.size.height; leadingScrollOffset = bounds.top; targetMainAxisExtent = bounds.height; break; case AxisDirection.left: mainAxisExtent = this.size.width; leadingScrollOffset = contentSize.width - bounds.right; targetMainAxisExtent = bounds.width; break; } float targetOffset = leadingScrollOffset - (mainAxisExtent - targetMainAxisExtent) * alignment; Rect targetRect = bounds.shift(this._paintOffsetForPosition(targetOffset)); return(new RevealedOffset(offset: targetOffset, rect: targetRect)); }
void _paintThumb(PaintingContext context, Offset offset, Rect thumbRect) { List <BoxShadow> thumbShadow = new List <BoxShadow> { new BoxShadow( color: new Color(0x1F000000), offset: new Offset(0, 3), blurRadius: 8 ), new BoxShadow( color: new Color(0x0A000000), offset: new Offset(0, 3), blurRadius: 1 ) }; RRect thumbRRect = RRect.fromRectAndRadius(thumbRect.shift(offset), CupertinoSlidingSegmentedControlsUtils._kThumbRadius); foreach (BoxShadow shadow in thumbShadow) { context.canvas.drawRRect(thumbRRect.shift(shadow.offset), shadow.toPaint()); } context.canvas.drawRRect( thumbRRect.inflate(0.5f), new Paint() { color = new Color(0x0A000000) } ); context.canvas.drawRRect( thumbRRect, new Paint() { color = thumbColor } ); }