Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int
- midH, // height / 2 (vidurio horizontali linija)
- midW, // width / 2 (vidurio vertikali linija)
- left,
- right,
- above,
- below,
- diameter, // akies dydis (atitinkamai prie jo pririšti ir kiti dydžiai)
- weight; // plonų stačiakampių storis
- void setup () {
- size (1280, 700);
- // width = 1280
- // height = 700
- background (255);
- rectMode (CENTER); // nurodau, kad noriu visų stačiakampių (tame tarpe ir kvadrato) pradžia bus
- // ne viršutinis kairys kampas, bet pats stačiakampio centras
- midH = height/2;
- midW = width/2;
- diameter = height/5; // pririšu prie aukščio, nes jis dažniausiai būna mažesnis nei plotis
- weight = height/50;
- left = midW - diameter;
- right = midW + diameter;
- above = midH - diameter;
- below = midH + diameter;
- }
- void draw () {
- // face
- fill (0, 255, 0);
- circle (midW, midH, diameter*4);
- // eyebrows (antakiai)
- fill (0);
- rect (left, above, diameter, weight);
- rect (right, above, diameter, weight);
- // nose
- rect (midW, midH, weight, diameter/2);
- // eyes
- // spalvą pasirenku priklausomai nuo to, ar pelė paspausta, ar ne
- if (mousePressed)
- fill (0, 0, 255);
- else
- fill (255); // tik šis sakinys galioja prie "else"
- // (kadangi neapskliaudėme riestiniais skliaustais {})
- circle (left, midH, diameter);
- circle (right, midH, diameter);
- // pupils (vyzdžiai)
- fill (0);
- circle (left, midH, diameter/3);
- circle (right, midH, diameter/3);
- // mouth
- int mouthH; // burnos aukštis
- // burnos aukščio pasirinkimas
- if (mouseY < below) // jei pelė yra aukščiau nei burna
- mouthH = 0;
- else if (mouseY > below + diameter) // jei pelė yra žemiau nei maksimalus burnos aukštis
- mouthH = diameter;
- else // jei pelė žemiau nei burna (bet ne per daug žemai)
- mouthH = mouseY - below;
- fill (255, 0, 0); // red
- rect (midW, below, diameter, mouthH); // pati burna
- lines ();
- }
- void lines () {
- strokeWeight (5);
- // main
- stroke (255, 0, 0); // red
- line (0, midH, width, midH);
- line (midW, 0, midW, height);
- // vertical
- stroke (0); // green
- line (left, 0, left, height);
- line (right, 0, right, height);
- // horizontal
- stroke (0, 0, 255); // blue
- line (0, above, width, above);
- line (0, below, width, below);
- // to reset everything (I know it should not be a part of the function)
- // only that in this case it is more appropriate for me to do that
- strokeWeight (1);
- stroke (0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement