public void DrawSegment(cpVect from, cpVect to, float radius, cpColor color) { base.DrawSegment(from.ToCCPoint(), to.ToCCPoint(), radius, color.ToCCColor4F()); }
public void Draw(cpBB bb, cpColor color) { DrawPolygon(new cpVect[] { new cpVect(bb.r, bb.b), new cpVect(bb.r, bb.t), new cpVect(bb.l, bb.t), new cpVect(bb.l, bb.b) }, 4, TRANSPARENT_COLOR, 1, color); }
public void DrawCircle(cpVect center, float radius, float angle, int segments, cpColor color) { base.DrawCircle(center.ToCCPoint(), radius, angle, segments, color.ToCCColor4B()); }
public void DrawPolygon(cpVect[] verts, int count, cpColor fillColor, float borderWidth, cpColor borderColor) { base.DrawPolygon(cpVertArray2ccpArrayN(verts, verts.Length), count, fillColor.ToCCColor4F(), borderWidth, borderColor.ToCCColor4F()); }
public cpColor(cpColor color) { r = color.r; g = color.g; b = color.b; a = color.a; }
public void DrawCircle(cpVect center, float radius, cpColor color) { var centerPoint = center.ToCCPoint(); var colorOutline = color.ToCCColor4B(); var colorFill = colorOutline * 0.5f; base.DrawCircle(centerPoint, radius, colorOutline); base.DrawSolidCircle(centerPoint, radius, colorFill); }
private void Draw(cpSegmentShape seg, cpColor color) { DrawFatSegment(seg.ta, seg.tb, seg.r, color); }
public void DrawSolidCircle(cpVect center, float radius, cpColor color) { base.DrawCircle(center.ToCCPoint(), radius, color.ToCCColor4B()); }
public void DrawRect(CCRect rect, cpColor color) { base.DrawRect(rect, color.ToCCColor4B()); }
public void DrawDot(cpVect pos, float radius, cpColor color) { //base.DrawDot(pos.ToCCPoint(), radius, color.ToCCColor4F()); base.DrawSolidCircle(pos.ToCCPoint(), radius, color.ToCCColor4B()); }
public void Draw(cpVect point, cpColor color) { Draw(point, 0.5f, color); }
public void Draw(cpVect point, float radius, cpColor color) { DrawDot(point, radius, color); }
public void Set(cpColor color) { Set(color.r, color.g, color.b, color.a); }
public void DrawShape(cpShape shape) { cpBody body = shape.body; cpColor color = cp.GetShapeColor(shape);; // ColorForBody(body); switch (shape.shapeType) { case cpShapeType.Circle: { cpCircleShape circle = (cpCircleShape)shape; if (Flags.HasFlag(PhysicsDrawFlags.BB) || Flags.HasFlag(PhysicsDrawFlags.All)) { Draw(circle.bb); } if (Flags.HasFlag(PhysicsDrawFlags.Shapes) || Flags.HasFlag(PhysicsDrawFlags.All)) { Draw(circle, color); } } break; case cpShapeType.Segment: { cpSegmentShape seg = (cpSegmentShape)shape; if (Flags.HasFlag(PhysicsDrawFlags.BB) || Flags.HasFlag(PhysicsDrawFlags.All)) { Draw(seg.bb); } if (Flags.HasFlag(PhysicsDrawFlags.Shapes) || Flags.HasFlag(PhysicsDrawFlags.All)) { Draw(seg, color); } } break; case cpShapeType.Polygon: { cpPolyShape poly = (cpPolyShape)shape; if (Flags.HasFlag(PhysicsDrawFlags.BB) || Flags.HasFlag(PhysicsDrawFlags.All)) { Draw(poly.bb); } if (Flags.HasFlag(PhysicsDrawFlags.Shapes) || Flags.HasFlag(PhysicsDrawFlags.All)) { Draw(poly, color); } } break; default: cp.AssertHard(false, "Bad assertion in DrawShape()"); break; } }
public void DrawSpring(cpVect a, cpVect b, cpColor cpColor) { DrawDot(a, 5, CONSTRAINT_COLOR); DrawDot(b, 5, CONSTRAINT_COLOR); cpVect delta = cpVect.cpvsub(b, a); float cos = delta.x; float sin = delta.y; float s = 1.0f / cpVect.cpvlength(delta); cpVect r1 = cpVect.cpv(cos, -sin * s); cpVect r2 = cpVect.cpv(sin, cos * s); cpVect[] verts = new cpVect[springPoints.Length]; for (int i = 0; i < springPoints.Length; i++) { cpVect v = springPoints[i]; verts[i] = new cpVect(cpVect.cpvdot(v, r1) + a.x, cpVect.cpvdot(v, r2) + a.y); } for (int i = 0; i < springPoints.Length - 1; i++) { DrawSegment(verts[i], verts[i + 1], 1, cpColor.Grey); } }
public abstract void DrawBB(cpBB bb, cpColor color);
public abstract void DrawPoint(cpVect p, float size, cpColor color);
/// Draw a line segment. public abstract void DrawSegment(cpVect p1, cpVect p2, cpColor color);
/// Draw a line segment with a strokeWidth. public abstract void DrawSegment(cpVect p1, cpVect p2, float lineWidth, cpColor color);
public void Draw(cpPolyShape poly, cpColor color) { cpColor fill = new cpColor(color); fill.a = cp.cpflerp(color.a, 1.0f, 0.5f); DrawPolygon(poly.GetVertices(), poly.Count, fill, 0.5f, color); }
/// Draw a solid circle. public abstract void DrawSolidCircle(cpVect center, float radius, cpVect axis, cpColor color);
public void Draw(cpCircleShape circle, cpColor color) { cpVect center = circle.tc; float radius = circle.r; cpVect To = cpVect.cpvadd(cpVect.cpvmult(circle.body.GetRotation(), circle.r), (circle.tc)); DrawCircle(center, cp.cpfmax(radius, 1.0f), color); DrawSegment(center, To, 0.5f, cpColor.Grey); }
/// Draw a solid closed polygon provided in CCW order. public abstract void DrawSolidPolygon(cpVect[] vertices, int vertexCount, cpColor color);
private void DrawFatSegment(cpVect ta, cpVect tb, float r, cpColor color) { cpColor fill = new cpColor(color); fill.a = cp.cpflerp(color.a, 1.0f, 0.5f); DrawSegment(ta, tb, Math.Max(0.05f, r), fill); }
public abstract void DrawSpring(cpVect a, cpVect b, cpColor cpColor);
public static CCColor4B ToCCColor4B(this cpColor color) { return(new CCColor4B(color.r / 255, color.g / 255, color.b / 255, color.a / 255)); }