请教如下图片怎样用grasshopper或其他软件生成是否有编程算法上的实现方式
在此抛砖引玉,基本思路和 @jane lia 说的差不多,实现使用 Processing (JAVA), 效果不是特别理想,欢迎大家改进。PS. 我觉得算法上跟图案的角度有关,说不定我们能借用一点 Neural Network 的 convolution 思想。
原始图片(致敬扎哈):
【请教如下图片怎样用grasshopper或其他软件生成是否有编程算法上的实现方式】 
效果:

代码://constantsPImage img; float imgBrightness;float circlePoints;int numPoints = 150;int segment = 2;float linesToDraw = new float;//this method is a little hacky, code from https://forum.processing.org/beta/num_1276644884.htmlpublic PVector getDistance( float x1, float y1, float x2, float y2, float x, float y ){ PVector result = new PVector(); float dx = x2 - x1; float dy = y2 - y1; float d = sqrt( dx*dx + dy*dy ); float ca = dx/d; // cosine float sa = dy/d; // sine float mX = (-x1+x)*ca + (-y1+y)*sa; if( mX \u0026lt;= 0 ){ result.x = x1; result.y = y1; } else if( mX \u0026gt;= d ){ result.x = x2; result.y = y2; } else{ result.x = x1 + mX*ca; result.y = y1 + mX*sa; } dx = x - result.x; dy = y - result.y; result.z = sqrt( dx*dx + dy*dy ); return result; }public float imageBrigthness(PImage img, int height, int width, int segment) { img.filter(GRAY); img.loadPixels(); float bright; int n = floor(height / segment); int m = floor(width / segment); bright = new float; for (int y = 0; y \u0026lt; n; y++ ) { for (int x = 0; x \u0026lt; m; x++ ) { int loc = x + y * m; bright = brightness(img.pixels); } } return bright;}public float generateCircle (PImage img, int numPoints) { float radius=img.height/2; float angle=TWO_PI/(float)numPoints; float circlePoints = new float; for(int i=0;i\u0026lt; numPoints;i++){ float pt = {img.width/2 + radius*sin(angle*i), img.height/2 + radius*cos(angle*i)}; circlePoints = pt; } return circlePoints;}public float generateLines (float circlePoints) { float res = new float; int i = 0; for (int k=0; k \u0026lt; circlePoints.length-1; k++) { for (int l=k+1; l \u0026lt; circlePoints.length; l++) { res = new float {circlePoints, circlePoints, circlePoints, circlePoints}; i += 1; } } return res; }void setup() { size(468, 468); img = loadImage("zaha.jpg"); int height = img.height; int width = img.width; int n = floor(height / segment); int m = floor(width / segment); imgBrightness = imageBrigthness(img, height, width, segment); circlePoints = generateCircle(img, numPoints); float lines = generateLines(circlePoints); // get the sum brightness for (int k=0; k \u0026lt; lines.length; k++) { float sumBrightness = 0; for (int i=0; i \u0026lt; n; i++) { for (int j=0; j \u0026lt; m; j++) { PVector distance = getDistance(lines, lines, lines, lines, segment * i, segment * j); // if the point is close enough to the line, we add the value to the brightness value of that line, which will decide whether we display the line or not if (distance.z \u0026lt; 0.1) { sumBrightness += imgBrightness; } } } if (sumBrightness \u0026lt; 1600) { linesToDraw = new float {lines, lines, lines, lines}; } }}void draw() { //Displays the image at its actual size at point (0,0) image(img, 0, 0); for(int i=0; i \u0026lt; linesToDraw.length; i++){ line(linesToDraw, linesToDraw, linesToDraw, linesToDraw); } }
推荐阅读
- 盐城■盐城:千余件老物件慰市民“乡愁”
- 江苏如皋:冬日龙游湖景如画
- |77岁老人烙画《古韵扬州》铁笔生辉“烙”出“好地方”
- 通城|冷空气来袭,耐寒草花“上岗”扮靓通城
- 辩论赛|唇枪舌战!文明校园辩论赛总决赛举行
- 趣头条|奇瑞瑞虎5x,极具性价比,你喜欢吗
- 东台|东台致力打造串场河生态景观廊道
- 教育|中国移动“和教育”智慧校园研讨会在通召开
- 汽车|传华为智能汽车部件采用三元锂电池
- 趣头条|喜欢你,没道理,吉利博瑞就是我的菜
