当前位置: 首页>>代码示例>>Java>>正文


Java Color3f类代码示例

本文整理汇总了Java中org.jbox2d.common.Color3f的典型用法代码示例。如果您正苦于以下问题:Java Color3f类的具体用法?Java Color3f怎么用?Java Color3f使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Color3f类属于org.jbox2d.common包,在下文中一共展示了Color3f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: step

import org.jbox2d.common.Color3f; //导入依赖的package包/类
public void step(){
  
  m_angle += 0.25f * PI / 180.0f;

  float radius = 25.0f;
  Vec2 point1 = new Vec2(0.0f, 10.0f);
  Vec2 p1p2 = new Vec2(radius * cos(m_angle), -radius * abs(sin(m_angle)));
  Vec2 point2 = point1.add(p1p2);

  callback.m_fixture = null;
  world.raycast(callback, point1, point2);

  if (callback.m_fixture != null) {
    world.debug_draw.drawPoint(callback.m_point, 5.0f/world.transform.screen_scale, new Color3f(0.4f, 0.9f, 0.4f));
    world.debug_draw.drawSegment(point1, callback.m_point, new Color3f(0.8f, 0.8f, 0.8f));
    Vec2 head = callback.m_normal.mul(.5f).addLocal(callback.m_point);
    world.debug_draw.drawSegment(callback.m_point, head, new Color3f(0.9f, 0.9f, 0.4f));
  } else {
    world.debug_draw.drawSegment(point1, point2, new Color3f(0.8f, 0.8f, 0.8f));
  }

}
 
开发者ID:diwi,项目名称:LiquidFunProcessing,代码行数:23,代码来源:box2d_RayCastEdgeShapes.java

示例2: step

import org.jbox2d.common.Color3f; //导入依赖的package包/类
/**
 * @see org.jbox2d.testbed.framework.TestbedTest#step(org.jbox2d.testbed.framework.TestbedSettings)
 */
@Override
public void step(TestbedSettings settings) {
	super.step(settings);
	
	PolyShapesCallback callback = new PolyShapesCallback(m_world.getPool());
	callback.m_circle.m_radius = 2.0f;
	callback.m_circle.m_p.set(0.0f, 2.1f);
	callback.m_transform.setIdentity();
	callback.debugDraw = m_debugDraw;

	AABB aabb = new AABB();
	callback.m_circle.computeAABB(aabb, callback.m_transform);

	m_world.queryAABB(callback, aabb);

	Color3f color = new Color3f(0.4f, 0.7f, 0.8f);
	m_debugDraw.drawCircle(callback.m_circle.m_p, callback.m_circle.m_radius, color);

	addTextLine("Press 1-5 to drop stuff");
	addTextLine("Press 'a' to (de)activate some bodies");
	addTextLine("Press 'd' to destroy a body");
	addTextLine("Up to 30 bodies in the target circle are highlighted");
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:PolyShapes.java

示例3: drawSolidPolygon

import org.jbox2d.common.Color3f; //导入依赖的package包/类
/**
 * @see org.jbox2d.callbacks.DebugDraw#drawSolidPolygon(org.jbox2d.common.Vec2[], int, org.jbox2d.common.Color3f)
 */
@Override
public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) {

	// inside
	Graphics2D g = getGraphics();		
	int[] xInts = xIntsPool.get(vertexCount);
	int[] yInts = yIntsPool.get(vertexCount);
	
	for(int i=0; i<vertexCount; i++){
		getWorldToScreenToOut(vertices[i], temp);
		xInts[i] = (int)temp.x;
		yInts[i] = (int)temp.y;
	}
	
	Color c = cpool.getColor(color.x, color.y, color.z, .4f);
	g.setColor(c);
	g.fillPolygon(xInts, yInts, vertexCount);
	
	// outside
	drawPolygon(vertices, vertexCount, color);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:DebugDrawJ2D.java

示例4: drawSolidCircle

import org.jbox2d.common.Color3f; //导入依赖的package包/类
@Override
public void drawSolidCircle(Vec2 center, float radius, Vec2 axis,
		Color3f color) {
	Graphics g = container.getGraphics();
	Color c = g.getColor();
	g.setColor(new Color((int) color.x, (int) color.y, (int) color.z));
	Vec2 screenCenter = this.transform.worldToScreen(center);
	float screenRadius = this.transform.scaleFactor * radius;
	// x1, y1 are upper left corner
	float x1 = screenCenter.x - screenRadius;
	float y1 = screenCenter.y - screenRadius;
	// solid outline and
	g.setColor(new Color((int) color.x, (int) color.y, (int) color.z));
	g.drawOval(x1, y1, 2 * screenRadius, 2 * screenRadius);
	g.drawLine(screenCenter.x, screenCenter.y, screenCenter.x
			+ screenRadius * axis.x, screenCenter.y + this.transform.yFlipFactor * screenRadius
			* axis.y);
	// semi-transparent fill
	g.setColor(new Color((int) color.x, (int) color.y, (int) color.z, 63));
	g.fillOval(x1, y1, 2 * screenRadius, 2 * screenRadius);
	g.setColor(c);
}
 
开发者ID:intentor,项目名称:telyn,代码行数:23,代码来源:SlickDebugDraw.java

示例5: drawSolidPolygon

import org.jbox2d.common.Color3f; //导入依赖的package包/类
@Override
public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
	Graphics g = container.getGraphics();
	Color c = g.getColor();
	float[] points = new float[vertexCount * 2];
	for (int i = 0; i < vertexCount; i++) {
		Vec2 screen = this.transform.worldToScreen(vertices[i]);
		points[2 * i] = screen.x;
		points[2 * i + 1] = screen.y;
	}
	org.newdawn.slick.geom.Polygon poly = new org.newdawn.slick.geom.Polygon(
			points);
	// solid outline
	g.setColor(new Color((int) color.x, (int) color.y, (int) color.z));
	g.draw(poly);
	// semi-transparent fill
	g.setColor(new Color((int) color.x, (int) color.y, (int) color.z, 63));
	g.fill(new org.newdawn.slick.geom.Polygon(points));
	g.setColor(c);
}
 
开发者ID:intentor,项目名称:telyn,代码行数:21,代码来源:SlickDebugDraw.java

示例6: drawSolidPolygon

import org.jbox2d.common.Color3f; //导入依赖的package包/类
@Override
public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
  setFillColor(color);
  setStrokeColor(color);
  Path path = canvas.createPath();
  for (int i = 0; i < vertexCount; i++) {
    getWorldToScreenToOut(vertices[i], tempVec1);
    if (i == 0) {
      path.moveTo(tempVec1.x, tempVec1.y);
    } else {
      path.lineTo(tempVec1.x, tempVec1.y);
    }
  }
  path.close();
  canvas.fillPath(path);
  canvas.strokePath(path);
}
 
开发者ID:playn,项目名称:playn,代码行数:18,代码来源:DebugDrawBox2D.java

示例7: drawCircle

import org.jbox2d.common.Color3f; //导入依赖的package包/类
@Override
public void drawCircle(Vec2 center, float radius, Color3f color) {
  if (canvas == null) {
    log().error(CANVASERROR);
    return;
  }

  setFillColor(color);
  setStrokeColor(color);
  // calculate the effective radius
  tempVec1.set(center.x + radius, center.y + radius);
  getWorldToScreenToOut(tempVec1, tempVec1);
  getWorldToScreenToOut(center, tempVec2);
  canvas.canvas().fillCircle(tempVec2.x, tempVec2.y, tempVec1.x - tempVec2.x);
  canvas.canvas().strokeCircle(tempVec2.x, tempVec2.y, tempVec1.x - tempVec2.x);
}
 
开发者ID:fredsa,项目名称:forplay,代码行数:17,代码来源:DebugDrawBox2D.java

示例8: drawSolidCircle

import org.jbox2d.common.Color3f; //导入依赖的package包/类
@Override
public void drawSolidCircle(Vec2 center, float radius, Vec2 axis, Color3f color) {
  if (canvas == null) {
    log().error(CANVASERROR);
    return;
  }

  setFillColor(color);
  setStrokeColor(color);
  // calculate the effective radius
  tempVec1.set(center.x + radius, center.y + radius);
  getWorldToScreenToOut(tempVec1, tempVec1);
  getWorldToScreenToOut(center, tempVec2);
  getWorldToScreenToOut(axis, tempVec3);
  canvas.canvas().fillCircle(tempVec2.x, tempVec2.y, tempVec1.x - tempVec2.x);
  canvas.canvas().strokeCircle(tempVec2.x, tempVec2.y, tempVec1.x - tempVec2.x);
}
 
开发者ID:fredsa,项目名称:forplay,代码行数:18,代码来源:DebugDrawBox2D.java

示例9: drawSolidPolygon

import org.jbox2d.common.Color3f; //导入依赖的package包/类
@Override
public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
  if (canvas == null) {
    log().error(CANVASERROR);
    return;
  }

  setFillColor(color);
  setStrokeColor(color);
  Path path = graphics().createPath();
  for (int i = 0; i < vertexCount; i++) {
    getWorldToScreenToOut(vertices[i], tempVec1);
    if (i == 0) {
      path.moveTo(tempVec1.x, tempVec1.y);
    } else {
      path.lineTo(tempVec1.x, tempVec1.y);
    }
  }
  path.close();
  canvas.canvas().fillPath(path);
  canvas.canvas().strokePath(path);
}
 
开发者ID:fredsa,项目名称:forplay,代码行数:23,代码来源:DebugDrawBox2D.java

示例10: drawCircle

import org.jbox2d.common.Color3f; //导入依赖的package包/类
@Override
public void drawCircle(Vec2 center, float radius, Color3f color) {
    System.err.println("drawCircle: "+center +", "+radius+", "+color);
  GL2 gl = panel.getGL().getGL2();
  gl.glPushMatrix();
  transformViewport(gl, zero);
  float theta = 2 * MathUtils.PI / NUM_CIRCLE_POINTS;
  float c = MathUtils.cos(theta);
  float s = MathUtils.sin(theta);
  float x = radius;
  float y = 0;
  float cx = center.x;
  float cy = center.y;
  gl.glBegin(GL2.GL_LINE_LOOP);
  gl.glColor4f(color.x, color.y, color.z, 1);
  for (int i = 0; i < NUM_CIRCLE_POINTS; i++) {
    gl.glVertex3f(x + cx, y + cy, 0);
    // apply the rotation matrix
    float temp = x;
    x = c * x - s * y;
    y = s * temp + c * y;
  }
  gl.glEnd();
  gl.glPopMatrix();
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:26,代码来源:JoglDebugDraw.java

示例11: step

import org.jbox2d.common.Color3f; //导入依赖的package包/类
/**
 * @see org.jbox2d.testbed.framework.TestbedTest#step(org.jbox2d.testbed.framework.TestbedSettings)
 */
@Override
public void step(TestbedSettings settings) {
  super.step(settings);

  PolyShapesCallback callback = new PolyShapesCallback(getWorld().getPool());
  callback.m_circle.m_radius = 2.0f;
  callback.m_circle.m_p.set(0.0f, 2.1f);
  callback.m_transform.setIdentity();
  callback.debugDraw = getDebugDraw();

  AABB aabb = new AABB();
  callback.m_circle.computeAABB(aabb, callback.m_transform, 0);

  getWorld().queryAABB(callback, aabb);

  Color3f color = new Color3f(0.4f, 0.7f, 0.8f);
  getDebugDraw().drawCircle(callback.m_circle.m_p, callback.m_circle.m_radius, color);

  addTextLine("Press 1-5 to drop stuff");
  addTextLine("Press 'a' to (de)activate some bodies");
  addTextLine("Press 'd' to destroy a body");
  addTextLine("Up to 30 bodies in the target circle are highlighted");
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:27,代码来源:PolyShapes.java

示例12: drawCircle

import org.jbox2d.common.Color3f; //导入依赖的package包/类
@Override
public void drawCircle(Vec2 center, float radius, Vec2 axis, Color3f color) {
  Graphics2D g = getGraphics();
  saveState(g);
  transformGraphics(g, center);
  g.setStroke(stroke);
  Color s = cpool.getColor(color.x, color.y, color.z, 1f);
  g.scale(radius, radius);
  g.setColor(s);
  g.draw(circle);
  g.rotate(MathUtils.atan2(axis.y, axis.x));
  if (axis != null) {
    g.drawLine(0, 0, 1, 0);
  }
  restoreState(g);
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:17,代码来源:DebugDrawJ2D.java

示例13: drawSolidCircle

import org.jbox2d.common.Color3f; //导入依赖的package包/类
@Override
public void drawSolidCircle(Vec2 center, float radius, Vec2 axis, Color3f color) {
  Graphics2D g = getGraphics();
  saveState(g);
  transformGraphics(g, center);
  g.setStroke(stroke);
  Color f = cpool.getColor(color.x, color.y, color.z, .4f);
  Color s = cpool.getColor(color.x, color.y, color.z, 1f);
  g.scale(radius, radius);
  g.setColor(f);
  g.fill(circle);
  g.setColor(s);
  g.draw(circle);
  g.rotate(MathUtils.atan2(axis.y, axis.x));
  if (axis != null) {
    g.drawLine(0, 0, 1, 0);
  }
  restoreState(g);
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:20,代码来源:DebugDrawJ2D.java

示例14: drawSolidPolygon

import org.jbox2d.common.Color3f; //导入依赖的package包/类
@Override
public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
  Color f = cpool.getColor(color.x, color.y, color.z, .4f);
  Color s = cpool.getColor(color.x, color.y, color.z, 1f);
  Graphics2D g = getGraphics();
  saveState(g);
  int[] xInts = xIntsPool.get(vertexCount);
  int[] yInts = yIntsPool.get(vertexCount);
  for (int i = 0; i < vertexCount; i++) {
    getWorldToScreenToOut(vertices[i], temp);
    xInts[i] = (int) temp.x;
    yInts[i] = (int) temp.y;
  }
  g.setStroke(stroke);
  g.setColor(f);
  g.fillPolygon(xInts, yInts, vertexCount);
  g.setColor(s);
  g.drawPolygon(xInts, yInts, vertexCount);
  restoreState(g);
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:21,代码来源:DebugDrawJ2D.java

示例15: drawPolygon

import org.jbox2d.common.Color3f; //导入依赖的package包/类
@Override
public void drawPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
  Color s = cpool.getColor(color.x, color.y, color.z, 1f);
  Graphics2D g = getGraphics();
  saveState(g);
  int[] xInts = xIntsPool.get(vertexCount);
  int[] yInts = yIntsPool.get(vertexCount);
  for (int i = 0; i < vertexCount; i++) {
    getWorldToScreenToOut(vertices[i], temp);
    xInts[i] = (int) temp.x;
    yInts[i] = (int) temp.y;
  }
  g.setStroke(stroke);
  g.setColor(s);
  g.drawPolygon(xInts, yInts, vertexCount);
  restoreState(g);
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:18,代码来源:DebugDrawJ2D.java


注:本文中的org.jbox2d.common.Color3f类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。