本文整理汇总了Java中processing.core.PShape.setFill方法的典型用法代码示例。如果您正苦于以下问题:Java PShape.setFill方法的具体用法?Java PShape.setFill怎么用?Java PShape.setFill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类processing.core.PShape
的用法示例。
在下文中一共展示了PShape.setFill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createShape
import processing.core.PShape; //导入方法依赖的package包/类
private PShape createShape(PApplet papplet, float radius, boolean icosahedron){
PShape shape;
if(!icosahedron){
shape = papplet.createShape(PConstants.POINT, 0, 0);
shape.setStroke(true);
shape.setStrokeWeight(1);
} else {
if(ifs == null){
ifs = new DwIcosahedron(1);
// ifs = new DwCube(1);
}
shape = papplet.createShape(PShape.GEOMETRY);
shape.setStroke(false);
shape.setFill(true);
DwMeshUtils.createPolyhedronShape(shape, ifs, radius, 3, true);
}
return shape;
}
示例2: setStyle
import processing.core.PShape; //导入方法依赖的package包/类
public PShape setStyle(PShape shp
, boolean fill_enabled
, int fill_color
, boolean stroke_enabled
, int stroke_color
, float stroke_weight
){
if(shp == null) return null;
shp.setFill (fill_enabled);
shp.setFill (fill_color);
shp.setStroke (stroke_enabled);
shp.setStroke (stroke_color);
shp.setStrokeWeight(stroke_weight / transform.screen_scale);
return shp;
}
示例3: addShape
import processing.core.PShape; //导入方法依赖的package包/类
void addShape(MyPoissonSample sample){
PShape shp_point = createShape(POINT, sample.x(), sample.y(), sample.z());
shp_point.setStroke(color(255));
shp_point.setStrokeWeight(3);
shp_samples_points.addChild(shp_point);
if(ifs == null){
ifs = new DwIcosahedron(2); verts_per_face = 3;
// ifs = new DwCube(2); verts_per_face = 4;
}
PShape shp_sphere = createShape(PShape.GEOMETRY);
shp_sphere.setStroke(false);
shp_sphere.setFill(color(255));
shp_sphere.resetMatrix();
shp_sphere.translate(sample.x(), sample.y(), sample.z());
DwMeshUtils.createPolyhedronShape(shp_sphere, ifs, sample.rad(), verts_per_face, true);
shp_samples_spheres.addChild(shp_sphere);
// PShape shp_sphere_normals = createShape(PShape.GEOMETRY);
// shp_sphere_normals.setStroke(false);
// shp_sphere_normals.setFill(color(255));
// shp_sphere_normals.resetMatrix();
// shp_sphere_normals.translate(sample.x(), sample.y(), sample.z());
//
// DwMeshUtils.createPolyhedronShapeNormals(shp_sphere_normals, ifs, sample.rad(), 10);
//
// shp_samples_spheres.addChild(shp_sphere_normals);
}
示例4: addShape
import processing.core.PShape; //导入方法依赖的package包/类
void addShape(MyPoissonSample sample){
PShape shp_point = createShape(POINT, sample.x(), sample.y(), sample.z());
shp_point.setStroke(color(255));
shp_point.setStrokeWeight(3);
shp_samples_points.addChild(shp_point);
if(ifs == null){
ifs = new DwIcosahedron(2); verts_per_face = 3;
// ifs = new DwCube(3); verts_per_face = 4;
}
PShape shp_sphere = createShape(PShape.GEOMETRY);
shp_sphere.setStroke(false);
shp_sphere.setFill(color(255));
colorMode(HSB, 360, 1, 1);
float hsb_h = 15 + (float)(Math.random() - 0.5f) * 45 ;
float hsb_s = (float) Math.random() * 0.99f + 0.01f;
float hsb_b = hsb_s*3;
shp_sphere.setFill(color(hsb_h, hsb_s, hsb_b));
colorMode(RGB);
shp_sphere.resetMatrix();
shp_sphere.translate(sample.x(), sample.y(), sample.z());
boolean flat_shading = random(1) > 0.5f;
DwMeshUtils.createPolyhedronShape(shp_sphere, ifs, sample.rad(), verts_per_face, flat_shading);
shp_samples_spheres.addChild(shp_sphere);
}
示例5: toggleDisplayWireFrame
import processing.core.PShape; //导入方法依赖的package包/类
public void toggleDisplayWireFrame(){
DISPLAY_WIREFRAME = !DISPLAY_WIREFRAME;
for (BObject body : physics.rigidBodies) {
PShape shp = body.displayShape;
String name = shp.getName();
if(name != null && name.contains("[wire]")){
shp.setFill(!DISPLAY_WIREFRAME);
shp.setStroke(DISPLAY_WIREFRAME);
}
}
skylight.reset();
}
示例6: createShapeWireframe
import processing.core.PShape; //导入方法依赖的package包/类
@Override
public void createShapeWireframe(PGraphics pg, DwStrokeStyle style){
PShape shp = pg.createShape();
displayGridXY(shp, texture_XYp);
shp.setTexture(null);
shp.setFill(false);
shp.setStroke(true);
shp.setStroke(style.stroke_color);
shp.setStrokeWeight(style.stroke_weight);
setShapeWireframe(pg.parent, shp);
}
示例7: createShapeWireframe
import processing.core.PShape; //导入方法依赖的package包/类
@Override
public void createShapeWireframe(PGraphics pg, DwStrokeStyle style){
PShape shp = createShape(pg);
shp.setTexture(null);
shp.setFill(false);
shp.setStroke(true);
shp.setStroke(style.stroke_color);
shp.setStrokeWeight(style.stroke_weight);
setShapeWireframe(pg.parent, shp);
}
示例8: createScene
import processing.core.PShape; //导入方法依赖的package包/类
public void createScene(){
int scale = 10;
int src_w = pg_src.width;
int src_h = pg_src.height;
int num_x = src_w/scale;
int num_y = src_h/scale;
pg_src_small = (PGraphics2D) createGraphics(num_x, num_y, P2D);
pg_src_small_tmp = (PGraphics2D) createGraphics(num_x, num_y, P2D);
opticalflow.resize(src_w, src_h);
pg_src_tmp = (PGraphics2D) createGraphics(src_w, src_h, P2D);
tex_vel_small.resize(context, opticalflow.frameCurr.velocity);
tex_vel_small.resize(context, num_x, num_y);
pg_oflow = (PGraphics2D) createGraphics(src_w, src_h, P2D);
group_cubes = createShape(GROUP);
shp_cubes = new PShape[num_x * num_y];
for(int y = 0; y < num_y; y++){
for(int x = 0; x < num_x; x++){
int idx = y * num_x + x;
PShape shp_cube = createShape(BOX, 1, 1, 1);
shp_cube.setStroke(false);
shp_cube.setStroke(color(0));
shp_cube.setFill(true);
shp_cubes[idx] = shp_cube;
group_cubes.addChild(shp_cube);
}
}
}
示例9: createBoxShape
import processing.core.PShape; //导入方法依赖的package包/类
public PShape createBoxShape(Vector3f dim){
PShape shp = createShape(BOX, dim.x, dim.y, dim.z);
shp.setStroke(false);
shp.setFill(true);
shp.setFill(color(16));
shp.setStrokeWeight(1);
shp.setStroke(color(0));
return shp;
}
示例10: createShapeWireframe
import processing.core.PShape; //导入方法依赖的package包/类
@Override
public void createShapeWireframe(PGraphics pg, DwStrokeStyle style){
PShape shp = createShape(pg);
shp.setTexture(null);
shp.setFill(false);
shp.setStroke(true);
shp.setStroke(style.stroke_color);
shp.setStrokeWeight(style.stroke_weight);
setShapeWireframe(pg.parent, shp);
}
示例11: createScene
import processing.core.PShape; //导入方法依赖的package包/类
public void createScene(){
// int res = 4;
num_x = 100;
num_y = 100;
if(group_cubes == null){
group_cubes = createShape(GROUP);
shp_cubes = new PShape[num_x * num_y];
}
float scene_dimx = bounds[3] - bounds[0];
float scene_dimy = bounds[4] - bounds[1];
float scene_dimz = bounds[5] - bounds[2];
float bounds_off = 100;
float dimx = (scene_dimx - bounds_off*2) / num_x;
float dimy = (scene_dimy - bounds_off*2) / num_y;
float dim = min(dimx, dimy);
float tx = -dim * num_x * 0.5f;
float ty = -dim * num_y * 0.5f;
float dims = 1;
for(int y = 0; y < num_y; y++){
for(int x = 0; x < num_x; x++){
int idx = y * num_x + x;
// float dim_z = random(scene_dimz/4, scene_dimz);
float nval = noise(3*x/(float)num_x, 2*y/(float)num_y);
float dim_z = scene_dimz * nval*nval;
PShape shp_cube = createShape(BOX, dim*dims, dim*dims, dim*dims*1);
shp_cube.setStroke(false);
shp_cube.setStroke(color(0));
shp_cube.setFill(true);
shp_cube.setFill(color(255, 255*nval,255*nval*nval));
shp_cube.translate(tx + x * dim, ty + y * dim, dim_z);
group_cubes.addChild(shp_cube);
shp_cubes[idx] = shp_cube;
}
}
// int cubes_dimz = 100;
}
示例12: updateAnim
import processing.core.PShape; //导入方法依赖的package包/类
public void updateAnim(){
float scene_dimx = bounds[3] - bounds[0];
float scene_dimy = bounds[4] - bounds[1];
float scene_dimz = bounds[5] - bounds[2];
float bounds_off = 100;
float dimx = (scene_dimx - bounds_off*2) / num_x;
float dimy = (scene_dimy - bounds_off*2) / num_y;
float dim = min(dimx, dimy);
float tx = -dim * num_x * 0.5f;
float ty = -dim * num_y * 0.5f;
anim_counter += 0.003f;
float anim_frequency = 2;
for(int y = 0; y < num_y; y++){
for(int x = 0; x < num_x; x++){
int idx = y * num_x + x;
PShape shp_cube = shp_cubes[idx];
float nval = noise(anim_counter + anim_frequency*x/(float)num_x, anim_counter + anim_frequency*y/(float)num_y);
float dim_z = scene_dimz * nval * nval;
float rgb_r = 255;
float rgb_g = 255*nval;
float rgb_b = 255*nval*nval;
shp_cube.setFill(color(rgb_r, rgb_g, rgb_b));
shp_cube.resetMatrix();
// shp_cube.rotateY(nval*PI);
// shp_cube.rotateX(nval*PI);
// shp_cube.rotateZ(nval*PI);
shp_cube.translate(tx + x * dim, ty + y * dim, dim_z);
// shp_cube.rotateY(nval*PI/4f);
// shp_cube.rotateX(nval*PI);
// shp_cube.rotateZ(nval*PI);
shp_cube.rotateZ(cos(nval*10));
// shp_cube.rotateY(nval*PI/4f);
// shp_cube.rotateZ(nval*PI);
// shp_cube.rotateX(nval*PI);
// shp_cube.rotateY(nval*PI);
}
}
}
示例13: updateAnim
import processing.core.PShape; //导入方法依赖的package包/类
public void updateAnim(){
if(pg_src_small == null){
return;
}
int num_x = pg_src_small.width;
int num_y = pg_src_small.height;
DwFilter.get(context).gaussblur.apply(pg_src, pg_src, pg_src_tmp, 5);
pg_src_small.beginDraw();
pg_src_small.image(pg_src, 0, 0, num_x, num_y);
pg_src_small.endDraw();
opticalflow.update(pg_src);
DwFilter.get(context).copy.apply(opticalflow.frameCurr.velocity, tex_vel_small);
flow = tex_vel_small.getFloatTextureData(flow);
DwFilter.get(context).gaussblur.apply(pg_src_small, pg_src_small, pg_src_small_tmp, 3);
pg_src_small.loadPixels();
float scene_dimx = bounds[3] - bounds[0];
float scene_dimy = bounds[4] - bounds[1];
float scene_dimz = bounds[5] - bounds[2];
float bounds_off = 100;
float dimx = (scene_dimx - bounds_off*2) / num_x;
float dimy = (scene_dimy - bounds_off*2) / num_y;
float dim = min(dimx, dimy);
float tx = -dim * num_x * 0.5f;
float ty = -dim * num_y * 0.5f;
float tz = 0;
for(int y = 0; y < num_y; y++){
for(int x = 0; x < num_x; x++){
int idx = y * num_x + x;
int rgb = pg_src_small.pixels[idx];
int r = (rgb >> 16) & 0xFF;
int g = (rgb >> 8) & 0xFF;
int b = (rgb >> 0) & 0xFF;
int flow_idx = (num_y - y - 1) * num_x + x;
float flows = 5;
float flowx = flow[flow_idx * 2 + 0] * +flows;
float flowy = flow[flow_idx * 2 + 1] * -flows;
float gray = (r + g + b) / (3f * 255f);
float px = tx + x * dim + flowx;
float py = ty + y * dim + flowy;
float pz = tz + scene_dimz * gray * 0.35f;
PShape cube = shp_cubes[idx];
cube.resetMatrix();
cube.scale(dim);
cube.translate(px, py, pz);
cube.setFill(rgb);
}
}
}
示例14: draw
import processing.core.PShape; //导入方法依赖的package包/类
/**
* Draws the filled section on the screen
*
* @param p the parent Processing applet
* @param color the color to use
*/
public void draw(PApplet p, int color) {
PShape mesh = calculateMesh(p, color);
mesh.setFill(color);
p.shape(mesh);
}
示例15: updateAnim
import processing.core.PShape; //导入方法依赖的package包/类
public void updateAnim(){
if(pg_src_small == null){
createScene();
}
int num_x = pg_src_small.width;
int num_y = pg_src_small.height;
DwFilter.get(context).gaussblur.apply(pg_src, pg_src, pg_src_tmp, 3);
pg_src_small.beginDraw();
pg_src_small.image(pg_src, 0, 0, num_x, num_y);
pg_src_small.endDraw();
opticalflow.update(pg_src);
DwFilter.get(context).copy.apply(opticalflow.frameCurr.velocity, tex_vel_small);
flow = tex_vel_small.getFloatTextureData(flow);
DwFilter.get(context).gaussblur.apply(pg_src_small, pg_src_small, pg_src_small_tmp, 3);
pg_src_small.loadPixels();
float scene_dimx = bounds[3] - bounds[0];
float scene_dimy = bounds[4] - bounds[1];
float scene_dimz = bounds[5] - bounds[2];
float bounds_off = 100;
float dimx = (scene_dimx - bounds_off*2) / num_x;
float dimy = (scene_dimy - bounds_off*2) / num_y;
float dim = min(dimx, dimy);
float tx = -dim * num_x * 0.5f;
float ty = -dim * num_y * 0.5f;
float tz = 10;
for(int y = 0; y < num_y; y++){
for(int x = 0; x < num_x; x++){
int idx = y * num_x + x;
int rgb = pg_src_small.pixels[idx];
int r = (rgb >> 16) & 0xFF;
int g = (rgb >> 8) & 0xFF;
int b = (rgb >> 0) & 0xFF;
int flow_idx = (num_y - y - 1) * num_x + x;
float flows = 3;
float flowx = flow[flow_idx * 2 + 0] * +flows;
float flowy = flow[flow_idx * 2 + 1] * -flows;
float flow_mm = flowx*flowx + flowy*flowy;
float flow_m = (float) Math.pow(flow_mm, 0.5f);
float gray = (r + g + b) / (3f * 255f);
float px = x * dim;
float py = y * dim;
float pz = scene_dimz * gray * 0.25f + +flow_m;
pz = max(pz, 0);
PShape cube = shp_cubes[idx];
cube.resetMatrix();
cube.scale(dim);
cube.translate(tx+px, ty+py, tz+pz);
cube.setFill(rgb);
}
}
}