Ejemplo n.º 1
0
static void
ellipse_save(Ellipse *ellipse, ObjectNode obj_node, const char *filename)
{
    element_save(&ellipse->element, obj_node);

    if (ellipse->border_width != 0.1)
        data_add_real(new_attribute(obj_node, "border_width"),
                      ellipse->border_width);

    if (!color_equals(&ellipse->border_color, &color_black))
        data_add_color(new_attribute(obj_node, "border_color"),
                       &ellipse->border_color);

    if (!color_equals(&ellipse->inner_color, &color_white))
        data_add_color(new_attribute(obj_node, "inner_color"),
                       &ellipse->inner_color);

    if (!ellipse->show_background)
        data_add_boolean(new_attribute(obj_node, "show_background"),
                         ellipse->show_background);

    if (ellipse->aspect != FREE_ASPECT)
        data_add_enum(new_attribute(obj_node, "aspect"),
                      ellipse->aspect);

    if (ellipse->line_style != LINESTYLE_SOLID) {
        data_add_enum(new_attribute(obj_node, "line_style"),
                      ellipse->line_style);

        if (ellipse->dashlength != DEFAULT_LINESTYLE_DASHLEN)
            data_add_real(new_attribute(obj_node, "dashlength"),
                          ellipse->dashlength);
    }
}
Ejemplo n.º 2
0
static void
beziergon_save(Beziergon *beziergon, ObjectNode obj_node,
	      const char *filename)
{
  beziershape_save(&beziergon->bezier, obj_node);

  if (!color_equals(&beziergon->line_color, &color_black))
    data_add_color(new_attribute(obj_node, "line_color"),
		   &beziergon->line_color);
  
  if (beziergon->line_width != 0.1)
    data_add_real(new_attribute(obj_node, PROP_STDNAME_LINE_WIDTH),
		  beziergon->line_width);
  
  if (!color_equals(&beziergon->inner_color, &color_white))
    data_add_color(new_attribute(obj_node, "inner_color"),
		   &beziergon->inner_color);
  
  data_add_boolean(new_attribute(obj_node, "show_background"),
		   beziergon->show_background);

  if (beziergon->line_style != LINESTYLE_SOLID)
    data_add_enum(new_attribute(obj_node, "line_style"),
		  beziergon->line_style);

  if (beziergon->line_style != LINESTYLE_SOLID &&
      beziergon->dashlength != DEFAULT_LINESTYLE_DASHLEN)
    data_add_real(new_attribute(obj_node, "dashlength"),
		  beziergon->dashlength);
  
  if (beziergon->line_join != LINEJOIN_MITER)
    data_add_enum(new_attribute(obj_node, "line_join"),
                  beziergon->line_join);

}
Ejemplo n.º 3
0
Archivo: bezier.c Proyecto: GNOME/dia
static void
bezierline_save(Bezierline *bezierline, ObjectNode obj_node,
	        DiaContext *ctx)
{
  if (connpoint_is_autogap(bezierline->bez.object.handles[0]->connected_to) ||
      connpoint_is_autogap(bezierline->bez.object.handles[3*(bezierline->bez.bezier.num_points-1)]->connected_to) ||
      bezierline->absolute_start_gap || bezierline->absolute_end_gap) {
    Point gap_points[4];
    compute_gap_points(bezierline, gap_points);
    exchange_bez_gap_points(&bezierline->bez,gap_points);
    bezierconn_update_boundingbox(&bezierline->bez);
    exchange_bez_gap_points(&bezierline->bez,gap_points);
  }
  bezierconn_save(&bezierline->bez, obj_node, ctx);

  if (!color_equals(&bezierline->line_color, &color_black))
    data_add_color(new_attribute(obj_node, "line_color"),
		   &bezierline->line_color, ctx);

  if (bezierline->line_width != 0.1)
    data_add_real(new_attribute(obj_node, PROP_STDNAME_LINE_WIDTH),
		  bezierline->line_width, ctx);

  if (bezierline->line_style != LINESTYLE_SOLID)
    data_add_enum(new_attribute(obj_node, "line_style"),
		  bezierline->line_style, ctx);

  if (bezierline->line_style != LINESTYLE_SOLID &&
      bezierline->dashlength != DEFAULT_LINESTYLE_DASHLEN)
    data_add_real(new_attribute(obj_node, "dashlength"),
		  bezierline->dashlength, ctx);

  if (bezierline->line_join != LINEJOIN_MITER)
    data_add_enum(new_attribute(obj_node, "line_join"),
                  bezierline->line_join, ctx);
  if (bezierline->line_caps != LINECAPS_BUTT)
    data_add_enum(new_attribute(obj_node, "line_caps"),
                  bezierline->line_caps, ctx);

  if (bezierline->start_arrow.type != ARROW_NONE) {
    save_arrow(obj_node, &bezierline->start_arrow, "start_arrow",
	     "start_arrow_length", "start_arrow_width", ctx);
  }

  if (bezierline->end_arrow.type != ARROW_NONE) {
    save_arrow(obj_node, &bezierline->end_arrow, "end_arrow",
	     "end_arrow_length", "end_arrow_width", ctx);
  }

  if (bezierline->absolute_start_gap)
    data_add_real(new_attribute(obj_node, "absolute_start_gap"),
                 bezierline->absolute_start_gap, ctx);
  if (bezierline->absolute_end_gap)
    data_add_real(new_attribute(obj_node, "absolute_end_gap"),
                 bezierline->absolute_end_gap, ctx);
}
Ejemplo n.º 4
0
static void
image_save(EImage *image, ObjectNode obj_node, const char *filename)
{
  char *diafile_dir;
  
  element_save(&image->element, obj_node);

  if (image->border_width != 0.1)
    data_add_real(new_attribute(obj_node, "border_width"),
		  image->border_width);
  
  if (!color_equals(&image->border_color, &color_black))
    data_add_color(new_attribute(obj_node, "border_color"),
		   &image->border_color);
  
  if (image->line_style != LINESTYLE_SOLID)
    data_add_enum(new_attribute(obj_node, "line_style"),
		  image->line_style);

  if (image->line_style != LINESTYLE_SOLID &&
      image->dashlength != DEFAULT_LINESTYLE_DASHLEN)
    data_add_real(new_attribute(obj_node, "dashlength"),
		  image->dashlength);
  
  data_add_boolean(new_attribute(obj_node, "draw_border"), image->draw_border);
  data_add_boolean(new_attribute(obj_node, "keep_aspect"), image->keep_aspect);
  data_add_boolean(new_attribute(obj_node, "keep_orig_aspect"), image->keep_orig_aspect);

  data_add_string(new_attribute(obj_node, "embed_id"),
		dtree_conv_longname_to_xml(image->embed_id));

  if (image->file != NULL) {
    if (g_path_is_absolute(image->file)) { /* Absolute pathname */
      diafile_dir = get_directory(filename);

      if (strncmp(diafile_dir, image->file, strlen(diafile_dir))==0) {
	/* The image pathname has the dia file pathname in the begining */
	/* Save the relative path: */
	data_add_filename(new_attribute(obj_node, "file"), image->file + strlen(diafile_dir) + 1);
      } else {
	/* Save the absolute path: */
	data_add_filename(new_attribute(obj_node, "file"), image->file);
      }
      
      g_free(diafile_dir);
      
    } else {
      /* Relative path. Must be an erronous filename...
	 Just save the filename. */
      data_add_filename(new_attribute(obj_node, "file"), image->file);
    }
    
  }
}
Ejemplo n.º 5
0
static void
box_save(Box *box, ObjectNode obj_node, const char *filename)
{
  element_save(&box->element, obj_node);

  if (box->border_width != 0.1)
    data_add_real(new_attribute(obj_node, "border_width"),
		  box->border_width);
  
  if (!color_equals(&box->border_color, &color_black))
    data_add_color(new_attribute(obj_node, "border_color"),
		   &box->border_color);
   
  if (!color_equals(&box->inner_color, &color_white))
    data_add_color(new_attribute(obj_node, "inner_color"),
		   &box->inner_color);
  
  data_add_boolean(new_attribute(obj_node, "show_background"), 
                   box->show_background);

  if (box->line_style != LINESTYLE_SOLID)
    data_add_enum(new_attribute(obj_node, "line_style"),
		  box->line_style);
  
  if (box->line_style != LINESTYLE_SOLID &&
      box->dashlength != DEFAULT_LINESTYLE_DASHLEN)
    data_add_real(new_attribute(obj_node, "dashlength"),
                  box->dashlength);
  if (box->corner_radius > 0.0)
    data_add_real(new_attribute(obj_node, "corner_radius"),
		  box->corner_radius);

  data_add_real(new_attribute(obj_node, "padding"), box->padding);
  
  data_add_text(new_attribute(obj_node, "text"), box->text);

  if (box->text_fitting != TEXTFIT_WHEN_NEEDED)
    data_add_enum(new_attribute(obj_node, PROP_STDNAME_TEXT_FITTING),
		  box->text_fitting);
}
Ejemplo n.º 6
0
static void
box_save(Box *box, ObjectNode obj_node, const char *filename)
{
  element_save(&box->element, obj_node);

  if (box->border_width != 0.1)
    data_add_real(new_attribute(obj_node, "border_width"),
		  box->border_width);
  
  if (!color_equals(&box->border_color, &color_black))
    data_add_color(new_attribute(obj_node, "border_color"),
		   &box->border_color);
  
  if (!color_equals(&box->inner_color, &color_white))
    data_add_color(new_attribute(obj_node, "inner_color"),
		   &box->inner_color);
  
  data_add_boolean(new_attribute(obj_node, "show_background"), box->show_background);

  if (box->line_style != LINESTYLE_SOLID)
    data_add_enum(new_attribute(obj_node, "line_style"),
		  box->line_style);
  
  if (box->line_style != LINESTYLE_SOLID &&
      box->dashlength != DEFAULT_LINESTYLE_DASHLEN)
    data_add_real(new_attribute(obj_node, "dashlength"),
                  box->dashlength);

  if (box->line_join != LINEJOIN_MITER)
    data_add_enum(new_attribute(obj_node, "line_join"),
		  box->line_join);

  if (box->corner_radius > 0.0)
    data_add_real(new_attribute(obj_node, "corner_radius"),
		  box->corner_radius);

  if (box->aspect != FREE_ASPECT)
    data_add_enum(new_attribute(obj_node, "aspect"),
		  box->aspect);
}
Ejemplo n.º 7
0
static void
polyline_save(Polyline *polyline, ObjectNode obj_node,
	      DiaContext *ctx)
{
  polyconn_save(&polyline->poly, obj_node, ctx);

  if (!color_equals(&polyline->line_color, &color_black))
    data_add_color(new_attribute(obj_node, "line_color"),
		   &polyline->line_color, ctx);

  if (polyline->line_width != 0.1)
    data_add_real(new_attribute(obj_node, PROP_STDNAME_LINE_WIDTH),
		  polyline->line_width, ctx);
  
  if (polyline->line_style != LINESTYLE_SOLID)
    data_add_enum(new_attribute(obj_node, "line_style"),
		  polyline->line_style, ctx);

  if (polyline->line_style != LINESTYLE_SOLID &&
      polyline->dashlength != DEFAULT_LINESTYLE_DASHLEN)
    data_add_real(new_attribute(obj_node, "dashlength"),
		  polyline->dashlength, ctx);

  if (polyline->line_join != LINEJOIN_MITER)
    data_add_enum(new_attribute(obj_node, "line_join"),
                  polyline->line_join, ctx);
  if (polyline->line_caps != LINECAPS_BUTT)
    data_add_enum(new_attribute(obj_node, "line_caps"),
                  polyline->line_caps, ctx);

  if (polyline->start_arrow.type != ARROW_NONE) {
    save_arrow(obj_node, &polyline->start_arrow, "start_arrow",
	     "start_arrow_length", "start_arrow_width", ctx);
  }

  if (polyline->end_arrow.type != ARROW_NONE) {
    save_arrow(obj_node, &polyline->end_arrow, "end_arrow",
	     "end_arrow_length", "end_arrow_width", ctx);
  }

  if (polyline->absolute_start_gap)
    data_add_real(new_attribute(obj_node, "absolute_start_gap"),
                 polyline->absolute_start_gap, ctx);
  if (polyline->absolute_end_gap)
    data_add_real(new_attribute(obj_node, "absolute_end_gap"),
                 polyline->absolute_end_gap, ctx);

  if (polyline->corner_radius > 0.0)
    data_add_real(new_attribute(obj_node, "corner_radius"),
                  polyline->corner_radius, ctx);
}
Ejemplo n.º 8
0
int main(int argc, char **argv) {

	int ch,i=0,j,end=3;

	grsim_init();

	gr();
	clear_screens();

	while(1) {

		/* clear old colors */
		for(j=0;j<40;j++) row_color[j]=0;

		gr();

		set_row_color(i+0,14);	// aqua
		set_row_color(i+1,6);		// med-blue
		set_row_color(i+2,12);	// light-green
		set_row_color(i+3,4);		// green
		set_row_color(i+4,13);	// yellow
		set_row_color(i+5,9);		// orange
		set_row_color(i+6,11);	// pink
		set_row_color(i+7,1);		// red

		for(j=0;j<40;j++) {
			if (row_color[j]) {
				color_equals(row_color[j]);
				hlin(0,0,40,j);
			}
		}

		grsim_update();

		ch=grsim_input();
		if (ch=='q') exit(0);
		usleep(100000);

		i++;
		if (i>(ELEMENTS-1)) {
			i=0;
			end--;
			if (end==0) break;
		}

//		printf("\n");
	}

	return 0;
}
Ejemplo n.º 9
0
static void
ellipse_save(Ellipse *ellipse, ObjectNode obj_node, DiaContext *ctx)
{
  element_save(&ellipse->element, obj_node, ctx);

  if (ellipse->border_width != 0.1)
    data_add_real(new_attribute(obj_node, "border_width"),
		  ellipse->border_width, ctx);

  if (!color_equals(&ellipse->border_color, &color_black))
    data_add_color(new_attribute(obj_node, "border_color"),
		   &ellipse->border_color, ctx);

  if (!color_equals(&ellipse->inner_color, &color_white))
    data_add_color(new_attribute(obj_node, "inner_color"),
		   &ellipse->inner_color, ctx);

  data_add_boolean(new_attribute(obj_node, "show_background"),
		   ellipse->show_background, ctx);

  if (ellipse->line_style != LINESTYLE_SOLID)
    data_add_enum(new_attribute(obj_node, "line_style"),
		  ellipse->line_style, ctx);

  if (ellipse->line_style != LINESTYLE_SOLID &&
      ellipse->dashlength != DEFAULT_LINESTYLE_DASHLEN)
    data_add_real(new_attribute(obj_node, "dashlength"),
                  ellipse->dashlength, ctx);

  data_add_real(new_attribute(obj_node, "padding"), ellipse->padding, ctx);

  data_add_text(new_attribute(obj_node, "text"), ellipse->text, ctx);

  if (ellipse->text_fitting != TEXTFIT_WHEN_NEEDED)
    data_add_enum(new_attribute(obj_node, PROP_STDNAME_TEXT_FITTING),
		  ellipse->text_fitting, ctx);
}
Ejemplo n.º 10
0
Archivo: line.c Proyecto: mpuels/dia
static void
line_save(Line *line, ObjectNode obj_node, DiaContext *ctx)
{
#ifdef DEBUG
  dia_object_sanity_check((DiaObject*)line, "Saving line");
#endif

  connection_save(&line->connection, obj_node, ctx);

  connpointline_save(line->cpl, obj_node, "numcp", ctx);

  if (!color_equals(&line->line_color, &color_black))
    data_add_color(new_attribute(obj_node, "line_color"),
		   &line->line_color, ctx);

  if (line->line_width != 0.1)
    data_add_real(new_attribute(obj_node, PROP_STDNAME_LINE_WIDTH),
		  line->line_width, ctx);

  if (line->line_style != LINESTYLE_SOLID)
    data_add_enum(new_attribute(obj_node, "line_style"),
		  line->line_style, ctx);

  if (line->line_caps != LINECAPS_BUTT)
    data_add_enum(new_attribute(obj_node, "line_caps"),
                  line->line_caps, ctx);

  if (line->start_arrow.type != ARROW_NONE) {
    save_arrow(obj_node, &line->start_arrow,
	       "start_arrow", "start_arrow_length", "start_arrow_width", ctx);
  }

  if (line->end_arrow.type != ARROW_NONE) {
    save_arrow(obj_node, &line->end_arrow,
	       "end_arrow", "end_arrow_length", "end_arrow_width", ctx);
  }

  if (line->absolute_start_gap)
    data_add_real(new_attribute(obj_node, "absolute_start_gap"),
                 line->absolute_start_gap, ctx);
  if (line->absolute_end_gap)
    data_add_real(new_attribute(obj_node, "absolute_end_gap"),
                 line->absolute_end_gap, ctx);

  if (line->line_style != LINESTYLE_SOLID && line->dashlength != DEFAULT_LINESTYLE_DASHLEN)
    data_add_real(new_attribute(obj_node, "dashlength"),
		  line->dashlength, ctx);
}
Ejemplo n.º 11
0
void
lazy_setcolor(DiaPsRenderer *renderer,
              Color *color)
{
  gchar r_buf[DTOSTR_BUF_SIZE];
  gchar g_buf[DTOSTR_BUF_SIZE];
  gchar b_buf[DTOSTR_BUF_SIZE];

  if (!color_equals(color, &(renderer->lcolor))) {
    renderer->lcolor = *color;
    fprintf(renderer->file, "%s %s %s srgb\n",
            psrenderer_dtostr(r_buf, (gdouble) color->red),
            psrenderer_dtostr(g_buf, (gdouble) color->green),
            psrenderer_dtostr(b_buf, (gdouble) color->blue) );    
  }
}
Ejemplo n.º 12
0
static void
zigzagline_save(Zigzagline *zigzagline, ObjectNode obj_node,
		const char *filename)
{
  orthconn_save(&zigzagline->orth, obj_node);

  if (!color_equals(&zigzagline->line_color, &color_black))
    data_add_color(new_attribute(obj_node, "line_color"),
		   &zigzagline->line_color);
  
  if (zigzagline->line_width != 0.1)
    data_add_real(new_attribute(obj_node, PROP_STDNAME_LINE_WIDTH),
		  zigzagline->line_width);
  
  if (zigzagline->line_style != LINESTYLE_SOLID)
    data_add_enum(new_attribute(obj_node, "line_style"),
		  zigzagline->line_style);
  
  if (zigzagline->line_join != LINEJOIN_MITER)
    data_add_enum(new_attribute(obj_node, "line_join"),
                  zigzagline->line_join);
  if (zigzagline->line_caps != LINECAPS_BUTT)
    data_add_enum(new_attribute(obj_node, "line_caps"),
                  zigzagline->line_caps);

  if (zigzagline->start_arrow.type != ARROW_NONE) {
    save_arrow(obj_node, &zigzagline->start_arrow, "start_arrow",
	     "start_arrow_length", "start_arrow_width");
  }

  if (zigzagline->end_arrow.type != ARROW_NONE) {
    save_arrow(obj_node, &zigzagline->end_arrow, "end_arrow",
	     "end_arrow_length", "end_arrow_width");
  }

  if (zigzagline->line_style != LINESTYLE_SOLID && 
      zigzagline->dashlength != DEFAULT_LINESTYLE_DASHLEN)
    data_add_real(new_attribute(obj_node, "dashlength"),
                  zigzagline->dashlength);

  if (zigzagline->corner_radius > 0.0)
    data_add_real(new_attribute(obj_node, "corner_radius"),
                  zigzagline->corner_radius);
}
Ejemplo n.º 13
0
static void
arc_save(Arc *arc, ObjectNode obj_node, const char *filename)
{
  connection_save(&arc->connection, obj_node);

  if (!color_equals(&arc->arc_color, &color_black))
    data_add_color(new_attribute(obj_node, "arc_color"),
		   &arc->arc_color);
  
  if (arc->curve_distance != 0.1)
    data_add_real(new_attribute(obj_node, "curve_distance"),
		  arc->curve_distance);
  
  if (arc->line_width != 0.1)
    data_add_real(new_attribute(obj_node, "line_width"),
		  arc->line_width);
  
  if (arc->line_style != LINESTYLE_SOLID)
    data_add_enum(new_attribute(obj_node, "line_style"),
		  arc->line_style);

  if (arc->line_style != LINESTYLE_SOLID &&
      arc->dashlength != DEFAULT_LINESTYLE_DASHLEN)
    data_add_real(new_attribute(obj_node, "dashlength"),
		  arc->dashlength);
  
  if (arc->start_arrow.type != ARROW_NONE) {
    data_add_enum(new_attribute(obj_node, "start_arrow"),
		  arc->start_arrow.type);
    data_add_real(new_attribute(obj_node, "start_arrow_length"),
		  arc->start_arrow.length);
    data_add_real(new_attribute(obj_node, "start_arrow_width"),
		  arc->start_arrow.width);
  }
  if (arc->end_arrow.type != ARROW_NONE) {
    data_add_enum(new_attribute(obj_node, "end_arrow"),
		  arc->end_arrow.type);
    data_add_real(new_attribute(obj_node, "end_arrow_length"),
		  arc->end_arrow.length);
    data_add_real(new_attribute(obj_node, "end_arrow_width"),
		  arc->end_arrow.width);
  }
}
Ejemplo n.º 14
0
int player_select(void) {

	int which_player=0;
	int ch,saved;

	saved=ram[DRAW_PAGE];
	ram[DRAW_PAGE]=8;
	clear_top_a(0);
	ram[DRAW_PAGE]=saved;

	while(1) {

		gr_copy_to_current(0xc00);

		color_equals(COLOR_AQUA);
		vlin(6+(which_player*16),22+(which_player*16),15);
		vlin(6+(which_player*16),22+(which_player*16),22);

		grsim_put_sprite(tfv_walk_right,17,8);

		grsim_put_sprite(tfg_walk_right,17,24);

		ram[CH]=13;
		ram[CV]=21;
		move_and_print("SELECT PLAYER");

		page_flip();

		ch=grsim_input();
		if (ch==13) break;

		if ((ch==APPLE_UP) || (ch==APPLE_DOWN) ||
			(ch==APPLE_RIGHT) || (ch==APPLE_LEFT)) {
			which_player=!which_player;
		}

		usleep(100000);

	}

	return which_player;
}
Ejemplo n.º 15
0
static void
bezierline_save(Bezierline *bezierline, ObjectNode obj_node,
                const char *filename)
{
    bezierconn_save(&bezierline->bez, obj_node);

    if (!color_equals(&bezierline->line_color, &color_black))
        data_add_color(new_attribute(obj_node, "line_color"),
                       &bezierline->line_color);

    if (bezierline->line_width != 0.1)
        data_add_real(new_attribute(obj_node, "line_width"),
                      bezierline->line_width);

    if (bezierline->line_style != LINESTYLE_SOLID)
        data_add_enum(new_attribute(obj_node, "line_style"),
                      bezierline->line_style);

    if (bezierline->line_style != LINESTYLE_SOLID &&
            bezierline->dashlength != DEFAULT_LINESTYLE_DASHLEN)
        data_add_real(new_attribute(obj_node, "dashlength"),
                      bezierline->dashlength);

    if (bezierline->start_arrow.type != ARROW_NONE) {
        data_add_enum(new_attribute(obj_node, "start_arrow"),
                      bezierline->start_arrow.type);
        data_add_real(new_attribute(obj_node, "start_arrow_length"),
                      bezierline->start_arrow.length);
        data_add_real(new_attribute(obj_node, "start_arrow_width"),
                      bezierline->start_arrow.width);
    }

    if (bezierline->end_arrow.type != ARROW_NONE) {
        data_add_enum(new_attribute(obj_node, "end_arrow"),
                      bezierline->end_arrow.type);
        data_add_real(new_attribute(obj_node, "end_arrow_length"),
                      bezierline->end_arrow.length);
        data_add_real(new_attribute(obj_node, "end_arrow_width"),
                      bezierline->end_arrow.width);
    }
}
Ejemplo n.º 16
0
Archivo: arc.c Proyecto: mpuels/dia
static void
arc_save(Arc *arc, ObjectNode obj_node, DiaContext *ctx)
{
  connection_save(&arc->connection, obj_node, ctx);

  if (!color_equals(&arc->arc_color, &color_black))
    data_add_color(new_attribute(obj_node, "arc_color"),
		   &arc->arc_color, ctx);

  if (arc->curve_distance != 0.1)
    data_add_real(new_attribute(obj_node, "curve_distance"),
		  arc->curve_distance, ctx);

  if (arc->line_width != 0.1)
    data_add_real(new_attribute(obj_node, PROP_STDNAME_LINE_WIDTH),
		  arc->line_width, ctx);

  if (arc->line_style != LINESTYLE_SOLID)
    data_add_enum(new_attribute(obj_node, "line_style"),
		  arc->line_style, ctx);

  if (arc->line_style != LINESTYLE_SOLID &&
      arc->dashlength != DEFAULT_LINESTYLE_DASHLEN)
    data_add_real(new_attribute(obj_node, "dashlength"),
		  arc->dashlength, ctx);

  if (arc->line_caps != LINECAPS_BUTT)
    data_add_enum(new_attribute(obj_node, "line_caps"),
                  arc->line_caps, ctx);

  if (arc->start_arrow.type != ARROW_NONE) {
    save_arrow(obj_node, &arc->start_arrow, "start_arrow",
	     "start_arrow_length", "start_arrow_width", ctx);
  }

  if (arc->end_arrow.type != ARROW_NONE) {
    save_arrow(obj_node, &arc->end_arrow, "end_arrow",
	     "end_arrow_length", "end_arrow_width", ctx);
  }
}
Ejemplo n.º 17
0
static void
image_save(Image *image, ObjectNode obj_node, const char *filename)
{
  char *diafile_dir;
  
  element_save(&image->element, obj_node);

  if (image->border_width != 0.1)
    data_add_real(new_attribute(obj_node, "border_width"),
		  image->border_width);
  
  if (!color_equals(&image->border_color, &color_black))
    data_add_color(new_attribute(obj_node, "border_color"),
		   &image->border_color);
  
  if (image->line_style != LINESTYLE_SOLID)
    data_add_enum(new_attribute(obj_node, "line_style"),
		  image->line_style);

  if (image->line_style != LINESTYLE_SOLID &&
      image->dashlength != DEFAULT_LINESTYLE_DASHLEN)
    data_add_real(new_attribute(obj_node, "dashlength"),
		  image->dashlength);
  
  data_add_boolean(new_attribute(obj_node, "draw_border"), image->draw_border);
  data_add_boolean(new_attribute(obj_node, "keep_aspect"), image->keep_aspect);

  if (image->file != NULL) {
    if (g_path_is_absolute(image->file)) { /* Absolute pathname */
      diafile_dir = get_directory(filename);

      if (strncmp(diafile_dir, image->file, strlen(diafile_dir))==0) {
	/* The image pathname has the dia file pathname in the begining */
	/* Save the relative path: */
	data_add_filename(new_attribute(obj_node, "file"), image->file + strlen(diafile_dir) + 1);
      } else {
	/* Save the absolute path: */
	data_add_filename(new_attribute(obj_node, "file"), image->file);
      }
      
      g_free(diafile_dir);
      
    } else {
      /* Relative path. Must be an erronous filename...
	 Just save the filename. */
      data_add_filename(new_attribute(obj_node, "file"), image->file);
    }
    
  }
  /* only save image_data inline if told to do so */
  if (image->inline_data) {
    GdkPixbuf *pixbuf;
    data_add_boolean (new_attribute(obj_node, "inline_data"), image->inline_data);

    /* just to be sure to get the currently visible */
    pixbuf = (GdkPixbuf *)dia_image_pixbuf (image->image);
    if (pixbuf != image->pixbuf && image->pixbuf != NULL)
      message_warning (_("Inconsistent pixbuf during image save."));
    if (pixbuf)
      data_add_pixbuf (new_attribute(obj_node, "pixbuf"), pixbuf);
  }
}
Ejemplo n.º 18
0
int main(int argc, char **argv) {

	int xx,yy,ch,i;
	double theta,delta=0.0;


	grsim_init();
	gr();

//	clear_screens();

	ram[DRAW_PAGE]=PAGE0;
	clear_bottom();
	ram[DRAW_PAGE]=PAGE1;
	clear_bottom();
	ram[DRAW_PAGE]=PAGE2;
	clear_bottom();


//	clear_bottom(PAGE0);
//	clear_bottom(PAGE1);
//	clear_bottom(PAGE2);

//	grsim_unrle(demo_rle,0x400);
//	grsim_unrle(demo_rle,0xc00);

//	gr_copy_to_current(0xc00);
//	page_flip();
//	gr_copy_to_current(0xc00);
//	page_flip();

	ram[DRAW_PAGE]=PAGE0;

	while(1) {

		ch=repeat_until_keypressed();
		if (ch=='q') break;

		clear_top();

		for(theta=0;theta<360.0;theta+=STEP) {
			xx=cos(d2r(theta+delta))*SCALE+20;
			yy=sin(d2r(theta+delta))*SCALE*1.33+24;

#if 1
			color_equals(15);
			plot(xx,yy);

			if (xx<20) {
				color_equals(1);
				for(i=xx;i<(20-xx)+20;i++) {
					plot(i,yy);
				}
			}
			else {
				color_equals(2);
				for(i=xx;i<40;i++) {
					plot(i,yy);
				}
			}

#endif

#if 0
			color_equals(4);
			plot(xx,yy);
			if (xx>20) {
				for(i=xx;i<40;i++) {
					plot(i,yy);
				}
			}
#endif
#if 0

			color_equals(4);
//			plot(xx,yy);
			if (xx<20) {
				for(i=xx;i<40;i++) {
					plot(i,yy);
				}
			}
#endif

		}
		delta+=DELTA;

		grsim_update();

	}


	return 0;
}
Ejemplo n.º 19
0
void draw_background_mode7(void) {


	int map_color;

	over_water=0;

	/* Draw Sky */
	/* Originally wanted to be fancy and have sun too, but no */
	color_equals(COLOR_MEDIUMBLUE);
	for(screen_y=0;screen_y<6;screen_y+=2) {
		hlin_double(ram[DRAW_PAGE], 0, 40, screen_y);
	}

	/* Draw hazy horizon */
	color_equals(COLOR_GREY);
	hlin_double(ram[DRAW_PAGE], 0, 40, 6);

//	fixed_to_double(&space_z,&double_space_z);
//	double_factor=double_space_z*double_BETA;

	fixed_mul(&space_z,&BETA,&factor,0);

	if (!displayed) {
		printf("SPACEZ/BETA/FACTOR %x %x * %x %x = %x %x\n",
			space_z.i,space_z.f,BETA.i,BETA.f,factor.i,factor.f);
	}

//	printf("spacez=%lf beta=%lf factor=%lf\n",
//		fixed_to_double(&space_z),
//		fixed_to_double(&BETA),
//		fixed_to_double(&factor));

	for (screen_y = 8; screen_y < LOWRES_H; screen_y+=2) {

		// then calculate the horizontal scale, or the distance between
		// space points on this horizontal line
//		double_horizontal_scale = double_space_z  / (screen_y + horizon);
//		double_to_fixed(double_horizontal_scale,&horizontal_scale);
		horizontal_scale.i=0;
		horizontal_scale.f=
			horizontal_lookup[space_z.i&0xf][(screen_y-8)/2];

		if (!displayed) {
			printf("HORIZ_SCALE %x %x\n",
			horizontal_scale.i,horizontal_scale.f);
		}

		// calculate the distance of the line we are drawing
		fixed_mul(&horizontal_scale,&scale,&distance,0);
		//fixed_to_double(&distance,&double_distance);

//		printf("Distance=%lf, horizontal-scale=%lf\n",
//			distance,horizontal_scale);


		if (!displayed) {
			printf("DISTANCE %x:%x\n",
			distance.i,distance.f);
		}

		// calculate the dx and dy of points in space when we step
		// through all points on this line
		dx.i=fixed_sin[(angle+8)&0xf].i;	// -sin()
		dx.f=fixed_sin[(angle+8)&0xf].f;	// -sin()
		fixed_mul(&dx,&horizontal_scale,&dx,0);

		if (!displayed) {
			printf("DX %x:%x\n",
			dx.i,dx.f);
		}


		dy.i=fixed_sin[(angle+4)&0xf].i;	// cos()
		dy.f=fixed_sin[(angle+4)&0xf].f;	// cos()
		fixed_mul(&dy,&horizontal_scale,&dy,0);

		if (!displayed) {
			printf("DY %x:%x\n",
			dy.i,dy.f);
		}

		// calculate the starting position
		//double_space_x =(double_distance+double_factor);
		fixed_add(&distance,&factor,&space_x);
//		double_to_fixed(double_space_x,&space_x);
		fixed_temp.i=fixed_sin[(angle+4)&0xf].i; // cos
		fixed_temp.f=fixed_sin[(angle+4)&0xf].f; // cos
		fixed_mul(&space_x,&fixed_temp,&space_x,0);
		fixed_add(&space_x,&cx,&space_x);
		fixed_temp.i=0xec;	// -20 (LOWRES_W/2)
		fixed_temp.f=0;
		fixed_mul(&fixed_temp,&dx,&fixed_temp,0);
		fixed_add(&space_x,&fixed_temp,&space_x);

		if (!displayed) {
			printf("SPACEX! %x:%x\n",
			space_x.i,space_x.f);
		}

		fixed_add(&distance,&factor,&space_y);
//		double_space_y =(double_distance+double_factor);
//		double_to_fixed(double_space_y,&space_y);
		fixed_temp.i=fixed_sin[angle&0xf].i;
		fixed_temp.f=fixed_sin[angle&0xf].f;
		fixed_mul(&space_y,&fixed_temp,&space_y,0);
		fixed_add(&space_y,&cy,&space_y);
		fixed_temp.i=0xec;	// -20 (LOWRES_W/2)
		fixed_temp.f=0;
		fixed_mul(&fixed_temp,&dy,&fixed_temp,0);
		fixed_add(&space_y,&fixed_temp,&space_y);

		if (!displayed) {
			printf("SPACEY! %x:%x\n",
			space_y.i,space_y.f);
		}

		// go through all points in this screen line
		for (screen_x = 0; screen_x < LOWRES_W-1; screen_x++) {
			// get a pixel from the tile and put it on the screen

			map_color=lookup_map(space_x.i,space_y.i);

			ram[COLOR]=map_color;
			ram[COLOR]|=map_color<<4;

			if ((screen_x==20) && (screen_y==38)) {
				if (map_color==COLOR_DARKBLUE) over_water=1;
			}

			hlin_double(ram[DRAW_PAGE], screen_x, screen_x+1,
				screen_y);

			// advance to the next position in space
			fixed_add(&space_x,&dx,&space_x);
			fixed_add(&space_y,&dy,&space_y);
		}
	}
	displayed=1;
}