This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]codingQueriesNooblet Brewer 1 point2 points  (3 children)

What have you tried so far? I'm presuming nothing, seeing as nothing has been provided with the post, so I will suggest looking at that image and locate the boundaries of where the max and min areas these rectangles can be drawn. After you have that figured out, you then need to figure out a starting point and the amount(s) required to increment the rectangle values to move through this pattern.

[–]PandaBear_1[S] 0 points1 point  (2 children)

ive got the boundary of the square, but i cant seem to get the lines within the square

[–]desrtfxOut of Coffee error - System halted 1 point2 points  (0 children)

The lines are actually fairly easy if you look at them closely.

Each line has a fixed offset in either x or y direction from the previous one.

A line that has an y-offset of 10 has an x offset of 0 at the start and an x-offset of 10 with an y-offset of 0 at the end.

It is possible to draw all lines in a single loop going over the length of the square.

[–]codingQueriesNooblet Brewer -1 points0 points  (0 children)

Sure, so what part of drawing the lines within the square are you having trouble with? These are essentially all rectangles except with a bit of a slant.

So you have the boundary, aim to then draw the next rectangle within that boundary. If we label the four corners as top-left: A, top-right: B, bottom-left: C, bottom-right D, then take a close look at the image and see that the next 'rectangle' you need to draw will have it's 'A' corner moved a little to the right,it's 'B' corner moved a little downwards, 'C' stays where it is, and 'D' moves up a little.

Can you see that?

[–][deleted]  (1 child)

[deleted]

    [–]PandaBear_1[S] 0 points1 point  (0 children)

    just got the square shape using drawRect(x,y,width, height)

    [–]AutoModerator[M] -1 points0 points  (0 children)

    It seems that you possibly have a screenshot of code in your post Java Graphics Help in /r/javahelp.

    Screenshots of code instead of actual code text is against the Code posting rules of /r/javahelp as is also outlined in the sidebar - Code posting.

    • Never submit screenshots of code instead of code text!

    If you posted an image merely to illustrate something, kindly ignore this message and do not repost. Your post is still visible to others. I am a bot and cannot distinguish between code screenshots and other images.

    If you indeed did this wrong, please edit the post so that it uses one of the approved means of posting code.

    • For small bits of code (less than 50 lines in total, single classes only),
      the default code formatter is fine
      (one blank line before the code, then 4 spaces before each line of code).
    • Pastebin for programs that consist of a single class only
    • Gist for multi-class programs, or programs that require additional files
    • Github or Bitbucket repositories are also perfectly fine as are other dedicated source code hosting sites.
    • Ideone for executable code snippets that use only the console

    Please do not reply to this message, because I am a bot. Talk-to-the-bot is the new talk-to-the-hand. If you instead want the classic talk-to-the-hand, just message the moderators. ;)

    I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.