shihaipeng05 发表于 2019-6-28 14:16:10

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

一个很牛逼的变矢量算法。看似挺简单,不过本人不太会搞,先搬过来给高人研究研究。
这个画风还是挺独特的,都是线条描绘的明暗细节部分。不过代码里是同时好几条线一起画出来。不知道能不能搞成就1条线画完。求高人相助。


这个还算正常

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

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

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

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

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

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

//aimed direction
PVector vise=new PVector();
int locPixel;
ArrayList <Seeker> seekersArray;
float seekX,seekY;
//worm's length
int maxLength;
int maxLayers;
//like pixels[], to keep track of how many times a point is reached by a worm
int [] buffer;
int [] limiteDown;
//number of worms at the beginning
int nbePoints;
public float inertia;
//width and length of the drawing area
int larg;
int haut;
int largI;
int hautI;
//brightness of the destination pixel
float briMax;
//minimum brightness threshold
public int seuilBrillanceMini;
//maximum brightness threshold
public int seuilBrillanceMaxi;
//location of the tested point in pixels[]
int locTest;
int locTaX;
    int locTaY;
int brightnessTemp;
//around a point (worms position), how many pixels will we look at...
int amplitudeTest;
//constrain the acceleration vector into a devMax radius circle
float devMax;
//constrain the speed vector into a vMax radius circle
float vMax;
//not used:random factor
int hasard;
//stroke's weight (slider) or radius of ellipse used for drawing
public float myweight;
//draw or not (button onOffButton)
public boolean dessine=true;
//different drawing options
public int modeCouleur;
//fill color
int macouleur;
boolean limite;

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

size(800,600);
//sound useSound=false;
limite=false;
//sound minim = new Minim(this);
//drop = new SDrop(this);
// f = loadFont("ArialUnicodeMS-12.vlw");
source = loadImage("tiger.jpg");
if(hautI*source.width>largI*source.height){
    larg=largI;
    haut=larg*source.height/source.width;
}else{
    haut=hautI;
    larg=haut*source.width/source.height;
}
source.resize(larg,haut);
source.loadPixels();
fill(0);
initialiser();
}

//launched after setup and any time you hit the ResetButton button
public void initialiser() {
dessine=true;
nbePoints=6;
fill( 255 );
stroke( 255 );
rect( 0, 0, larg,haut );
buffer=new int;
smooth();
inertia=6;

1134548171 发表于 2020-4-7 13:06:11

可以发一下源链接吗? 好像缺一个库文件
页: [1]
查看完整版本: 点阵图变矢量的代码,有偿求改