本文整理汇总了Java中processing.core.PShape.scale方法的典型用法代码示例。如果您正苦于以下问题:Java PShape.scale方法的具体用法?Java PShape.scale怎么用?Java PShape.scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类processing.core.PShape
的用法示例。
在下文中一共展示了PShape.scale方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateLineShape
import processing.core.PShape; //导入方法依赖的package包/类
protected void updateLineShape(PShape shp, Vec2 p0, Vec2 p1){
Vec2 AB = p1.sub(p0);
// https://github.com/processing/processing/blob/master/core/src/processing/opengl/PShapeOpenGL.java#L1348
float ab_len = AB.length() + 0.0000001f;
shp.resetMatrix();
shp.scale(ab_len, 1);
shp.rotate((float) Math.atan2(AB.y, AB.x));
shp.translate(p0.x, p0.y);
}
示例2: updateSpheres
import processing.core.PShape; //导入方法依赖的package包/类
public void updateSpheres(){
PShape[] shp_spheres = shp_samples_spheres.getChildren();
for(int i = 0; i < shp_spheres.length; i++){
PShape shp_sphere = shp_spheres[i];
MyPoissonSample sample = pds.samples.get(i);
sample.updateAnimation();
shp_sphere.resetMatrix();
shp_sphere.scale(sample.anim_rad);
shp_sphere.translate(sample.x(), sample.y(), sample.z());
}
}
示例3: 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);
}
}
}
示例4: 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);
}
}
}