Dart Documentationbox2dDebugDraw

DebugDraw abstract class

abstract class DebugDraw {
 // TODO(gregbglw): Draw joints once have them implemented. Also draw other
 // neat stuff described below.

 /// draw shapes
 static const int e_shapeBit = 0x0001;
 /// draw joint connections
 static const int e_jointBit = 0x0002;
 /// draw core (TimeOfImpact) shapes
 static const int e_aabbBit = 0x0004;
 /// draw axis aligned boxes
 static const int e_pairBit = 0x0008;
 /// draw center of mass 
 static const int e_centerOfMassBit = 0x0010;
 /// draw dynamic tree.
 static const int e_dynamicTreeBit = 0x0020;
 /// draw with lines (vs. default filled polygons).
 static const int e_lineDrawingBit = 0x0040;

 int flags;
 ViewportTransform viewportTransform;

 DebugDraw(ViewportTransform viewport)
     : flags = e_shapeBit,
       viewportTransform = viewport;

 void appendFlags(int value) { flags |= value; }
 void clearFlags(int value) { flags &= ~value; }

 /** Draw a closed polygon provided in CCW order. */
 void drawPolygon(List<vec2> vertices, int vertexCount, Color3 color);

 /** Draws the given point with the given radius and color.  */
 void drawPoint(vec2 point, num radiusOnScreen, Color3 color);

 /** Draw a solid closed polygon provided in CCW order. */
 void drawSolidPolygon(List<vec2> vertices, int vertexCount, Color3 color);

 /** Draw a circle. */
 void drawCircle(vec2 center, num radius, Color3 color, [vec2 axis]);

 /** Draw a solid circle. */
 void drawSolidCircle(vec2 center, num radius, Color3 color, [vec2 axis]);

 /** Draw a line segment. */
 void drawSegment(vec2 p1, vec2 p2, Color3 color);

 /** Draw a transform.  Choose your own length scale. */
 void drawTransform(Transform xf, Color3 color);

 /** Draw a string. */
 // TODO(dominich): font.
 void drawString(num x, num y, String s, Color3 color);

 /**
  * Sets the center of the viewport to the given x and y values and the
  * viewport scale to the given scale.
  */
 void setCamera(num x, num y, num scale) {
   viewportTransform.setCamera(x,y,scale);
 }

 /**
  * Screen coordinates are specified in argScreen. These coordinates are
  * converted to World coordinates and placed in the argWorld return vector.
  */
 void getScreenToWorldToOut(vec2 argScreen, vec2 argWorld) {
   viewportTransform.getScreenToWorld(argScreen, argWorld);
 }

 /**
  * World coordinates are specified in argWorld. These coordinates are
  * converted to screen coordinates and placed in the argScreen return vector.
  */
 void getWorldToScreenToOut(vec2 argWorld, vec2 argScreen) {
   viewportTransform.getWorldToScreen(argWorld, argScreen);
 }
}

Subclasses

CanvasDraw

Static Properties

const int e_aabbBit #

draw core (TimeOfImpact) shapes

static const int e_aabbBit = 0x0004

const int e_centerOfMassBit #

draw center of mass

static const int e_centerOfMassBit = 0x0010

const int e_dynamicTreeBit #

draw dynamic tree.

static const int e_dynamicTreeBit = 0x0020

const int e_jointBit #

draw joint connections

static const int e_jointBit = 0x0002

const int e_lineDrawingBit #

draw with lines (vs. default filled polygons).

static const int e_lineDrawingBit = 0x0040

const int e_pairBit #

draw axis aligned boxes

static const int e_pairBit = 0x0008

const int e_shapeBit #

draw shapes

static const int e_shapeBit = 0x0001

Constructors

new DebugDraw(ViewportTransform viewport) #

DebugDraw(ViewportTransform viewport)
   : flags = e_shapeBit,
     viewportTransform = viewport;

Properties

int flags #

int flags

ViewportTransform viewportTransform #

ViewportTransform viewportTransform

Methods

void appendFlags(int value) #

void appendFlags(int value) { flags |= value; }

void clearFlags(int value) #

void clearFlags(int value) { flags &= ~value; }

abstract void drawCircle(vec2 center, num radius, Color3 color, [vec2 axis]) #

Draw a circle.

abstract void drawPoint(vec2 point, num radiusOnScreen, Color3 color) #

Draws the given point with the given radius and color.

abstract void drawPolygon(List<vec2> vertices, int vertexCount, Color3 color) #

Draw a closed polygon provided in CCW order.

abstract void drawSegment(vec2 p1, vec2 p2, Color3 color) #

Draw a line segment.

abstract void drawSolidCircle(vec2 center, num radius, Color3 color, [vec2 axis]) #

Draw a solid circle.

abstract void drawSolidPolygon(List<vec2> vertices, int vertexCount, Color3 color) #

Draw a solid closed polygon provided in CCW order.

abstract void drawString(num x, num y, String s, Color3 color) #

Draw a string.

abstract void drawTransform(Transform xf, Color3 color) #

Draw a transform. Choose your own length scale.

void getScreenToWorldToOut(vec2 argScreen, vec2 argWorld) #

Screen coordinates are specified in argScreen. These coordinates are converted to World coordinates and placed in the argWorld return vector.

void getScreenToWorldToOut(vec2 argScreen, vec2 argWorld) {
 viewportTransform.getScreenToWorld(argScreen, argWorld);
}

void getWorldToScreenToOut(vec2 argWorld, vec2 argScreen) #

World coordinates are specified in argWorld. These coordinates are converted to screen coordinates and placed in the argScreen return vector.

void getWorldToScreenToOut(vec2 argWorld, vec2 argScreen) {
 viewportTransform.getWorldToScreen(argWorld, argScreen);
}

void setCamera(num x, num y, num scale) #

Sets the center of the viewport to the given x and y values and the viewport scale to the given scale.

void setCamera(num x, num y, num scale) {
 viewportTransform.setCamera(x,y,scale);
}