Skip to content

Instantly share code, notes, and snippets.

@tvdu29
Last active April 16, 2019 21:41
Show Gist options
  • Save tvdu29/a4d71d8a3a244a29a6207524ba6c2492 to your computer and use it in GitHub Desktop.
Save tvdu29/a4d71d8a3a244a29a6207524ba6c2492 to your computer and use it in GitHub Desktop.
Paimt
//Fonctions de dessin
void drawLine(int startx, int starty, int finishx, int finishy, color col)
{
stroke(col);
line(startx, starty, finishx, finishy);
}
void drawSquare(int startx, int starty, int widthx, int widthy, color col)
{
noStroke();
fill(col);
rect(startx, starty, widthx, widthy);
}
void drawCircle(int startx, int starty, int widthx, int widthy, color col)
{
noStroke();
fill(col);
ellipse(startx, starty, widthx, widthy);
}
void drawBox()
{
//dessine un carre a l'aide de 4 lignes
drawLine(200, 100, 1000, 100, red);
drawLine(200, 100, 200, 700, green);
drawLine(1000, 100, 1000, 700, blue);
drawLine(200, 700, 1000, 700, color(200, 10, 240));
}
//Fonctions pour le palier 3
void printSquares()
{
drawSquare(width - width / 5, 0, width / 5, 100, red);
drawSquare(width - width / 5, 100, width / 5, 100, blue);
drawSquare(width - width / 5, 200, width / 5, 100, green);
}
boolean mouseIsInBox(int xmin, int ymin, int xmax, int ymax)//Regarde si la position de la souris est a l'interieur d'une boite de xmax pixels de large et ymin pixels de haut
{ //dont le coin haut gauche est situe a la position (x = xmin y = ymin)
if (mouseX >= xmin && mouseX <= xmax && mouseY >= ymin && mouseY <= ymax)
return (true);
else
return (false);
}
color red = color(255, 0, 0);
color green = color(0, 255, 0);
color blue = color(0, 0, 255);
color black = color (0, 0, 0);
color line_color = black;
int weight = 3;
void settings() {
size(1200, 800);
}
void setup() {
strokeWeight(weight);
}
void draw()
{
if (keyPressed){
if (key == 'b')
line_color = blue;
if (key == 'v')
line_color = green;
if (key == 'r')
line_color = red;
if (key == 'x')
line_color = black;
if (key == '+')
weight += 1;
if (key == '-' && weight > 0)
weight -= 1;
if (key == 'c')
background(204);
}
strokeWeight(weight);
if (mousePressed == true)
drawLine(pmouseX, pmouseY, mouseX, mouseY, line_color);
//Ecrivez votre code ici
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment