本文整理匯總了Java中processing.core.PGraphics類的典型用法代碼示例。如果您正苦於以下問題:Java PGraphics類的具體用法?Java PGraphics怎麽用?Java PGraphics使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PGraphics類屬於processing.core包,在下文中一共展示了PGraphics類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showTitle
import processing.core.PGraphics; //導入依賴的package包/類
/** 顯示選中的標記對應的城市名稱 */
public void showTitle(PGraphics pg, float x, float y)
{
String name = getCity() + " " + getCountry() + " ";
String pop = "Pop: " + getPopulation() + " Million";
pg.pushStyle();
pg.fill(255, 255, 255);
pg.textSize(12);
pg.rectMode(PConstants.CORNER);
pg.rect(x, y-TRI_SIZE-39, Math.max(pg.textWidth(name), pg.textWidth(pop)) + 6, 39);
pg.fill(0, 0, 0);
pg.textAlign(PConstants.LEFT, PConstants.TOP);
pg.text(name, x+3, y-TRI_SIZE-33);
pg.text(pop, x+3, y - TRI_SIZE -18);
pg.popStyle();
}
示例2: displayParticles
import processing.core.PGraphics; //導入依賴的package包/類
static public void displayParticles(PGraphics pg, World world) {
int particle_num = world.getParticleCount();
if (particle_num != 0) {
float radius = world.getParticleRadius();
radius *= PARTICLE_RADIUS_SCALE;
Vec2[] particle_pos = world.getParticlePositionBuffer();
pg.beginShape(PConstants.QUADS);
pg.noFill();
pg.noStroke();
pg.textureMode(PConstants.NORMAL);
pg.texture(PARTICLE_SPRITE);
for (int i = 0; i < particle_num; i++) {
Vec2 pos = particle_pos[i];
pg.vertex(pos.x - radius, pos.y - radius, 0, 0);
pg.vertex(pos.x + radius, pos.y - radius, 1, 0);
pg.vertex(pos.x + radius, pos.y + radius, 1, 1);
pg.vertex(pos.x - radius, pos.y + radius, 0, 1);
}
pg.endShape();
}
}
示例3: display
import processing.core.PGraphics; //導入依賴的package包/類
static public void display(PGraphics pg, Body body){
for (Fixture fixture = body.getFixtureList(); fixture != null; fixture = fixture.getNext()) {
display(pg, fixture);
// if (body.isActive() == false) {
// display(pg, fixture);
// } else if (body.getType() == BodyType.STATIC) {
// display(pg, fixture);
// } else if (body.getType() == BodyType.KINEMATIC) {
// display(pg, fixture);
// } else if (body.isAwake() == false) {
// display(pg, fixture);
// } else {
// display(pg, fixture);
// }
}
}
示例4: drawTileLayer
import processing.core.PGraphics; //導入依賴的package包/類
public void drawTileLayer(PGraphics pg, int m){
int n;
float x, y;
PVector p;
Tile tileN;
Layer l = Ptmx.this.layer[m];
int xstart = parent.floor(this.canvasToMap(Ptmx.this.camleft, Ptmx.this.camtop).x - Ptmx.this.drawmargin);
xstart = parent.max(0, xstart - xstart % 2);
int xstop = parent.min(Ptmx.this.mapwidth, parent.ceil(this.canvasToMap(Ptmx.this.camleft + pg.width, Ptmx.this.camtop + pg.height).x + Ptmx.this.drawmargin));
int ystart = parent.max(0, parent.floor(this.canvasToMap(Ptmx.this.camleft, Ptmx.this.camtop).y - Ptmx.this.drawmargin));
int ystop = parent.min(Ptmx.this.mapheight, parent.ceil(this.canvasToMap(Ptmx.this.camleft + pg.width, Ptmx.this.camtop + pg.height).y + Ptmx.this.drawmargin));
for(int ny = ystart; ny < ystop; ny++) for(int nx = xstart; nx < xstop; nx++){
n = l.data[nx + ny * Ptmx.this.mapwidth] - 1;
if(n >= 0){
tileN = Ptmx.this.tile[n];
p = Ptmx.this.mapToCam(nx, ny);
x = p.x - Ptmx.this.tilewidth / 2 + tileN.offsetx + l.offsetx;
y = p.y - Ptmx.this.tileheight / 2 + tileN.offsety + l.offsety + (Ptmx.this.tileheight - tileN.image.height);;
pg.image(tileN.image, x, y);
}
}
}
示例5: apply
import processing.core.PGraphics; //導入依賴的package包/類
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
List<Object> params = ProcessingUtil.parseParams(stack, 1);
PGraphics pg = (PGraphics) params.get(0);
if ("MODEL".equals(params.get(1))) {
pg.textMode(PGraphics.MODEL);
} else if ("SHAPE".equals(params.get(1))) {
pg.textMode(PGraphics.SHAPE);
} else {
throw new WarpScriptException(getName() + " invalid mode, should be 'MODEL' or 'SHAPE'.");
}
stack.push(pg);
return stack;
}
示例6: apply
import processing.core.PGraphics; //導入依賴的package包/類
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
List<Object> params = ProcessingUtil.parseParams(stack, 1, 3);
PGraphics pg = (PGraphics) params.get(0);
if (2 == params.size()) {
pg.box(((Number) params.get(1)).floatValue());
} else {
pg.box(
((Number) params.get(1)).floatValue(),
((Number) params.get(2)).floatValue(),
((Number) params.get(3)).floatValue()
);
}
stack.push(pg);
return stack;
}
示例7: showTitle
import processing.core.PGraphics; //導入依賴的package包/類
/** Show the title of the earthquake if this marker is selected */
public void showTitle(PGraphics pg, float x, float y)
{
String title = getTitle();
pg.pushStyle();
pg.rectMode(PConstants.CORNER);
pg.stroke(110);
pg.fill(255,255,255);
pg.rect(x, y + 15, pg.textWidth(title) +6, 18, 5);
pg.textAlign(PConstants.LEFT, PConstants.TOP);
pg.fill(0);
pg.text(title, x + 3 , y +18);
pg.popStyle();
}
示例8: apply
import processing.core.PGraphics; //導入依賴的package包/類
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
List<Object> params = ProcessingUtil.parseParams(stack, 2, 3);
PGraphics pg = (PGraphics) params.get(0);
if (pg.is3D() && 4 != params.size()) {
throw new WarpScriptException(getName() + " missing z-coordinate.");
}
if (pg.is3D()) {
pg.point(((Number) params.get(1)).floatValue(), ((Number) params.get(2)).floatValue(), ((Number) params.get(3)).floatValue());
} else {
pg.point(((Number) params.get(1)).floatValue(), ((Number) params.get(2)).floatValue());
}
stack.push(pg);
return stack;
}
示例9: apply
import processing.core.PGraphics; //導入依賴的package包/類
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
List<Object> params = ProcessingUtil.parseParams(stack, 1);
PGraphics pg = (PGraphics) params.get(0);
String mode = params.get(1).toString();
if ("CORNER".equals(mode)) {
pg.rectMode(PGraphics.CORNER);
} else if ("CORNERS".equals(mode)) {
pg.rectMode(PGraphics.CORNERS);
} else if ("RADIUS".equals(mode)) {
pg.rectMode(PGraphics.RADIUS);
} else if ("CENTER".equals(mode)) {
pg.rectMode(PGraphics.CENTER);
} else {
throw new WarpScriptException(getName() + ": invalid mode, should be 'CENTER', 'RADIUS', 'CORNER' or 'CORNERS'.");
}
stack.push(pg);
return stack;
}
示例10: apply
import processing.core.PGraphics; //導入依賴的package包/類
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
List<Object> params = ProcessingUtil.parseParams(stack, 1);
PGraphics pg = (PGraphics) params.get(0);
String mode = params.get(1).toString();
if ("SQUARE".equals(mode)) {
pg.strokeCap(PGraphics.SQUARE);
} else if ("PROJECT".equals(mode)) {
pg.strokeCap(PGraphics.PROJECT);
} else if ("ROUND".equals(mode)) {
pg.strokeCap(PGraphics.ROUND);
} else {
throw new WarpScriptException(getName() + ": invalid mode, should be 'SQUARE', 'PROJECT' or 'ROUND'.");
}
stack.push(pg);
return stack;
}
示例11: apply
import processing.core.PGraphics; //導入依賴的package包/類
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
List<Object> params = ProcessingUtil.parseParams(stack, 5);
PGraphics pg = (PGraphics) params.get(0);
float f = pg.bezierTangent(
((Number) params.get(1)).floatValue(),
((Number) params.get(2)).floatValue(),
((Number) params.get(3)).floatValue(),
((Number) params.get(4)).floatValue(),
((Number) params.get(5)).floatValue()
);
stack.push(pg);
stack.push((double) f);
return stack;
}
示例12: apply
import processing.core.PGraphics; //導入依賴的package包/類
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
List<Object> params = ProcessingUtil.parseParams(stack, 3);
PGraphics pg = (PGraphics) params.get(0);
if (params.get(3) instanceof PImage) {
pg.set(
((Number) params.get(1)).intValue(),
((Number) params.get(2)).intValue(),
(PImage) params.get(3)
);
} else {
pg.set(
((Number) params.get(1)).intValue(),
((Number) params.get(2)).intValue(),
((Number) params.get(3)).intValue()
);
}
stack.push(pg);
return stack;
}
示例13: apply
import processing.core.PGraphics; //導入依賴的package包/類
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
List<Object> params = ProcessingUtil.parseParams(stack, 5);
PGraphics pg = (PGraphics) params.get(0);
float f = pg.bezierPoint(
((Number) params.get(1)).floatValue(),
((Number) params.get(2)).floatValue(),
((Number) params.get(3)).floatValue(),
((Number) params.get(4)).floatValue(),
((Number) params.get(5)).floatValue()
);
stack.push(pg);
stack.push((double) f);
return stack;
}
示例14: createShape
import processing.core.PGraphics; //導入依賴的package包/類
private PShape createShape(PGraphics pg){
PShape shp = pg.createShape(PConstants.GROUP);
PShape[] shp_grid = new PShape[6];
for(int i = 0; i < shp_grid.length; i++){
shp_grid[i] = pg.createShape();
shp.addChild(shp_grid[i]);
}
shp_grid[0].setName("gridXYp");
shp_grid[1].setName("gridXYn");
shp_grid[2].setName("gridYZp");
shp_grid[3].setName("gridYZn");
shp_grid[4].setName("gridXZp");
shp_grid[5].setName("gridXZn");
displayGridXY(shp_grid[0], normals[0], 0 , texture_XYp);
if(nodes_z > 1) displayGridXY(shp_grid[1], normals[1], nodes_z-1, texture_XYn);
displayGridYZ(shp_grid[2], normals[2], 0 , texture_YZp);
if(nodes_x > 1) displayGridYZ(shp_grid[3], normals[3], nodes_x-1, texture_YZn);
displayGridXZ(shp_grid[4], normals[4], 0 , texture_XZp);
if(nodes_y > 1) displayGridXZ(shp_grid[5], normals[5], nodes_y-1, texture_XZn);
return shp;
}
示例15: apply
import processing.core.PGraphics; //導入依賴的package包/類
@Override
public Object apply(WarpScriptStack stack) throws WarpScriptException {
List<Object> params = ProcessingUtil.parseParams(stack, 8);
PGraphics pg = (PGraphics) params.get(0);
pg.quad(
((Number) params.get(1)).floatValue(),
((Number) params.get(2)).floatValue(),
((Number) params.get(3)).floatValue(),
((Number) params.get(4)).floatValue(),
((Number) params.get(5)).floatValue(),
((Number) params.get(6)).floatValue(),
((Number) params.get(7)).floatValue(),
((Number) params.get(8)).floatValue()
);
stack.push(pg);
return stack;
}