Created
May 14, 2022 09:10
-
-
Save lxfly2000/22150a9724ef5283b0e0dc22d99b3318 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PGraphics imgNoise[],imgCaptcha,imgBlended; | |
int x1=0,x2=0,recorded=0; | |
void setup(){ | |
size(640,400); | |
imgNoise=new PGraphics[2]; | |
for(int i=0;i<imgNoise.length;i++){ | |
imgNoise[i]=createGraphics(width,height); | |
imgNoise[i].beginDraw(); | |
for(int y=0;y<height;y++){ | |
for(int x=0;x<width;x++){ | |
imgNoise[i].set(x,y,color(255*(int)random(2.0f))); | |
} | |
} | |
imgNoise[i].endDraw(); | |
} | |
imgCaptcha=createGraphics(width,height); | |
imgCaptcha.beginDraw(); | |
imgCaptcha.background(0,0,0); | |
imgCaptcha.textFont(createFont("微软雅黑 Bold",48.0f)); | |
imgCaptcha.scale(4.0f,4.0f); | |
imgCaptcha.text(String.valueOf((int)random(1000.0f,10000.0f)),20.0f,70.0f); | |
imgCaptcha.endDraw(); | |
imgBlended=createGraphics(width,height); | |
} | |
void draw(){ | |
blendMode(BLEND); | |
image(imgCaptcha,0.0f,0.0f); | |
blendMode(SCREEN); | |
image(imgNoise[0],(float)x1,0.0f); | |
image(imgNoise[0],(float)(x1-width),0.0f); | |
x1=(x1+1)%width; | |
imgBlended.beginDraw(); | |
imgBlended.blendMode(BLEND); | |
imgBlended.image(imgCaptcha,0.0f,0.0f); | |
imgBlended.blendMode(MULTIPLY); | |
imgBlended.image(imgNoise[1],(float)x2,0.0f); | |
imgBlended.image(imgNoise[1],(float)(x2-width),0.0f); | |
x2=(x2+width-1)%width; | |
imgBlended.endDraw(); | |
blendMode(SUBTRACT); | |
image(imgBlended,0,0); | |
if(recorded<2){ | |
saveFrame("f-##.png"); | |
recorded++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment