|
Post by lavaswordman on May 16, 2017 7:40:51 GMT -8
Is there a way to redraw a polygon you already created but just rotated GD.Clear();
GD.Begin(POINTS);
GD.PointSize(16 * 20);
GD.ColorRGB(0xFFFFFF);
GD.Vertex2ii(277, 30);
GD.ColorRGB(0x3498db);
GD.PointSize(16 * 10);
GD.Vertex2ii(277, 30);
GD.ColorRGB(0xFFFFFF);
Poly po;
po.begin();
po.v(16 * 274, 16 * -5);
po.v(16 * 282, 16 * -5);
po.v(16 * 286, 16 * 15);
po.v(16 * 270, 16 * 15);
po.draw(); I would like to rotate and redraw this polygon by an angle pi/6 as I am trying to design a gear like so
|
|
dl14
Junior Member
Posts: 22
|
Post by dl14 on May 18, 2017 18:30:57 GMT -8
From the gd2 cook book
// Apply a rotation around pixel (64, 64) static void rotate_64_64(uint16_t a) { GD.cmd_translate(F16(64),F16(64)); GD.cmd_rotate(a); GD.cmd_translate(F16(-64), F16(-64)); }
//main code: GD.ClearColorRGB(0x602010); GD.Clear(); GD.BlendFunc(SRC_ALPHA, ZERO); GD.Begin(BITMAPS); GD.Vertex2ii(10, 72); rotate_64_64(DEGREES(22.5)); GD.cmd_setmatrix(); GD.Vertex2ii(176, 72); rotate_64_64(DEGREES(22.5)); GD.cmd_setmatrix(); GD.Vertex2ii(342, 72); GD.swap();
this will display three images (all of them rotated)
|
|
dl14
Junior Member
Posts: 22
|
Post by dl14 on May 18, 2017 18:32:25 GMT -8
Remember that the angle specified is in Furmans where 1 F = 360 / 65536 degrees
|
|