示例#1
0
void ColorWheel::on_render(clan::Canvas &canvas, const clan::Rect &update_rect)
{
    get_options();

    clan::Pointf center( (float) canvas.get_width()/2.0f, (float) canvas.get_height()/2.0f);
    float radius = 200.0f;
    create_colorwheel(center, radius);

    canvas.fill_triangles(colorwheel_positions, colorwheel_colors, colorwheel_segments * 3);

    draw_labels(canvas);
}
示例#2
0
void List::draw(const Cairo::RefPtr<Cairo::Context> & cr) {
	// update the positions of the list
	arrange_nodes();

	// mark the array as unprinted
	for (int i = 0; i < currentNodes; i++) {
		nodes[i]->printed = false;
	}

	// print the head of the list
	draw_labels(cr);

	//  print the nodes in the list
	draw_connected(cr);

	// print nodes disconnected from the list
	draw_disconnected(cr);
}
示例#3
0
void draw_menu_full(void)
{
	draw_edge();
	draw_logo();
	draw_color_list();
	draw_init_size();
	draw_direction();
	draw_speed();
	draw_function();
	draw_control_buttons();
	draw_io_buttons();
	draw_size();
	draw_steps();
	draw_labels();
	wnoutrefresh(menuw);

	if (dialogw) {
		draw_dialog();
	}
}
示例#4
0
ENTRYPOINT void
draw_molecule (ModeInfo *mi)
{
  time_t now = time ((time_t *) 0);
  GLfloat speed = 4.0;  /* speed at which the zoom out/in happens */

  molecule_configuration *mc = &mcs[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);

  if (!mc->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(mc->glx_context));

  if (mc->draw_time == 0)
    {
      pick_new_molecule (mi, mc->draw_time);
      mc->draw_time = now;
    }
  else if (mc->mode == 0)
    {
      if (mc->draw_tick++ > 10)
        {
          time_t now = time((time_t *) 0);
          if (mc->draw_time == 0) mc->draw_time = now;
          mc->draw_tick = 0;

          if (!mc->button_down_p &&
              mc->nmolecules > 1 &&
              mc->draw_time + timeout <= now)
            {
              /* randomize molecules every -timeout seconds */
              mc->mode = 1;    /* go out */
              mc->mode_tick = 10 * speed;
              mc->draw_time = now;
            }
        }
    }
  else if (mc->mode == 1)   /* out */
    {
      if (--mc->mode_tick <= 0)
        {
          mc->mode_tick = 10 * speed;
          mc->mode = 2;  /* go in */
          pick_new_molecule (mi, mc->draw_time);
          mc->draw_time = now;
        }
    }
  else if (mc->mode == 2)   /* in */
    {
      if (--mc->mode_tick <= 0)
        mc->mode = 0;  /* normal */
    }
  else
    abort();

  glPushMatrix ();
  glScalef(1.1, 1.1, 1.1);

  {
    double x, y, z;
    get_position (mc->rot, &x, &y, &z, !mc->button_down_p);
    glTranslatef((x - 0.5) * 9,
                 (y - 0.5) * 9,
                 (z - 0.5) * 9);

    gltrackball_rotate (mc->trackball);

    get_rotation (mc->rot, &x, &y, &z, !mc->button_down_p);
    glRotatef (x * 360, 1.0, 0.0, 0.0);
    glRotatef (y * 360, 0.0, 1.0, 0.0);
    glRotatef (z * 360, 0.0, 0.0, 1.0);
  }

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  if (mc->mode != 0)
    {
      GLfloat s = (mc->mode == 1
                   ? mc->mode_tick / (10 * speed)
                   : ((10 * speed) - mc->mode_tick + 1) / (10 * speed));
      glScalef (s, s, s);
    }

  glPushMatrix();
  glCallList (mc->molecule_dlist);

  if (mc->mode == 0)
    {
      molecule *m = &mc->molecules[mc->which];

      draw_labels (mi);

      /* This can't go in the display list, or the characters are spaced
         wrongly when the window is resized. */
      if (do_titles && m->label && *m->label)
        {
          set_atom_color (mi, 0, True, 1);
          print_gl_string (mi->dpy, mc->xfont3, mc->font3_dlist,
                           mi->xgwa.width, mi->xgwa.height,
                           10, mi->xgwa.height - 10,
                           m->label, False);
        }
    }
  glPopMatrix();

  if (do_shells)
    {
      glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
      glPushMatrix();
      glCallList (mc->shell_dlist);
      glPopMatrix();
      glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

      glDepthFunc (GL_EQUAL);
      glEnable (GL_BLEND);
      glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glPushMatrix();
      glCallList (mc->shell_dlist);
      glPopMatrix();
      glDepthFunc (GL_LESS);
      glDisable (GL_BLEND);
    }

  glPopMatrix ();

  mi->polygon_count = mc->polygon_count;

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}
示例#5
0
static void search_contour (const Matrix& z, int x, int y, int direction)
//
// search a path
//
// current start position: (x,y)
//
//                                      0
//                                      |
//                                      |
// initial search direction:     3----(x,y)-----1         
//                                      |
//                                      |
//                                      2
//
//
{
    int way = 0;

    // final direction (neccessary to determine end condition of the search)
    final_direction = (direction+1) & 3;

    // first point 
    interpolate_start(z,x,y,final_direction);

    // find next point 
    for (;;) {

        // test if there is a way lower than this height 
        switch (direction) {
            case  0: if ((way = (cut[x-1][y] != higher))) x--; break;
            case  1: if ((way = (cut[x][y+1] != higher))) y++; break;
            case  2: if ((way = (cut[x+1][y] != higher))) x++; break;
            case  3: if ((way = (cut[x][y-1] != higher))) y--; break;
            default: Matpack.Error("ContourLine: search_contour: bad direction (%d)",
                                   direction);
        }

        if (way) { // move along this way 

            // roll off Ariadne's thread 
            cut[x][y] = thread;

            // turn counter clockwise 
            direction = (direction+1) & 3;

        } else { // compute interpolation point 

             // check if we returned to the starting point - finished
             if ( interpolate_next(z,x,y,direction) ) {
                 
                 // mark this one too - happens if there is one 
                 // singular hole with lower level inside -BAD IDEA !!!!!!!!!
                 cut[x][y] = thread;

                 // draw the contour line
                 if (opencontour) 
                   draw_open_contour(); 
                 else 
                   draw_closed_contour();

                 // draw the labels
                 draw_labels();

                 // release the circular contour list
                 release(start);
                 return;
             }

             // turn clockwise 
             direction = (direction+3) & 3;
        }
    }
}