1

So I have the code to print a horizontal line on an image...

public void printH_line(int row, int thickness, int red, int green, int blue) {
    Pixel[] pixels = pic.getPixels();
    System.out.println("\nprintH_line");

    for (int c = 0; c < 200; c++) {
        Pixel pix = pic.getPixel(c, row);
        pix.setColor(new Color(limitVal(red), limitVal(green),
                limitVal(blue)));

Now I just don't know how to do the "thickness," meaning how thick the user wants the line to be. I will be asking the user to enter a number on how thick they want the line to be and that is "int thickness."

simont
  • 68,704
  • 18
  • 117
  • 136
  • 1
    possible duplicate of [Java: How to print a line x number of times?](http://stackoverflow.com/questions/16290886/java-how-to-print-a-line-x-number-of-times) – MadProgrammer Apr 30 '13 at 04:36
  • Draw a rectangle instead. –  Apr 30 '13 at 04:37
  • 2
    I can't tell what API you are using. I don't see any Graphics methods being used. Also, why would you create a new Color every time through the loop. It looks to me like you are creating the same Color. – camickr Apr 30 '13 at 04:42

1 Answers1

1

Use Graphics2D.setStroke(Stroke) as seen in this answer.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433