Пример #1
0
  void SVGPainter::NewCanvas(double width, double height)
  {
    //Using withViewBox to supress xml header and xmlns attributes. May need another way.
    if(!m_withViewBox)
      m_ofs << "<?xml version=\"1.0\"?>\n";

    if(m_withViewBox)
      m_ofs << "<g transform=\"translate(" << m_x << "," << m_y << ")\">\n";

    m_ofs << "<svg ";
    if(!m_withViewBox)
      m_ofs << "xmlns=\"http://www.w3.org/2000/svg\"\n"
               "xmlns:xlink=\"http://www.w3.org/1999/xlink\" "
               "xmlns:cml=\"http://www.xml-cml.org/schema\" ";
    if(m_withViewBox)
      m_ofs << "width=\"" << m_width << "\" height=\"" << m_height << "\" "
            << "x=\"0\" y=\"0\" "
            << "viewBox=\"0 0 " << width << ' ' << height << "\"\n";
    else
      m_ofs << "width=\"" << width << "\" height=\"" << height << "\" "
            << "x=\"0\" y=\"0\" ";

    //Bond color and width are the initial m_Pencolor and m_PenWidth
    m_ofs << "font-family=\"" << m_fontFamily << "\" stroke=" << MakeRGB(m_Pencolor)
          << "stroke-width=\"" << m_PenWidth << "\"  stroke-linecap=\"round\"" << ">\n";

    if(!m_withViewBox && m_Fillcolor.alpha!=0.0)//Background color for single molecule. Handled by outer svg when table.
      m_ofs << "<rect x=\"0%\" y=\"0%\" width=\"100%\" height=\"100%\" stroke-width=\"0\" fill="
            << MakeRGB(m_Fillcolor) << " />\n";
    m_OrigBondcolor = m_Pencolor;
  }
Пример #2
0
 void SVGPainter::DrawText(double x, double y, const std::string &text)
 {
   m_ofs << "<text x=\"" << x << "\" y=\"" << y << "\""
     << " fill=" << MakeRGB(m_Pencolor) << " stroke=" << MakeRGB(m_Pencolor) << "stroke-width=\"1\" "
     << "font-size=\"" << m_fontPointSize << "\" >"
     << text << "</text>\n";
 }
Пример #3
0
 void SVGPainter::DrawPolygon(const std::vector<std::pair<double,double> > &points)
 {
   m_ofs << "<polygon points=\"";
     std::vector<std::pair<double,double> >::const_iterator i;
   for (i = points.begin(); i != points.end(); ++i)
     m_ofs << i->first << ' ' << i->second << ' ';
   m_ofs << "\"";
   m_ofs << " stroke-width=\"" << m_PenWidth << "\"";
   m_ofs << " fill=" << MakeRGB(m_Pencolor);
   m_ofs << " stroke=" << MakeRGB(m_Pencolor);
   m_ofs << "/>\n";
 }
Пример #4
0
 void   SVGPainter::WriteDefs()
 {
   if (!m_Gradients->empty()) {
     m_ofs << "<defs>\n";
     for (std::set<ColorGradient>::iterator it=m_Gradients->begin(); it!=m_Gradients->end(); ++it) {
       m_ofs << "<radialGradient id='radial";
       m_ofs << RGBcode(it->first)<< RGBcode(it->second) << "' ";
       m_ofs << "cx='50%' cy='50%' r='50%' fx='30%' fy='30%'>\n";
       m_ofs << "  <stop offset=' 0%' stop-color=" << MakeRGB(it->first) << " stop-opacity='0.8'/>\n";
       m_ofs << "  <stop offset='100%' stop-color=" << MakeRGB(it->second) << " stop-opacity ='1.0'/>\n";
       m_ofs << "</radialGradient>\n";
     }
     m_ofs << "</defs>\n";
   }
 }
Пример #5
0
 void SVGPainter::DrawLine(double x1, double y1, double x2, double y2)
 {
   streamsize oldprec = m_ofs.precision(1);
   m_ofs << fixed << "<line x1=\"" << x1 << "\" y1=\"" << y1 << "\" x2=\""
     << x2 << "\" y2=\"" << y2 << "\"";
   if(m_Pencolor!=m_OrigBondcolor)
     m_ofs << " stroke=" << MakeRGB(m_Pencolor);
   m_ofs << "/>\n";
   m_ofs.precision(oldprec);
 }
Пример #6
0
  void SVGPainter::NewCanvas(double width, double height)
  {
    if(m_withViewBox)
      m_ofs << "<svg width=\"" << m_width << "\" height=\"" << m_height << "\" "
            << "x=\"0\" y=\"0\" "
            << "viewBox=\"0 0 " << width << ' ' << height << "\"\n";
    else
      m_ofs << "<svg width=\"" << width << "\" height=\"" << height << "\" "
            << "x=\"0\" y=\"0\" ";

    //Bond color and width are the initial m_Pencolor and m_PenWidth
    m_ofs << "font-family=\"" << m_fontFamily << "\" stroke=" << MakeRGB(m_Pencolor)
          << "stroke-width=\"" << m_PenWidth << "\"  stroke-linecap=\"round\"" << ">\n";

    if(!m_withViewBox && m_Fillcolor.alpha!=0.0)//Background color for single molecule. Handled by outer svg when table.
      m_ofs << "<rect x=\"0%\" y=\"0%\" width=\"100%\" height=\"100%\" stroke-width=\"0\" fill="
            << MakeRGB(m_Fillcolor) << " />\n";
    m_OrigBondcolor = m_Pencolor;
  }
Пример #7
0
 void SVGPainter::DrawLine(double x1, double y1, double x2, double y2)
 {
   streamsize oldprec = m_ofs.precision(1);
   m_ofs << fixed << "<line x1=\"" << x1 << "\" y1=\"" << y1 << "\" x2=\""
     << x2 << "\" y2=\"" << y2 << "\"";
   // if(m_Pencolor!=m_OrigBondcolor) // TODO: Bring this line back once Pybel is fine with this
     m_ofs << " stroke=" << MakeRGB(m_Pencolor);
   m_ofs << " stroke-width=\"" << m_PenWidth << "\"";
   m_ofs << "/>\n";
   m_ofs.precision(oldprec);
 }
Пример #8
0
void Draw (int x1, int y1, int length) {
  Vector t1,t2,t3,t4;  
  int x2,y2;

  x2=x1+length-1;
  y2=y1+length-1;
  if (length==2) {
    Pixels+=4;
    PutPixel (x1,y1,MakeRGB (ShootRay (BuildReta (x1,y1),1.0)));
    PutPixel (x2,y1,MakeRGB (ShootRay (BuildReta (x2,y1),1.0)));
    PutPixel (x1,y2,MakeRGB (ShootRay (BuildReta (x1,y2),1.0)));
    PutPixel (x2,y2,MakeRGB (ShootRay (BuildReta (x2,y2),1.0)));
  } 
  else {
    int factor;

    t1=ShootRay (BuildReta (x1,y1),1.0);
    t2=ShootRay (BuildReta (x2,y1),1.0);
    t3=ShootRay (BuildReta (x1,y2),1.0);
    t4=ShootRay (BuildReta (x2,y2),1.0);
    if (diff (t1,t2)+diff (t2,t3)+diff (t3,t4)+diff (t4,t1)>threshold) {
      factor=length/2;
      Draw (x1,y1,factor);
      Draw (x1+factor,y1,factor);
      Draw (x1,y1+factor,factor);
      Draw (x1+factor,y1+factor,factor);
    }
    else {
      int i,j;
      double alpha,beta;
      Vector p1,p2,p3;

      Pixels+=4;
      if (interpolation) {
        alpha=1.0/double (x2-x1);
        beta=1.0/double (y2-y1);
        p1=t1;
        p2=t3;
        for (i=x1; i<=x2; i++) {
          p3=p1;        
          for (j=y1; j<=y2; j++) {
            PutPixel (i,j,MakeRGB (p3)); 
            p3+=(p2-p1)*beta;
          }
          p1+=(t2-t1)*alpha;
          p2+=(t4-t3)*alpha;
        }
      }
      else {
        int i,j;
        for (i=x1; i<=x2; i++)
          for (j=y1; j<=y2; j++)
            PutPixel (i,j,MakeRGB (t1));
      }
    }
  }
}
Пример #9
0
  void SVGPainter::DrawBall(double x, double y, double r, double opacity)
  {
    if (!isfinite(opacity))
      opacity = 1.0;
    if (opacity < 0.25)
      opacity = 0.25;

    m_ofs << "<circle cx=\"" << x << "\" cy=\"" << y << "\" r=\"" << r << "\" ";
    m_ofs << "opacity=\"" << opacity << "\" ";
    if (m_isFillcolor) {
      m_ofs << "style=\"stroke:black;fill:" << MakeRGB(m_Fillcolor) << "\"/>\n";
    } else {
      m_ofs << "style=\"stroke:black;fill:url(#radial";
      m_ofs << RGBcode(m_Gradientcolor.first)<< RGBcode(m_Gradientcolor.second) << ")\"/>\n";
    }
  }
Пример #10
0
  void SVGPainter::DrawLine(double x1, double y1, double x2, double y2, const std::vector<double>& dashes)
  {
    streamsize oldprec = m_ofs.precision(1);
    m_ofs << fixed << "<line x1=\"" << x1 << "\" y1=\"" << y1 << "\" x2=\""
      << x2 << "\" y2=\"" << y2 << "\"";
    // if(m_Pencolor!=m_OrigBondcolor) // TODO: Bring this line back once Pybel is fine with this
      m_ofs << " stroke=" << MakeRGB(m_Pencolor);
    m_ofs << " stroke-width=\"" << m_PenWidth << "\"";
    if (!dashes.empty()) {
      std::vector<double>::const_iterator it = dashes.begin();
      m_ofs << " stroke-dasharray=\"" << *it;
      for (; it!=dashes.end() ; ++it)
        m_ofs << "," << *it;
      m_ofs << "\"";

    }
    m_ofs << "/>\n";
    m_ofs.precision(oldprec);
  }
Пример #11
0
static void PaletteEffect(FrameT *frame, PaletteT *src, PaletteT *dst) {
  bool beatFlash = CountBeat(frame);
  int j = 0;

  while (src) {
    int i;

    for (i = 0; i < src->count; i++) {
      RGB col = src->colors[i];

      int r = col.r;
      int g = col.g;
      int b = col.b;

      if (beatFlash) {
        r += 64; g += 64; b += 64;
      }

      {
        int f = frame->number;

        if (f >= 25)
          f = (frame->last - frame->first) - f;

        if (f < 25) {
          r = r * f / 25;
          g = g * f / 25;
          b = b * f / 25;
        }
      }

      dst->colors[j++] = MakeRGB(r, g, b);

      if (j >= 256)
        break;
    }

    src = src->next;
  }
  
  LoadPalette(dst);
}
Пример #12
0
void CVisualizerStatic::Draw()
{
	const char STR[] = "0CC-FamiTracker";		// // //
	const size_t COUNT = std::size(STR);
	static long long t = 0;

	const auto FixRGB = [] (int x) { return MakeRGB(GetB(x), GetG(x), GetR(x)); };

	const COLORREF Back[] = {
		FixRGB(FTEnv.GetSettings()->Appearance.iColBackground),
		FixRGB(FTEnv.GetSettings()->Appearance.iColBackgroundHilite),
		FixRGB(FTEnv.GetSettings()->Appearance.iColBackgroundHilite2),
	};
	const COLORREF Color = FixRGB(FTEnv.GetSettings()->Appearance.iColPatternText);
	const COLORREF Shadow = BlendColors(Color, 1, Back[0], 2);

	for (int y = m_iHeight - 1; y >= 0; --y)
		for (int x = m_iWidth - 1; x >= 0; --x) {
			int Dist = (abs(x - m_iWidth / 2) + abs(y - m_iHeight / 2) - t / 5) % 12;
			if (Dist < 0) Dist += 12;
			m_pBlitBuffer[y * m_iWidth + x] = Back[Dist / 4];
		}

	for (size_t i = 0; i < COUNT; ++i) {
		double Phase = .07 * t - .9 * i;
		double x = sin(Phase) * 2. + m_iWidth + 11. * i - .4 * t;
		double y = sin(Phase) * 7.;
		const double MAX = m_iWidth + 120.;
		if (x < 0) {
			x = fmod(x, MAX);
			if (x < -40.) x += MAX;
		}
		DrawChar(STR[i], static_cast<int>(x) + 1, static_cast<int>(m_iHeight / 2. - 3.5 - y) + 1, Shadow);
		DrawChar(STR[i], static_cast<int>(x), static_cast<int>(m_iHeight / 2. - 3.5 - y), Color);
	}

	++t;
}