Example #1
0
 /**
  * Dessine une ligne dans un tableau de pixel, relativement au point en haut a gauche de l'image.
  */
 public static void drawLine(byte[] tab, int width, ParametricFunction pf) {
   int height = tab.length / width;
   if (!pf.isAlmostVertical()) {
     for (int i = 0; i < width; i++) {
       int y = pf.getY(i);
       if (y >= 0 && y < height) tab[y * width + i] = 0;
     }
   } else {
     for (int i = 0; i < height; i++) {
       int x = pf.getX(i);
       if (x >= 0 && x < width) tab[i * width + x] = 0;
     }
   }
 }
Example #2
0
 /** Dessine une ligne dans un tableau de pixel, relativement au centre de l'image. */
 public static int drawLineCenter(byte[] tab, int width, ParametricFunction pf) {
   int height = tab.length / width;
   int center_x = width / 2;
   int center_y = (height / 2);
   int pixelsDrawn = 0;
   if (!pf.isAlmostVertical()) {
     for (int i = -width / 2; i < width / 2; i++) {
       int y = pf.getY(i) + center_y;
       if (y >= 0 && y < height) {
         tab[y * width + i + center_x] = 0;
         pixelsDrawn++;
       }
     }
   } else {
     for (int i = -height / 2; i < height / 2; i++) {
       int x = pf.getX(i) + center_x;
       if (x >= 0 && x < width) {
         tab[(i + center_y) * width + x] = 0;
         pixelsDrawn++;
       }
     }
   }
   return pixelsDrawn;
 }