Created
July 24, 2013 02:45
-
-
Save tinytintoy/6067729 to your computer and use it in GitHub Desktop.
Manga Linework #2; Perception
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
/* | |
* [020] Manga Linework #2; Perception | |
* | |
* 2013 [+++] @tinytintoto | |
*/ | |
LineworkDrawer ld = new LineworkDrawer(); | |
PVector center_loc; | |
void setup() { | |
size( 500, 280 ); | |
smooth(); | |
background( 255 ); | |
frameRate( 15 ); | |
fill( 0 ); | |
noStroke(); | |
center_loc = new PVector( 0, height ); | |
} | |
void draw() { | |
} | |
void mouseReleased() { | |
ld.perception( center_loc, new PVector(mouseX, mouseY) ); | |
} | |
void mousePressed() { | |
center_loc.x = mouseX; | |
center_loc.y = mouseY; | |
} | |
class LineworkDrawer { | |
LineworkDrawer() { | |
} | |
public void perception( PVector loc, PVector direction ) { | |
float tremor, range = PI * 0.6, in_r_scale = 0.85; | |
int step = 17; | |
ArrayList<PVector> in_vertexes = new ArrayList<PVector>(); | |
PVector position = new PVector(direction.x - loc.x, direction.y - loc.y); | |
position.rotate( -(range/2) ); | |
beginShape(); | |
for ( int i = 0; i < step; i++ ) { | |
float x, y; | |
x = ( position.x * ( 0.7 + 0.3 * ( 1 - i % 2 ) ) ); | |
y = ( position.y * ( 0.7 + 0.3 * ( 1 - i % 2 ) ) ); | |
PVector pos = new PVector( x, y ); | |
pos.mult( map( ( step/2 - abs( ( step / 2 ) - i ) ), 0, step/2, 0.75, 1 ) ); | |
vertex( pos.x + loc.x, pos.y + loc.y ); | |
position.rotate( range/step ); | |
if( i < step - 1 ){ | |
in_r_scale = map( ( step/2 - abs( ( step / 2 ) - i ) ), 0, step/2, 0.9, 0.85 ); | |
in_vertexes.add( new PVector( pos.x * in_r_scale, pos.y * in_r_scale ) ); | |
} | |
} | |
for( int i = in_vertexes.size() - 1; i > 0; i-- ){ | |
PVector pos = (PVector) in_vertexes.get(i); | |
vertex( pos.x + loc.x, pos.y + loc.y ); | |
in_vertexes.remove(i); | |
} | |
endShape(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment