Hui Wang
Hui Wang

Reputation: 1973

Canvas Comment/Document in Dart SDK

Is it possible to have an explicit explanation of what the following code does rather than showing only a meaningless reference.

Please note this piece of code is taken from the dart:html package (html_dartium.dart) where defines the class CanvasRenderingContext2D.

/// @domName CanvasRenderingContext2D
class CanvasRenderingContext2D extends CanvasRenderingContext {
  CanvasRenderingContext2D.internal(): super.internal();


  /** @domName CanvasRenderingContext2D.fillStyle */
  dynamic get fillStyle native "CanvasRenderingContext2D_fillStyle_Getter";

  ...

Upvotes: 1

Views: 130

Answers (1)

Shailen Tuli
Shailen Tuli

Reputation: 14161

The fillStyle getter uses native code. Hence the somewhat cryptic code there. To find out more about native code in Dart, I would recommend this article:

http://www.dartlang.org/articles/native-extensions-for-standalone-dart-vm/

Here's an excerpt:

The Dart library defines classes and top-level functions as usual, but declares that
some of these functions are implemented in native code, using the native keyword. The
native library is a shared library, written in C or C++, that contains the 
implementations of those functions.

Dart hasn't changed the Canvas api, so you can read about that api and get a good idea of what the code is doing. Here is a good place to start:

https://developer.mozilla.org/en-US/docs/HTML/Canvas/Drawing_Graphics_with_Canvas

If you have a more general complain about lack of explicit documentation (especially where native code is used), you can always file a bug.

Upvotes: 1

Related Questions