Beispiel #1
0
Rect GraphicsObjectData::dstRect(const GraphicsObject& go,
                                 const GraphicsObject* parent) {
  Point origin = dstOrigin(go);
  Rect src = srcRect(go);

  int center_x = go.x() + go.xAdjustmentSum() - origin.x() +
                 (src.width() / 2.0f);
  int center_y = go.y() + go.yAdjustmentSum() - origin.y() +
                 (src.height() / 2.0f);

  float second_factor_x = 1.0f;
  float second_factor_y = 1.0f;
  if (parent) {
    center_x += parent->x() + parent->xAdjustmentSum();
    center_y += parent->y() + parent->yAdjustmentSum();

    second_factor_x = parent->getWidthScaleFactor();
    second_factor_y = parent->getHeightScaleFactor();
  }

  int half_real_width = (src.width() * second_factor_x *
                         go.getWidthScaleFactor()) / 2.0f;
  int half_real_height = (src.height() * second_factor_y *
                          go.getHeightScaleFactor()) / 2.0f;

  int xPos1 = center_x - half_real_width;
  int yPos1 = center_y - half_real_height;
  int xPos2 = center_x + half_real_width;
  int yPos2 = center_y + half_real_height;

  return Rect::GRP(xPos1, yPos1, xPos2, yPos2);
}
// I am not entirely sure these methods even make sense given the
// context...
int AnmGraphicsObjectData::pixelWidth(const GraphicsObject& rp) {
  const Surface::GrpRect& rect = image_->getPattern(rp.pattNo());
  int width = rect.rect.width();
  return int(rp.getWidthScaleFactor() * width);
}