28#include "config_auto.h"
31#define INTERSECTING INT16_MAX
33int lessthan(
const void *first,
const void *second);
36 ICOORDELT_IT v = &vertices;
48 ICOORDELT_IT v = &vertices;
69 ICOORDELT_IT pts = &vertices;
71 botleft = *pts.data ();
75 if (pos.
x () < botleft.
x ())
77 botleft =
ICOORD (pos.
x (), botleft.
y ());
78 if (pos.
y () < botleft.
y ())
79 botleft =
ICOORD (botleft.
x (), pos.
y ());
80 if (pos.
x () > topright.
x ())
81 topright =
ICOORD (pos.
x (), topright.
y ());
82 if (pos.
y () > topright.
y ())
83 topright =
ICOORD (topright.
x (), pos.
y ());
86 while (!pts.at_first ());
87 ibl =
ICOORD (botleft.
x (), botleft.
y ());
88 itr =
ICOORD (topright.
x (), topright.
y ());
89 box =
TBOX (ibl, itr);
106 ICOORDELT_IT it = &vertices;
112 vvec = *it.data_relative (1) - pt;
114 if (vec.
y () <= 0 && vec.
y () + vvec.
y () > 0) {
121 else if (vec.
y () > 0 && vec.
y () + vvec.
y () <= 0) {
128 else if (vec.
y () == 0 && vec.
x () == 0)
132 while (!it.at_first ());
140 ICOORDELT_IT it = &vertices;
149 vertex = *it.data ();
157 while (!it.at_first ());
162 it.set_to_list (other->
points ());
164 vertex = *it.data ();
172 while (!it.at_first ());
187 ICOORDELT_IT pts = &vertices;
194 pt->
set_x(
static_cast<int16_t
>(floor(pos.
x() + 0.5)));
195 pt->
set_y(
static_cast<int16_t
>(floor(pos.
y() + 0.5)));
198 while (!pts.at_first ());
210 ICOORDELT_IT pts = &vertices;
217 while (!pts.at_first());
231 ICOORDELT_IT pts = &vertices;
238 while (!pts.at_first ());
243#ifndef GRAPHICS_DISABLED
245 ICOORDELT_IT v = &vertices;
254#if !defined(_WIN32) || defined(__MINGW32__)
255 snprintf(temp_buff,
sizeof(temp_buff),
"%" PRId32, num);
257 _ltoa(num, temp_buff, 10);
259 window->
Text(v.data ()->x (), v.data ()->y (), temp_buff);
262 window->
SetCursor(v.data ()->x (), v.data ()->y ());
263 for (v.mark_cycle_pt (); !v.cycled_list (); v.forward ()) {
264 window->
DrawTo(v.data ()->x (), v.data ()->y ());
267 window->
DrawTo(v.data ()->x (), v.data ()->y ());
282 const std::unique_ptr< ICOORDELT_LIST> segments(
284 if (!segments->empty ()) {
285 s_it.set_to_list(segments.get());
286 for (s_it.mark_cycle_pt (); !s_it.cycled_list (); s_it.forward ()) {
290 width = s_it.data ()->y ();
291 window->
SetCursor(s_it.data ()->x (), y);
292 window->
DrawTo(s_it.data()->x() +
static_cast<float>(width), y);
305 ICOORDELT_IT it = &vertices;
314 vertex = *it.data ();
322 while (!it.at_first ());
327 it.set_to_list (other->
points ());
337 while (!it.at_first ());
344 ICOORDELT_LIST *result;
347 result =
new ICOORDELT_LIST ();
348 r.set_to_list (result);
349 v.set_to_list (block->
points ());
351 for (v.mark_cycle_pt (); !v.cycled_list (); v.forward ()) {
352 if (((v.data_relative (-1)->y () > y) && (v.data ()->y () <= y))
353 || ((v.data_relative (-1)->y () <= y) && (v.data ()->y () > y))) {
354 previous = v.data_relative (-1);
356 float fx = 0.5f + previous->
x() +
357 (current->
x() - previous->
x()) * (fy - previous->
y()) /
358 (current->
y() - previous->
y());
359 x =
new ICOORDELT(
static_cast<int16_t
>(fx), 0);
366 for (r.mark_cycle_pt (); !r.cycled_list (); r.forward ())
368 for (r.mark_cycle_pt (); !r.cycled_list (); r.forward ()) {
369 r.data ()->
set_y (r.data_relative (1)->x () - r.data ()->x ());
371 delete (r.extract ());
379int lessthan(
const void *first,
const void *second) {
383 if (p1->
x () < p2->
x ())
385 else if (p1->
x () > p2->
x ())
391#ifndef GRAPHICS_DISABLED
413 return kPBColors[type];
int lessthan(const void *first, const void *second)
void set_x(int16_t xin)
rewrite function
int16_t y() const
access_function
void set_y(int16_t yin)
rewrite function
int16_t x() const
access function
void rotate(const FCOORD vec)
void set_y(float yin)
rewrite function
void set_x(float xin)
rewrite function
ICOORDELT_LIST * points()
bool overlap(POLY_BLOCK *other)
int16_t winding_number(const ICOORD &test_pt)
void fill(ScrollView *window, ScrollView::Color colour)
static ScrollView::Color ColorForPolyBlockType(PolyBlockType type)
Returns a color to draw the given type.
bool contains(POLY_BLOCK *other)
void rotate(FCOORD rotation)
void plot(ScrollView *window, int32_t num)
ICOORDELT_LIST * get_line(int16_t y)
bool overlap(const TBOX &box) const
void DrawTo(int x, int y)
void TextAttributes(const char *font, int pixel_size, bool bold, bool italic, bool underlined)
void Text(int x, int y, const char *mystring)
void SetCursor(int x, int y)