int SimpleDrawSimulate(void) { simulate = !simulate; if (simulate) cdCanvasSimulate(curCanvas, CD_SIM_ALL); else cdCanvasSimulate(curCanvas, CD_SIM_NONE); SimpleDraw(curCanvas); return 0; }
void cdCanvasRestoreState(cdCanvas* canvas, cdState* state) { assert(canvas); assert(state); if (!state || !_cdCheckCanvas(canvas)) return; /* clippling must be done in low level because origin and invert y axis */ canvas->clip_poly_n = state->clip_poly_n; if (canvas->clip_poly) { free(canvas->clip_poly); canvas->clip_poly = NULL; } if (canvas->clip_fpoly) { free(canvas->clip_fpoly); canvas->clip_fpoly = NULL; } if (state->clip_poly) { int size = state->clip_poly_n*sizeof(cdPoint); canvas->clip_poly = (cdPoint*)malloc(size); memcpy(canvas->clip_poly, state->clip_poly, size); } if (state->clip_fpoly) { int size = state->clip_poly_n*sizeof(cdfPoint); canvas->clip_fpoly = (cdfPoint*)malloc(size); memcpy(canvas->clip_fpoly, state->clip_fpoly, size); } cdCanvasClip(canvas, CD_CLIPOFF); if (canvas->clip_fpoly) canvas->cxFPoly(canvas->ctxcanvas, CD_CLIP, state->clip_fpoly, state->clip_poly_n); else if (canvas->clip_poly) canvas->cxPoly(canvas->ctxcanvas, CD_CLIP, state->clip_poly, state->clip_poly_n); cdCanvasClipArea(canvas, state->clip_rect.xmin, state->clip_rect.xmax, state->clip_rect.ymin, state->clip_rect.ymax); if (canvas->cxFClipArea) canvas->cxFClipArea(canvas->ctxcanvas, state->clip_frect.xmin, state->clip_frect.xmax, state->clip_frect.ymin, state->clip_frect.ymax); else if (canvas->cxClipArea) canvas->cxClipArea(canvas->ctxcanvas, state->clip_rect.xmin, state->clip_rect.xmax, state->clip_rect.ymin, state->clip_rect.ymax); cdCanvasClip(canvas, state->clip_mode); /* regular attributes */ cdCanvasSetBackground(canvas, state->background); cdCanvasSetForeground(canvas, state->foreground); cdCanvasBackOpacity(canvas, state->back_opacity); cdCanvasWriteMode(canvas, state->write_mode); cdCanvasLineStyle(canvas, state->line_style); cdCanvasLineWidth(canvas, state->line_width); cdCanvasLineCap(canvas, state->line_cap); cdCanvasLineJoin(canvas, state->line_join); cdCanvasFillMode(canvas, state->fill_mode); cdCanvasLineStyleDashes(canvas, state->line_dashes, state->line_dashes_count); cdCanvasHatch(canvas, state->hatch_style); if (state->stipple) cdCanvasStipple(canvas, state->stipple_w, state->stipple_h, state->stipple); if (state->pattern) cdCanvasPattern(canvas, state->pattern_w, state->pattern_h, state->pattern); cdCanvasInteriorStyle(canvas, state->interior_style); if (state->native_font[0]) cdCanvasNativeFont(canvas, state->native_font); else cdCanvasFont(canvas, state->font_type_face, state->font_style, state->font_size); cdCanvasTextAlignment(canvas, state->text_alignment); cdCanvasTextOrientation(canvas, state->text_orientation); cdCanvasMarkType(canvas, state->mark_type); cdCanvasMarkSize(canvas, state->mark_size); cdCanvasOrigin(canvas, state->origin.x, state->origin.y); if (state->use_matrix) cdCanvasTransform(canvas, state->matrix); wdCanvasWindow(canvas, state->window.xmin, state->window.xmax, state->window.ymin, state->window.ymax); wdCanvasViewport(canvas, state->viewport.xmin, state->viewport.xmax, state->viewport.ymin, state->viewport.ymax); cdCanvasSimulate(canvas, state->sim_mode); /* complex clipping regions are not saved */ /* driver internal attributes are not saved */ }