public static RelativeRect fromSize(Rect rect, Size container) { return(new RelativeRect( rect.left, rect.top, container.width - rect.right, container.height - rect.bottom)); }
public abstract Widget buildToolbar( BuildContext context, Rect globalEditableRegion, float textLineHeight, Offset position, List <TextSelectionPoint> endpoints, TextSelectionDelegate selectionDelegate );
public override Path getOuterPath(Rect rect, TextDirection?textDirection = null) { Radius radius = Radius.circular(rect.shortestSide / 2.0f); var path = new Path(); path.addRRect(RRect.fromRectAndRadius(rect, radius)); return(path); }
RRect _outerRectAt(Offset origin, float t) { float inset = 1.0f - (t - 0.5f).abs() * 2.0f; float size = CheckboxUtils._kEdgeSize - inset * CheckboxUtils._kStrokeWidth; Rect rect = Rect.fromLTWH(origin.dx + inset, origin.dy + inset, size, size); return(RRect.fromRectAndRadius(rect, CheckboxUtils._kEdgeRadius)); }
public override void paint(Canvas canvas, Rect rect, TextDirection?textDirection = null) { foreach (ShapeBorder border in borders) { border.paint(canvas, rect, textDirection); rect = border.dimensions.resolve(textDirection).deflateRect(rect); } }
public Rect toSize(Size container) { return(Rect.fromLTRB( this.left, this.top, container.width - this.right, container.height - this.bottom)); }
BorderRadius _adjustBorderRadius(Rect rect) { return(BorderRadius.lerp( borderRadius, BorderRadius.all(Radius.circular(rect.shortestSide / 2.0f)), 1.0f - rectness )); }
public Rect toRect(Rect container) { return(Rect.fromLTRB( this.left + container.left, this.top + container.top, container.right - this.right, container.bottom - this.bottom)); }
public Rect toSize(Size container) { return(Rect.fromLTRB( left, top, container.width - right, container.height - bottom)); }
public override Path getInnerPath(Rect rect) { Path path = new Path(); path.addRect(Rect.fromLTWH(rect.left, rect.top, rect.width, Mathf.Max(0.0f, rect.height - this.borderSide.width))); return(path); }
public override void paint(Canvas canvas, Rect rect) { foreach (ShapeBorder border in this.borders) { border.paint(canvas, rect); rect = border.dimensions.deflateRect(rect); } }
public Rect getLocalRectForCaret(TextPosition caretPosition) { this._layoutText(this.constraints.maxWidth); var caretOffset = this._textPainter.getOffsetForCaret(caretPosition, this._caretPrototype); return(Rect.fromLTWH(0.0f, 0.0f, _kCaretWidth, this.preferredLineHeight) .shift(caretOffset + this._paintOffset)); }
public override Widget buildTransitions(BuildContext context1, Animation <float> animation, Animation <float> secondaryAnimation, Widget child) { return(new OrientationBuilder( builder: (BuildContext context2, Orientation orientation) => { _lastOrientation = orientation; if (!animation.isCompleted) { bool reverse = animation.status == AnimationStatus.reverse; Rect rect = reverse ? _rectAnimatableReverse.evaluate(animation) : _rectAnimatable.evaluate(animation); Rect sheetRect = reverse ? _sheetRectAnimatableReverse.evaluate(animation) : _sheetRectAnimatable.evaluate(animation); float?sheetScale = reverse ? _sheetScaleAnimatableReverse.evaluate(animation) : _sheetScaleAnimatable.evaluate(animation); List <Widget> widgets = new List <Widget>(); widgets.Add( Positioned.fromRect( rect: sheetRect, child: new Opacity( opacity: _sheetOpacity.value, child: Transform.scale( alignment: getSheetAlignment(_contextMenuLocation), scale: sheetScale ?? 1.0f, child: new _ContextMenuSheet( key: _sheetGlobalKey, actions: _actions, contextMenuLocation: _contextMenuLocation, orientation: orientation ) ) ) ) ); widgets.Add( Positioned.fromRect( key: _childGlobalKey, rect: rect, child: _builder(context2, animation) )); return new Stack( children: widgets ); } return new _ContextMenuRouteStatic( actions: _actions, child: _builder(context1, animation), childGlobalKey: _childGlobalKey, contextMenuLocation: _contextMenuLocation, onDismiss: _onDismiss, orientation: orientation, sheetGlobalKey: _sheetGlobalKey ); } )); }
public override PaintShader createShader(Rect rect) { return(ui.Gradient.linear( this.begin.withinRect(rect), this.end.withinRect(rect), this.colors, this._impliedStops(), this.tileMode )); }
public override Path getOuterPath(Rect host, Rect guest) { if (!host.overlaps(guest)) { Path path = new Path(); path.addRect(host); return(path); } float notchRadius = guest.width / 2.0f; const float s1 = 15.0f; const float s2 = 1.0f; float r = notchRadius; float a = -1.0f * r - s2; float b = host.top - guest.center.dy; float n2 = Mathf.Sqrt(b * b * r * r * (a * a + b * b - r * r)); float p2xA = ((a * r * r) - n2) / (a * a + b * b); float p2xB = ((a * r * r) + n2) / (a * a + b * b); float p2yA = Mathf.Sqrt(r * r - p2xA * p2xA); float p2yB = Mathf.Sqrt(r * r - p2xB * p2xB); List <Offset> p = new List <Offset>(6); p[0] = new Offset(a - s1, b); p[1] = new Offset(a, b); float cmp = b < 0 ? -1.0f : 1.0f; p[2] = cmp * p2yA > cmp * p2yB ? new Offset(p2xA, p2yA) : new Offset(p2xB, p2yB); p[3] = new Offset(-1.0f * p[2].dx, p[2].dy); p[4] = new Offset(-1.0f * p[1].dx, p[1].dy); p[5] = new Offset(-1.0f * p[0].dx, p[0].dy); for (int i = 0; i < p.Count; i += 1) { p[i] += guest.center; } Path ret = new Path(); ret.moveTo(host.left, host.top); ret.lineTo(p[0].dx, p[0].dy); ret.quadraticBezierTo(p[1].dx, p[1].dy, p[2].dx, p[2].dy); // TODO: replace this lineTo() with arcToPoint when arcToPoint is ready ret.lineTo(p[3].dx, p[3].dy); // ret.arcToPoint(p[3], p[3], radius: Radius.circular(notchRadius), clockwise: false); ret.quadraticBezierTo(p[4].dx, p[4].dy, p[5].dx, p[5].dy); ret.lineTo(host.right, host.top); ret.lineTo(host.right, host.bottom); ret.lineTo(host.left, host.bottom); ret.close(); return(ret); }
public static Rect fromCenter(Offset center, float width, float height) { return(Rect.fromLTRB( center.dx - width / 2, center.dy - height / 2, center.dx + width / 2, center.dy + height / 2 )); }
public override Shader createShader(Rect rect, TextDirection?textDirection = null) { return(ui.Gradient.sweep( center.resolve(textDirection).withinRect(rect), colors, _impliedStops(), tileMode, startAngle, endAngle, _resolveTransform(rect, textDirection) )); }
public override Shader createShader(Rect rect, TextDirection?textDirection = null) { return(ui.Gradient.linear( begin.resolve(textDirection).withinRect(rect), end.resolve(textDirection).withinRect(rect), colors, _impliedStops(), tileMode, _resolveTransform(rect, textDirection) )); }
public override Path getInnerPath(Rect rect) { for (int index = 0; index < this.borders.Count - 1; index += 1) { rect = this.borders[index].dimensions.deflateRect(rect); } return(this.borders.Last().getInnerPath(rect)); }
public override PaintShader createShader(Rect rect) { return(ui.Gradient.radial( this.center.withinRect(rect), this.radius * rect.shortestSide, this.colors, this._impliedStops(), this.tileMode )); }
public override PaintShader createShader(Rect rect) { return(ui.Gradient.sweep( this.center.withinRect(rect), this.colors, this._impliedStops(), this.tileMode, this.startAngle, this.endAngle )); }
public override void performLayout(Size size) { float columnCardX = size.width / 5.0f; float columnCardWidth = size.width - columnCardX; float columnCardHeight = size.height / this.cardCount; float rowCardWidth = size.width; Offset offset = this.translation.alongSize(size); float columnCardY = 0.0f; float rowCardX = -(this.selectedIndex * rowCardWidth); float columnTitleX = size.width / 10.0f; float rowTitleWidth = size.width * ((1 + this.tCollapsed) / 2.25f); float rowTitleX = (size.width - rowTitleWidth) / 2.0f - this.selectedIndex * rowTitleWidth; const float paddedSectionIndicatorWidth = AnimationWidgetsUtils.kSectionIndicatorWidth + 8.0f; float rowIndicatorWidth = paddedSectionIndicatorWidth + (1.0f - this.tCollapsed) * (rowTitleWidth - paddedSectionIndicatorWidth); float rowIndicatorX = (size.width - rowIndicatorWidth) / 2.0f - this.selectedIndex * rowIndicatorWidth; for (int index = 0; index < this.cardCount; index++) { Rect columnCardRect = Rect.fromLTWH(columnCardX, columnCardY, columnCardWidth, columnCardHeight); Rect rowCardRect = Rect.fromLTWH(rowCardX, 0.0f, rowCardWidth, size.height); Rect cardRect = this._interpolateRect(columnCardRect, rowCardRect).shift(offset); string cardId = $"card{index}"; if (this.hasChild(cardId)) { this.layoutChild(cardId, BoxConstraints.tight(cardRect.size)); this.positionChild(cardId, cardRect.topLeft); } Size titleSize = this.layoutChild($"title{index}", BoxConstraints.loose(cardRect.size)); float columnTitleY = columnCardRect.centerLeft.dy - titleSize.height / 2.0f; float rowTitleY = rowCardRect.centerLeft.dy - titleSize.height / 2.0f; float centeredRowTitleX = rowTitleX + (rowTitleWidth - titleSize.width) / 2.0f; Offset columnTitleOrigin = new Offset(columnTitleX, columnTitleY); Offset rowTitleOrigin = new Offset(centeredRowTitleX, rowTitleY); Offset titleOrigin = this._interpolatePoint(columnTitleOrigin, rowTitleOrigin); this.positionChild($"title{index}", titleOrigin + offset); Size indicatorSize = this.layoutChild($"indicator{index}", BoxConstraints.loose(cardRect.size)); float columnIndicatorX = cardRect.centerRight.dx - indicatorSize.width - 16.0f; float columnIndicatorY = cardRect.bottomRight.dy - indicatorSize.height - 16.0f; Offset columnIndicatorOrigin = new Offset(columnIndicatorX, columnIndicatorY); Rect titleRect = Rect.fromPoints(titleOrigin, titleSize.bottomRight(titleOrigin)); float centeredRowIndicatorX = rowIndicatorX + (rowIndicatorWidth - indicatorSize.width) / 2.0f; float rowIndicatorY = titleRect.bottomCenter.dy + 16.0f; Offset rowIndicatorOrigin = new Offset(centeredRowIndicatorX, rowIndicatorY); Offset indicatorOrigin = this._interpolatePoint(columnIndicatorOrigin, rowIndicatorOrigin); this.positionChild($"indicator{index}", indicatorOrigin + offset); columnCardY += columnCardHeight; rowCardX += rowCardWidth; rowTitleX += rowTitleWidth; rowIndicatorX += rowIndicatorWidth; } }
void _paintDividerBetweenContentAndActions(Canvas canvas, Offset offset) { canvas.drawRect( Rect.fromLTWH( offset.dx, offset.dy + this.contentSection.size.height, this.size.width, this._dividerThickness ), this._dividerPaint ); }
void _paintShadows(Canvas canvas, Rect rect) { foreach (BoxShadow boxShadow in boxShadows) { Paint paint = boxShadow.toPaint(); canvas.drawRRect( MaterialConstantsUtils.kMaterialEdges[MaterialType.card].toRRect(rect), paint); } }
public _TextSelectionToolbarLayout( Size screenSize, Rect globalEditableRegion, Offset position) { this.screenSize = screenSize; this.globalEditableRegion = globalEditableRegion; this.position = position; }
protected override void debugPaintSize(PaintingContext context, Offset offset) { base.debugPaintSize(context, offset); D.assert(() => { Rect outerRect = offset & size; D.debugPaintPadding(context.canvas, outerRect, child != null ? _resolvedPadding.deflateRect(outerRect) : null); return(true); }); }
public RasterCacheResult(Image image, Rect logicalRect, float devicePixelRatio) { D.assert(image != null); D.assert(logicalRect != null); this.image = image; this.logicalRect = logicalRect; this.devicePixelRatio = devicePixelRatio; }
public static RelativeRect fromRect(Rect rect, Rect container) { return(fromLTRB( rect.left - container.left, rect.top - container.top, container.right - rect.right, container.bottom - rect.bottom )); }
public override Path getInnerPath(Rect rect, TextDirection?textDirection = null) { for (int index = 0; index < borders.Count - 1; index += 1) { rect = borders[index].dimensions.resolve(textDirection).deflateRect(rect); } return(borders.Last().getInnerPath(rect)); }
void _drawFrameCost(Canvas canvas, float x, float y, float width, float height) { Rect visualizationRect = Rect.fromLTWH(x, y, width, height); Paint paint = new Paint { color = Colors.blue }; Paint paint2 = new Paint { color = Colors.red }; Paint paint3 = new Paint { color = Colors.green }; Paint paint4 = new Paint { color = Colors.white70 }; float[] costFrames = PerformanceUtils.instance.getFrames(); int curFrame = PerformanceUtils.instance.getCurFrame(); float barWidth = Mathf.Max(1, width / costFrames.Length); float perHeight = height / 32.0f; canvas.drawRect(visualizationRect, paint4); canvas.drawRect(Rect.fromLTWH(x, y + perHeight * 16.0f, width, 1), paint3); float cur_x = x; Path barPath = new Path(); for (var i = 0; i < costFrames.Length; i++) { if (costFrames[i] != 0) { float curHeight = Mathf.Min(perHeight * costFrames[i], height); Rect barRect = Rect.fromLTWH(cur_x, y + height - curHeight, barWidth, curHeight); barPath.addRect(barRect); } cur_x += barWidth; } canvas.drawPath(barPath, paint); if (curFrame >= 0 && curFrame < costFrames.Length && costFrames[curFrame] != 0) { float curHeight = Mathf.Min(perHeight * costFrames[curFrame], height); Rect barRect = Rect.fromLTWH(x + barWidth * curFrame, y + height - curHeight, barWidth, curHeight); canvas.drawRect(barRect, paint2); var pb = new ParagraphBuilder(new ParagraphStyle { }); pb.addText("Frame Cost: " + costFrames[curFrame] + "ms"); var paragraph = pb.build(); paragraph.layout(new ParagraphConstraints(width: 300)); canvas.drawParagraph(paragraph, new Offset(x, y + height - 12)); } }