newbie question, tessellation
metzor

I'm gonna feel really stupid for asking this, but here it goes

I just started taking a computer graphics course, and we've now started using Allegro C++. We haven't gotten all that far, we basically were handed a sheet with primitive functions (rectfill, ellipsefill, triangle, etc) and one of our first or second assignments was to tessellate (basically tile) the screen with a checkerboard. This was easy enough, as all it really needed was one set of nested for loops and a rectfill statement.

our next assignment has me stumped. i haven't taken a programming class in years, and it's overall very frustrating, which is why I'm making a fool of myself on these forums =)

we basically have to take a polygon with 6 vertices. and tile the screen with it. (this polygon has vertices of (50,0), (25, 25), (50,50), (100,50), (75, 25), (100,0)). we also have to make up our own polygon and do the same thing with it, creating something that you might see from mc escher. but i figure if i could just figure out the code for the first one, i could do it with pretty much any polygon.

anyone have any ideas or help? it's greatly appreciated.

sorry if this is lame :P

Krzysztof Kluczek
Quote:

(this polygon has vertices of (50,0), (25, 25), (50,50), (100,0), (75, 25), (100,0))

There is probably something wrong with is since you have listed (100,0) twice.

Ib Quezada

Probably the 2nd (100,0) is the way to tell the shape that it's closing... i'm not sure.

metzor

typo =o

there is a 100,0 but the other one is 100,50

corrected the original post
sorry

miran

What's the problem? Do the same thing as you did when drawing the checkerboard, except that instead of drawing rects, you draw this 6-sided polygon (write a function for this). The for loops should advance by 50 pixels each.

Ron Ofir

Unless you need to tile it tightly (leaving no spaces). I'm afraid it's not possible with this shape and I'm not sure there's a general way to do so.

miran
Quote:

I'm afraid it's not possible with this shape

Are you sure? ???

Evert
Quote:

Unless you need to tile it tightly (leaving no spaces). I'm afraid it's not possible with this shape

It's a regular hexagon. Of course it's possible.

miran
Quote:

It's a regular hexagon.

It's not a regular hexagon. It's a kind of an arrow hexagon, pointing to the left. Easier to tile than a regular honey comb style hexagon...

Simon Parzer
void draw_my_shape( BITMAP* bmp, int x, int y, int color )
{
  int points[12] = {0,0, -25,25, 0,50, 50,50, 25,25, 50,0};
  for (int i=0; i<12; ++i)
  {
    points<i>+=x;
    points[++i]+=y;
  }
  polygon(bmp,6,points,color);
}

Thread #587653. Printed from Allegro.cc