René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

Test Maxima [Ming wrapper example]

This flash movie was created with the following program.
TestMaxima.cpp
#include "SWFMovie.h"
#include <sstream>
#include <iostream>

int main() {

  int font_size=10;

  Font  verdana ("Verdana.fdb");
  int x_width  = 40;
  // TODO: wouldn't it be better to return an int from LineHeight?
  int y_height  = (int)verdana.LineHeight(font_size);

  std::cout << "y_height="<<y_height<<std::endl;

  //int nof_lines=65536 / y_height / 20;
  int nof_lines=125;
  //int nof_lines=80;
  int count_per_line=16/16;
  int movie_height=200;

  int total_height=0;
  
  Movie  movie   ("TestMaxima.swf", count_per_line*x_width, movie_height/*nof_lines*y_height*/,40);
  //Movie  movie   ("TestMaxima.swf", 100,100);
  MovieClip clip;
  movie.BackgroundColor(0xcc, 0xcc, 0xcc);

  for (int y=0; y<nof_lines; y++) {
  for (int x=0; x<count_per_line; x++) {
    std::stringstream s;
    s<< x + y*count_per_line;
    std::string val = s.str();

    // TODO: wouldn't it be better to return an int from Width?
    int width_val = (int)verdana.Width(val, font_size);

    Text txt(verdana, font_size, (x+1)*x_width-width_val, (y+1)*y_height, val, 0, 128, 255);
    clip.Add(txt);
  }
  total_height+=y_height; 
  }

  std::cout << "total_height = " << total_height << std::endl;

  clip.NextFrame();

  DisplayClip iClip = movie.Add(clip);
  movie.NextFrame();

  std::cout << "total_height-movie_height=" << (total_height-movie_height) << std::endl;

 // for (int i=0; i< total_height-movie_height-y_height*10;i+=10) 
  for (int i=0; i< (total_height-y_height); i+=5) 
  {
    iClip.MoveTo(0, -i);
    movie.NextFrame();
    std::cout << "i="<<i<<std::endl;
  }

  movie.Stop();
  movie.NextFrame();

  return 0;
}
This is one of a series of examples that demonstrates the C++ ming wrapper classes. Other examples can be found here.