java shape用法_Java PShape.scale方法代码示例
发布日期:2021-06-24 13:19:28 浏览次数:3 分类:技术文章

本文共 1709 字,大约阅读时间需要 5 分钟。

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);

}

}

}

转载地址:https://blog.csdn.net/weixin_33093437/article/details/114885159 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:java字符串三目_java字符串连接运算符和三目运算符
下一篇:java reduce.mdn_reduce高级用法

发表评论

最新留言

逛到本站,mark一下
[***.202.152.39]2024年04月13日 13时19分55秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章