Skip to content

Commit

Permalink
fix export with negative values, fix svg export preview
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Jun 17, 2022
1 parent af96618 commit fa17230
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy-to-play-store:
runs-on: ubuntu-22.04
# if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/')
defaults:
run:
working-directory: app
Expand Down
7 changes: 4 additions & 3 deletions app/lib/dialogs/image_export.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,17 @@ class _ImageExportDialogState extends State<ImageExportDialog> {
height < 0 ? y + height : y,
);
final currentSize = Size(
(width < 0 ? -width : width).toDouble(),
(height < 0 ? -height : height).toDouble(),
width.abs().toDouble(),
height.abs().toDouble(),
);
var painter = ViewPainter(current.document,
renderBackground: _renderBackground,
cameraViewport: current.cameraViewport.unbake(current.renderers),
transform: CameraTransform(-currentPosition, scale));
painter.paint(canvas, currentSize);
var picture = recorder.endRecording();
var image = await picture.toImage(width, height);
var image = await picture.toImage(
currentSize.width.toInt(), currentSize.height.toInt());
return await image.toByteData(format: ui.ImageByteFormat.png);
}

Expand Down
25 changes: 17 additions & 8 deletions app/lib/dialogs/svg_export.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,28 +86,37 @@ class _SvgExportDialogState extends State<SvgExportDialog> {
height < 0 ? y + height : y,
);
final currentSize = Size(
(width < 0 ? -width : width).toDouble(),
(height < 0 ? -height : height).toDouble(),
width.abs().toDouble(),
height.abs().toDouble(),
);
var painter = ViewPainter(current.document,
renderBackground: _renderBackground,
cameraViewport: current.cameraViewport.unbake(current.renderers),
transform: CameraTransform(-currentPosition, y.toDouble()));
transform: CameraTransform(-currentPosition, 1));
painter.paint(canvas, currentSize);
var picture = recorder.endRecording();
var image = await picture.toImage(width, height);
var image = await picture.toImage(
currentSize.width.toInt(), currentSize.height.toInt());
return await image.toByteData(format: ui.ImageByteFormat.png);
}

Future<void> _exportSvg() async {
final bloc = context.read<DocumentBloc>();
final state = bloc.state;
if (state is! DocumentLoadSuccess) return;
final currentPosition = Offset(
width < 0 ? x + width : x,
height < 0 ? y + height : y,
);
final currentSize = Size(
width.abs().toDouble(),
height.abs().toDouble(),
);
final data = state.renderSVG(
width: width,
height: height,
x: x,
y: y,
width: currentSize.width.toInt(),
height: currentSize.height.toInt(),
x: currentPosition.dx,
y: currentPosition.dy,
renderBackground: _renderBackground,
);
if (!mounted) return;
Expand Down
3 changes: 2 additions & 1 deletion fastlane/metadata/android/en-US/changelogs/27.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
* Add quality slider to pdf ([#184](https://github.com/LinwoodCloud/Butterfly/issues/184))
* Add copy to change document path ([#180](https://github.com/LinwoodCloud/Butterfly/issues/180))
* Add theme preview
* Fix negative values for exporting svgs and pngs
* Fix negative values for exporting svgs and pngs
* Fix svg export preview

0 comments on commit fa17230

Please sign in to comment.