极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 22649|回复: 1

点阵图变矢量的代码,有偿求改

[复制链接]
发表于 2019-6-28 14:16:10 | 显示全部楼层 |阅读模式
一个很牛逼的变矢量算法。看似挺简单,不过本人不太会搞,先搬过来给高人研究研究。
这个画风还是挺独特的,都是线条描绘的明暗细节部分。不过代码里是同时好几条线一起画出来。不知道能不能搞成就1条线画完。求高人相助。


这个还算正常

调节参数可以搞各种画风。。。他们说这个叫阴猫画

还有各种风格,大家可以自己研究。http://www.openprocessing.org/还有很多有意思的代码,不过有很多是不能直接搬到processing上直接用的,不太兼容。只能在它网站上在线编译。      这些不重要,主要还是求单独一线画出来的代码。有意者M我。

  1. /* OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/64754*@* */
  2. /* !do not delete the line above, required for linking your tweak if you upload again */
  3. // Pierre MARZIN
  4. // Trying to learn Processing... First project, much inspired by "Mycelium" by Scloopy?
  5. // http://marzinp.free.fr/applets

  6. //GUI and Drag 'n drop: great libraries ! Thanks to Andreas Schlegel (http://www.sojamo.de/libraries/index.html)
  7. //GUI variables
  8. //SDrop drop;
  9. public String mUrl;

  10. /* @pjs preload="tiger.jpg"; */

  11. PImage source;      // Source image
  12. //for each "worm", variables: position

  13. //aimed direction
  14. PVector vise=new PVector();
  15. int locPixel;
  16. ArrayList <Seeker> seekersArray;
  17. float seekX,seekY;
  18. //worm's length
  19. int maxLength;
  20. int maxLayers;
  21. //like pixels[], to keep track of how many times a point is reached by a worm
  22. int [] buffer;
  23. int [] limiteDown;
  24. //number of worms at the beginning
  25. int nbePoints;
  26. public float inertia;
  27. //width and length of the drawing area
  28. int larg;
  29. int haut;
  30. int largI;
  31. int hautI;
  32. //brightness of the destination pixel
  33. float briMax;
  34. //minimum brightness threshold
  35. public int seuilBrillanceMini;
  36. //maximum brightness threshold
  37. public int seuilBrillanceMaxi;
  38. //location of the tested point in pixels[]
  39. int locTest;
  40. int locTaX;
  41.     int locTaY;
  42. int brightnessTemp;
  43. //around a point (worms position), how many pixels will we look at...
  44. int amplitudeTest;
  45. //constrain the acceleration vector into a devMax radius circle
  46. float devMax;
  47. //constrain the speed vector into a vMax radius circle
  48. float vMax;
  49. //not used:random factor
  50. int hasard;
  51. //stroke's weight (slider) or radius of ellipse used for drawing
  52. public float myweight;
  53. //draw or not (button onOffButton)
  54. public boolean dessine=true;
  55. //different drawing options
  56. public int modeCouleur;
  57. //fill color
  58. int macouleur;
  59. boolean limite;

  60. //setup only sets up what won't change:GUI and window params
  61. //I use initialiser() to set up what has to be initialised
  62. //when you hit "ResetButton" and dessin() to set the drawing parameters
  63. void setup() {
  64.   larg=largI=800;
  65.   haut=hautI=600;

  66.   size(800,600);
  67.   //sound useSound=false;
  68.   limite=false;
  69.   //sound minim = new Minim(this);
  70.   //drop = new SDrop(this);
  71. // f = loadFont("ArialUnicodeMS-12.vlw");
  72.   source = loadImage("tiger.jpg");
  73.   if(hautI*source.width>largI*source.height){
  74.     larg=largI;
  75.     haut=larg*source.height/source.width;
  76.   }else{
  77.     haut=hautI;
  78.     larg=haut*source.width/source.height;
  79.   }
  80. source.resize(larg,haut);
  81. source.loadPixels();
  82.   fill(0);
  83.   initialiser();
  84. }

  85. //launched after setup and any time you hit the ResetButton button
  86. public void initialiser() {
  87.   dessine=true;
  88.   nbePoints=6;
  89.   fill( 255 );
  90.   stroke( 255 );
  91.   rect( 0, 0, larg,haut );
  92.   buffer=new int[haut*larg];
  93.   smooth();
  94.   inertia=6;
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

发表于 2020-4-7 13:06:11 | 显示全部楼层
可以发一下源链接吗? 好像缺一个库文件
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-24 08:52 , Processed in 0.040690 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表