cairodart 0.2.2

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 3

CairoDart

The goal of this project is to provide Dart language bindings for Cairo 2D graphics library (http://cairographics.org/).<br> Current binding supports Cairo v1.12.

Building

First of all you should install Cairo library on your machine.<br> For installation details see (http://cairographics.org/download/)

CairoDart provides API around native library, so the "glue" code should be compiled before start working with CairoDart.

QMake is used for building native part of cairodart, so it should be installed prior to building.

Also environment variable DART_SDK should be set to location of installed Dart SDK.

$ cd native
$ qmake
$ make

Starting unit tests

First start

$ pub get

from the root of the project tree.

To start unit tests run following command:

$ dart test/all_test.dart

Examples

You can find examples in example directory of the project.

Here is an example of CairoDart script that generates several 2D shapes:

library cairodart.example;

import 'dart:io';
import 'dart:math';

import 'package:cairodart/cairodart.dart';

main() {
  Directory dir = Directory.systemTemp.createTempSync('cairodart');

  var filePath = 'example${Platform.pathSeparator}filled_shapes.png';

  File file = new File(filePath);
  file.createSync();

  Surface surface = new ImageSurface(Format.ARGB32, 400, 200);
  Context ctx = new Context(surface);

  ctx.lineWidth = 1.0;

  // Red circle
  ctx..translate(150, 100)
     ..setSourceRgb(0, 0, 0)
     ..arc(0, 0, 50, 0, 2 * PI)
     ..strokePreserve()
     ..setSourceRgba(1, 0, 0, 0.7)
     ..fill();

  // Green circle
  ctx..translate(50, 0)
    ..setSourceRgb(0, 0, 0)
    ..arc(0, 0, 50, 0, 2 * PI)
    ..strokePreserve()
    ..setSourceRgba(0, 1, 0, 0.7)
    ..fill();

  // Blue circle
  ctx..translate(-25, 50)
    ..setSourceRgb(0, 0, 0)
    ..arc(0, 0, 50, 0, 2 * PI)
    ..strokePreserve()
    ..setSourceRgba(0, 0, 1, 0.7)
    ..fill();

  // Save to png file
  surface.writeTo(filePath);

}

Now a little example with transparency:

library cairodart.example;

import 'dart:io';

import 'package:cairodart/cairodart.dart';

main() {
  Directory dir = Directory.systemTemp.createTempSync('cairodart');

  var filePath = 'example/${Platform.pathSeparator}transparency.png';

  File file = new File(filePath);
  file.createSync();

  Surface surface = new ImageSurface(Format.ARGB32, 350, 350);
  Context ctx = new Context(surface);

  ctx.translate(10, 175);

  for (int i = 0; i < 10; i++) {
    ctx.translate(25, 0);
    var rect = new Rectangle(0, -10, 20, 20);
    ctx.rectangle(rect);
    ctx.setSourceRgba(0, 1, 0, 0.1 * i);
    ctx.fill();
  }

  // Save to png file
  surface.writeTo(filePath);
}

Not implemented features

The first version of CairoDart provides binaries for Linux only. Binries for Windows and Mac OS will be available in future versions.

The first version of CairoDart does not provide bindings for the following features:

  • Xlib Surfaces
  • Win32 Surfaces
  • XCB Surfaces
  • Quartz Surfaces
  • XLib-XRender Backend
  • Quartz (CGFont) Fonts
  • Win32 Fonts
  • FreeType Fonts

All these features are expected to be implemented in future versions.

Bugs

If you find a bug please register new issue with bug description, code example and version of library.<br> But before you do this please check if this bug is already registered.

Contribution

Help is much appreciated!<br> Before submitting pull request please ensure that you changes does not brake old unit tests and covered by new.

v0.1.0

Implemented features for drawing on PNG,PDF,SVG and PostScript surfaces.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  cairodart: ^0.2.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:cairodart/cairodart.dart';
  
Version Uploaded Documentation Archive
0.2.2 Aug 30, 2016 Go to the documentation of cairodart 0.2.2 Download cairodart 0.2.2 archive
0.2.1 Aug 24, 2016 Go to the documentation of cairodart 0.2.1 Download cairodart 0.2.1 archive
0.2.0 Aug 24, 2016 Go to the documentation of cairodart 0.2.0 Download cairodart 0.2.0 archive
0.1.0 Aug 11, 2015 Go to the documentation of cairodart 0.1.0 Download cairodart 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
6
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
3
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: unsure

Low code quality prevents platform classification.

Health issues and suggestions

Fix lib/src/pattern.dart. (-44.31 points)

Analysis of lib/src/pattern.dart failed with 2 errors, 2 hints:

line 49 col 3: Invalid override. The type of 'Pattern.==' ('(Pattern) → bool') isn't a subtype of 'Object.==' ('(dynamic) → bool').

line 378 col 3: Invalid override. The type of '_Pattern.==' ('(Pattern) → bool') isn't a subtype of 'Object.==' ('(dynamic) → bool').

line 49 col 11: Always override hashCode if overriding ==.

line 378 col 11: Always override hashCode if overriding ==.

Fix lib/src/surface.dart. (-44.31 points)

Analysis of lib/src/surface.dart failed with 2 errors, 2 hints:

line 116 col 3: Invalid override. The type of 'Surface.==' ('(Surface) → bool') isn't a subtype of 'Object.==' ('(dynamic) → bool').

line 382 col 3: Invalid override. The type of '_Surface.==' ('(Surface) → bool') isn't a subtype of 'Object.==' ('(dynamic) → bool').

line 116 col 11: Always override hashCode if overriding ==.

line 382 col 11: Always override hashCode if overriding ==.

Fix lib/src/font_extents.dart. (-25.75 points)

Analysis of lib/src/font_extents.dart failed with 1 error, 2 hints:

line 80 col 3: Invalid override. The type of '_FontExtents.==' ('(FontExtents) → bool') isn't a subtype of 'Object.==' ('(dynamic) → bool').

line 70 col 7: The class '_FontExtents' isn't used.

line 80 col 11: Always override hashCode if overriding ==.

Fix additional 48 files with analysis or formatting issues. (-916.05 points)

Additional issues in the following files:

  • lib/src/text_extents.dart (1 error, 2 hints)
  • lib/src/antialias.dart (1 error, 1 hint)
  • lib/src/cairoexception.dart (1 error, 1 hint)
  • lib/src/color.dart (1 error, 1 hint)
  • lib/src/content.dart (1 error, 1 hint)
  • lib/src/context.dart (1 error, 1 hint)
  • lib/src/dash.dart (1 error, 1 hint)
  • lib/src/device_type.dart (1 error, 1 hint)
  • lib/src/distance.dart (1 error, 1 hint)
  • lib/src/extend.dart (1 error, 1 hint)
  • lib/src/fill_rule.dart (1 error, 1 hint)
  • lib/src/filter.dart (1 error, 1 hint)
  • lib/src/font_options.dart (1 error, 1 hint)
  • lib/src/font_slant.dart (1 error, 1 hint)
  • lib/src/font_type.dart (1 error, 1 hint)
  • lib/src/font_weight.dart (1 error, 1 hint)
  • lib/src/glyph.dart (1 error, 1 hint)
  • lib/src/hint_metrics.dart (1 error, 1 hint)
  • lib/src/hint_style.dart (1 error, 1 hint)
  • lib/src/line_cap.dart (1 error, 1 hint)
  • lib/src/line_join.dart (1 error, 1 hint)
  • lib/src/matrix.dart (1 error, 1 hint)
  • lib/src/operator.dart (1 error, 1 hint)
  • lib/src/path_element_type.dart (1 error, 1 hint)
  • lib/src/pattern_type.dart (1 error, 1 hint)
  • lib/src/pdf_version.dart (1 error, 1 hint)
  • lib/src/point.dart (1 error, 1 hint)
  • lib/src/postscript_level.dart (1 error, 1 hint)
  • lib/src/rectangle.dart (1 error, 1 hint)
  • lib/src/region.dart (1 error, 1 hint)
  • lib/src/region_overlap.dart (1 error, 1 hint)
  • lib/src/subpixel_order.dart (1 error, 1 hint)
  • lib/src/surface_type.dart (1 error, 1 hint)
  • lib/src/svg_version.dart (1 error, 1 hint)
  • lib/src/text_cluster.dart (1 error, 1 hint)
  • lib/src/text_cluster_flags.dart (1 error, 1 hint)
  • lib/src/format.dart (1 hint)
  • lib/src/glyphs.dart (1 hint)
  • lib/src/path_element.dart (1 hint)
  • lib/src/rectangle_list.dart (1 hint)
  • lib/src/circle.dart (Run dartfmt to format lib/src/circle.dart.)
  • lib/src/color_stop.dart (Run dartfmt to format lib/src/color_stop.dart.)
  • lib/src/device.dart (Run dartfmt to format lib/src/device.dart.)
  • lib/src/font_face.dart (Run dartfmt to format lib/src/font_face.dart.)
  • lib/src/path.dart (Run dartfmt to format lib/src/path.dart.)
  • lib/src/ref_object.dart (Run dartfmt to format lib/src/ref_object.dart.)
  • lib/src/resolution.dart (Run dartfmt to format lib/src/resolution.dart.)
  • lib/src/scaled_font.dart (Run dartfmt to format lib/src/scaled_font.dart.)

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Low code quality prevents platform classification.

Package is too old. (-100 points)

The package was released more than two years ago.

Add SDK constraint in pubspec.yaml. (-5 points)

For information about setting SDK constraint, please see https://www.dartlang.org/tools/pub/pubspec#sdk-constraints.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example.

None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use cairodart.dart.

Dependencies

Package Constraint Resolved Available
Dev dependencies
test any