Skip to content

Instantly share code, notes, and snippets.

@bramses
Created December 15, 2019 06:42
Show Gist options
  • Save bramses/7f528337ee8795b5764654443d5d8120 to your computer and use it in GitHub Desktop.
Save bramses/7f528337ee8795b5764654443d5d8120 to your computer and use it in GitHub Desktop.
Galakrond Priest Eye πŸ‘
float p1x;
float p1y;
float p2x;
float p2y;
float p3x;
float p3y;
float p4y;
// lil eye start positions
float l1x;
float l1y;
float l2x;
float l2y;
float l3x;
float l3y;
float l4x;
float l4y;
void setup () {
size(200, 200);
pixelDensity(2);
colorMode(HSB, 360, 100, 100);
background(281, 53, 40);
p1x = width / 2 - 50;
p1y = height / 2;
p2x = width / 2;
p2y = height / 2 - 30;
p3x = width / 2 + 50;
p3y = height / 2;
// this y controls the "mirror" curve
p4y = height / 2 + 30;
l1x = random(150); l1y = random(150); l2x = random(150); l2y = random(150); l3x = random(200); l3y = random(200); l4x = random(200); l4y = random(200);
}
void draw () {
drawGradient(p1x + 50, p1y);
drawBigEye();
drawLittleEye(l1x,l1y,0,0,10, 4);
drawLittleEye(l2x,l2y,0,0,10, 8);
drawLittleEye(l3x,l3y,40,155, -55, 5);
drawLittleEye(l4x,l4y,0,0, 0, 9);
saveFrame();
}
void drawBigEye () {
float mouseMap = map(mouseX, 0, width, -5, 10);
float mouseMapY = map(mouseY, 0, height, -5, 5);
pushMatrix();
translate(-35, 50);
rotate(radians(-25));
// outer eye
stroke(309, 55, 21);
fill(39, 78, 51);
bezier(p1x, p1y, p2x, p2y, p2x, p2y, p3x, p3y);
bezier(p1x, p1y, p2x, p4y, p2x, p4y, p3x, p3y);
// smaller inner eye yellow
noStroke();
fill(53,100,88);
bezier(p1x + 6 , p1y, p2x, p2y, p2x, p2y, p3x - 6, p3y);
bezier(p1x + 6, p1y, p2x, p4y, p2x, p4y, p3x - 6, p3y);
// pupil
stroke(0);
fill(4, 56, 47);
bezier(p1x + 48 + mouseMap, p2y + 16 + mouseMapY,
p1x + 40 + mouseMap, p2y + 34 + mouseMapY, p1x + 40 + mouseMap, p2y + 34 + mouseMapY,
p1x + 48 + mouseMap, p4y - 16 + mouseMapY);
bezier(p1x + 48 + mouseMap, p2y + 16 + mouseMapY,
p1x + 55 + mouseMap, p2y + 34 + mouseMapY, p1x + 55 + mouseMap, p2y + 34 + mouseMapY,
p1x + 48 + mouseMap, p4y - 16 + mouseMapY);
popMatrix();
}
void drawLittleEye(float xCenter, float yCenter, float translateX, float translateY, float rotateDeg, float ratio) {
float mouseMap = map(mouseX, 0, width, -5 / ratio, 10 / ratio);
float mouseMapY = map(mouseY, 0, height, -5 / ratio, 5 / ratio);
float p1x = xCenter - 50 / ratio;
float p1y = yCenter;
float p2x = xCenter;
float p2y = yCenter - 30 / ratio;
float p3x = xCenter + 50 / ratio;
float p3y = yCenter;
// this y controls the "mirror" curve
float p4y = yCenter + 30 / ratio;
pushMatrix();
translate(translateX, translateY);
rotate(radians(rotateDeg));
// outer eye
stroke(309, 55, 21);
fill(39, 78, 51);
bezier(p1x, p1y, p2x, p2y, p2x, p2y, p3x, p3y);
bezier(p1x, p1y, p2x, p4y, p2x, p4y, p3x, p3y);
// smaller inner eye yellow
noStroke();
fill(53,100,88);
bezier(p1x + 6 / ratio, p1y, p2x, p2y, p2x, p2y, p3x - 6 / ratio, p3y);
bezier(p1x + 6 / ratio, p1y, p2x, p4y, p2x, p4y, p3x - 6 / ratio, p3y);
// pupil
stroke(0);
fill(4, 56, 47);
bezier(p1x + 48 / ratio + mouseMap, p2y + 16 / ratio + mouseMapY, p1x + 40 / ratio + mouseMap, p2y + 34 / ratio + mouseMapY, p1x + 40 / ratio + mouseMap, p2y + 34 / ratio + mouseMapY, p1x + 48 / ratio + mouseMap, p4y - 16 / ratio + mouseMapY);
bezier(p1x + 48 / ratio + mouseMap, p2y + 16 / ratio + mouseMapY, p1x + 55 / ratio + mouseMap, p2y + 34 / ratio + mouseMapY, p1x + 55 / ratio + mouseMap, p2y + 34 / ratio + mouseMapY, p1x + 48 / ratio + mouseMap, p4y - 16 / ratio + mouseMapY);
popMatrix();
}
void drawGradient (float x, float y) {
noStroke();
int radius = width;
for (int r = radius; r >0; r -= 5) {
float mapBrightness = map(r, radius, 0,40, 10);
fill(281, 53, mapBrightness);
ellipse(x,y, r, r);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment