Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/painting/Shape.beveled_rectangle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/painting/Shape.circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/painting/Shape.continuous_rectangle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/painting/Shape.continuous_stadium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/painting/Shape.rectangle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/painting/Shape.rounded_rectangle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/painting/Shape.stadium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/diagrams/lib/diagrams.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export 'src/implicit_animations.dart';
export 'src/ink_response_large.dart';
export 'src/ink_response_small.dart';
export 'src/ink_well.dart';
export 'src/shapes.dart';
export 'src/sliver_app_bars.dart';
export 'src/stroke_cap.dart';
export 'src/stroke_join.dart';
Expand Down
138 changes: 138 additions & 0 deletions packages/diagrams/lib/src/shapes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:diagram_capture/diagram_capture.dart';

import 'diagram_step.dart';

class ShapeDiagram extends StatelessWidget implements DiagramMetadata {
const ShapeDiagram({
Key key,
this.name,
this.shapeBorder,
this.width,
this.height
}) : super(key: key);

@override
final String name;
final ShapeBorder shapeBorder;
final double width;
final double height;

@override
Widget build(BuildContext context) {
const double padding = 50.0;
return Container(
height: height + padding,
width: width + padding,
alignment: Alignment.center,
child: Material(
color: Colors.blue,
shape: shapeBorder,
child: SizedBox(
width: width,
height: height,
),
),
);
}
}

class ShapeDiagramStep extends DiagramStep {
ShapeDiagramStep(DiagramController controller) : super(controller) {
const String circleName = 'Shape.circle';
const String rectangleName = 'Shape.rectangle';
const String roundedRectangleName = 'Shape.rounded_rectangle';
const String stadiumName = 'Shape.stadium';
const String continuousRectangleName = 'Shape.continuous_rectangle';
const String continuousStadiumName = 'Shape.continuous_stadium';
const String beveledRectangleName = 'Shape.beveled_rectangle';

const double width = 200.0;
const double height = 200.0;
const double radius = 75.0;

_diagrams.addAll(<ShapeDiagram>[
ShapeDiagram(
name: circleName,
shapeBorder: CircleBorder(),
width: width,
height: height,
key: const ValueKey<String>(circleName),
),
ShapeDiagram(
name: rectangleName,
shapeBorder: RoundedRectangleBorder(),
width: width,
height: height,
key: const ValueKey<String>(rectangleName),
),
ShapeDiagram(
name: roundedRectangleName,
shapeBorder: RoundedRectangleBorder(
borderRadius: const BorderRadius.all(
Radius.circular(radius)
)
),
width: width,
height: height,
key: const ValueKey<String>(roundedRectangleName),
),
ShapeDiagram(
name: stadiumName,
shapeBorder: StadiumBorder(),
width: width,
height: height / 2,
key: const ValueKey<String>(stadiumName),
),
ShapeDiagram(
name: continuousRectangleName,
shapeBorder: ContinuousRectangleBorder(
borderRadius: radius,
),
width: width,
height: height,
key: const ValueKey<String>(continuousRectangleName),
),
ShapeDiagram(
name: continuousStadiumName,
shapeBorder: ContinuousStadiumBorder(),
width: width,
height: height / 2,
key: const ValueKey<String>(continuousStadiumName),
),
ShapeDiagram(
name: beveledRectangleName,
shapeBorder: BeveledRectangleBorder(
borderRadius: const BorderRadius.all(
Radius.circular(radius)
)
),
width: width,
height: height,
key: const ValueKey<String>(beveledRectangleName),
),
]);
}

@override
final String category = 'painting';

final List<ShapeDiagram> _diagrams = <ShapeDiagram>[];

@override
Future<List<DiagramMetadata>> get diagrams async => _diagrams;

@override
Future<File> generateDiagram(DiagramMetadata diagram) async {
final ShapeDiagram typedDiagram = diagram;
controller.builder = (BuildContext context) => typedDiagram;
return await controller.drawDiagramToFile(new File('${diagram.name}.png'));
}
}
1 change: 1 addition & 0 deletions utils/diagram_generator/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Future<Null> main() async {
new InkResponseLargeDiagramStep(controller),
new InkResponseSmallDiagramStep(controller),
new InkWellDiagramStep(controller),
new ShapeDiagramStep(controller),
new SliverAppBarDiagramStep(controller),
new StrokeCapDiagramStep(controller),
new StrokeJoinDiagramStep(controller),
Expand Down