void TMyPaintBrushStyle::makeIcon(const TDimension &d) {
  TFilePath path = m_fullpath.getParentDir() + (m_fullpath.getWideName() + L"_prev.png");
  if (!m_preview) {
    m_icon = TRaster32P(d);
    m_icon->fill(TPixel32::Red);
  } else
  if (m_preview->getSize() == d) {
    m_icon = m_preview;
  } else {
    m_icon = TRaster32P(d);
    double sx = (double)d.lx/(double)m_preview->getLx();
    double sy = (double)d.ly/(double)m_preview->getLy();
    TRop::resample(m_icon, m_preview, TScale(sx, sy));
  }

  // paint color marker
  if (d.lx > 0 && d.ly > 0) {
    int size = std::min( 1 + std::min(d.lx, d.ly)*2/3,
                         1 + std::max(d.lx, d.ly)/2 );
    TPixel32 color = getMainColor();
    for(int y = 0; y < size; ++y) {
      TPixel32 *p = m_icon->pixels(d.ly - y - 1);
      TPixel32 *endp = p + size - y - 1;
      for( ;p != endp; ++p)
        *p = color;
      *p = blend(*p, color, 0.5);
    }
  }
}
예제 #2
0
	void StyleData::computeColors()
	{
		currentMainColor = calculateColor(mainColorData);
		current3DOverrideColor = _3dOverrideColor.a != 0 ? _3dOverrideColor : getMainColor();
		currentColors.clear();
		for(const auto& cd : colorDatas) currentColors.push_back(calculateColor(cd));

		ssvu::rotate(currentColors, begin(currentColors) + currentSwapTime / (maxSwapTime / 2.f));
	}
예제 #3
0
bool TColorStyle::operator==(const TColorStyle &cs) const {
  if (getTagId() != cs.getTagId()) return false;

  if (getMainColor() != cs.getMainColor()) return false;

  int paramCount = getParamCount();
  if (paramCount != cs.getParamCount()) return false;

  int colorParamCount = getColorParamCount();
  if (colorParamCount != cs.getColorParamCount()) return false;

  if (m_name != cs.getName()) return false;
  if (m_originalName != cs.getOriginalName()) return false;
  if (m_globalName != cs.getGlobalName()) return false;
  if (m_isEditedFromOriginal != cs.getIsEditedFlag()) return false;
  if (m_pickedPosition != cs.getPickedPosition()) return false;
  if (m_flags != cs.getFlags()) return false;

  for (int p = 0; p < colorParamCount; ++p)
    if (getColorParamValue(p) != cs.getColorParamValue(p)) return false;

  for (int p = 0; p < paramCount; ++p) {
    switch (getParamType(p)) {
    case BOOL:
      if (getParamValue(bool_tag(), p) != cs.getParamValue(bool_tag(), p))
        return false;
      break;
    case INT:
    case ENUM:
      if (getParamValue(int_tag(), p) != cs.getParamValue(int_tag(), p))
        return false;
      break;
    case DOUBLE:
      if (getParamValue(double_tag(), p) != cs.getParamValue(double_tag(), p))
        return false;
      break;
    case FILEPATH:
      if (getParamValue(TFilePath_tag(), p) !=
          cs.getParamValue(TFilePath_tag(), p))
        return false;
      break;
    default:
      assert(false);
    }
  }

  return true;
}