.. highlightlang:: us .. index:: g_graph .. _g_graph: g_graph ================ Create and close ^^^^^^^^^^^^^^^^^^^^^^^^ .. index:: g_create .. _g_create: g_create -------------- .. us.tag g_create NOTREADYENGLISH New5900 g_graph :ref:`g_create` creates a UniPlot vector graphic meta file in memory. The graphic is saved in a drawing object or dataset with :ref:`g_close`. It is plotted and saved with the object. .. function:: ctx = g_create(hObject) :: def _g_helper_new_text_doc(ssTitle, _rangeX, _rangeY) { if (nargsin() == 1) { rangeX = [0,3,1]; rangeY = [0,3,1]; } else { rangeX = _rangeX; rangeY = _rangeY; } hDoc = DocCreate(); hPage = PageCreate(); hLayer = LayerCreate(); LayerSetAxisMinMaxDelta(hLayer, "x", rangeX); LayerSetAxisMinMaxDelta(hLayer, "y", rangeY); LayerSetAxisTitle(hLayer, "x", ""); LayerSetAxisTitle(hLayer, "y", ""); PageAddLayer(hPage, hLayer) DocAddPage(hDoc, hPage); PageSetTitle(hPage, ssTitle+";0.6"); hText = TBCreate() rv = OBJGetPosSize(hLayer) OBJSetPosSize(hText, [rv[1], rv[2], 1, 1]) TBSetText(hText, ""); LayerAddObjects(hLayer, hText); return hText; } def test_g_create() { hText = _g_helper_new_text_doc("g_graph_1"); ctx = g_create(hText); g_set_transformation(ctx, "WC"); g_set_line_width(ctx, 50); g_set_source_rgb(ctx, [127, 0,255,0]) g_move_to(ctx, 0.5, 0.5); g_line_to(ctx, 2.5, 2.5); g_close(ctx); } .. image:: S:/uniplot-obj/images/g_graph_1.* .. ------------------------------------------------------------------------------ .. index:: g_close .. _g_close: g_close ------------------ .. us.tag g_close NOTREADYENGLISH New5900 g_graph :ref:`g_close` closes a UniPlot graphic meta fle and copies the bits into the obect specified with :ref:`g_create`. .. function:: r = g_close(ctx) .. ------------------------------------------------------------------------------ .. index:: g_set_transformation .. _g_set_transformation: g_set_transformation --------------------- .. us.tag g_set_transformation NOTREADYENGLISH New5900 g_graph :ref:`g_set_transformation` sets a transformation to world coordinaes or centimeter coordinates (*ssType* is "WC" or CM"). .. function:: r = g_set_transformation(ctx, ssType) .. ------------------------------------------------------------------------------ Linien und Fächen ^^^^^^^^^^^^^^^^^^^^^^ .. index:: g_move_to .. _g_move_to: g_move_to -------------- .. us.tag g_move_to NOTREADYENGLISH New5900 g_graph :ref:`g_move_to` sets the drawing pen to the specified position. .. function:: r = g_move_to(ctx, x, y) .. ------------------------------------------------------------------------------ .. index:: g_line_to .. _g_line_to: g_line_to -------------- .. us.tag g_line_to NOTREADYENGLISH New5900 g_graph :ref:`g_line_to` adds a line to the active path starting from the current position to the specified coordinates. .. function:: r = g_line_to(ctx, x, y) .. ------------------------------------------------------------------------------ .. index:: g_polyline .. _g_polyline: g_polyline ------------------ .. us.tag g_polyline NOTREADYENGLISH New5900 g_graph :ref:`g_polyline` adds lines to the active path. .. function:: r = g_polyline(ctx, rvX, rvY) :: def test_g_polyline() { hText = _g_helper_new_text_doc("g_polyline", [0,2*PI, 2*PI/10], [-1,1,0.5]); ctx = g_create(hText); g_set_transformation(ctx, "WC"); n = 1000; x = linspace(0, 2*PI, n); y = sin(x); g_set_line_width(ctx, 2); g_set_source_rgb(ctx, [255, 0,0,0]); g_polyline(ctx, x, y); g_stroke_preserve(ctx) p = g_pattern_create_linear(0, -1.1, 0, 1.1); g_pattern_add_color_stop_rgb(p, 0, [200, 0,0,0]); g_pattern_add_color_stop_rgb(p, 1, [255, 255,255,255]); g_set_source(ctx, p); g_fill(ctx); g_close(ctx); } .. image:: S:/uniplot-obj/images/g_polyline.* .. ------------------------------------------------------------------------------ .. index:: g_ellipse .. _g_ellipse: g_ellipse ------------------ .. us.tag g_ellipse NOTREADYENGLISH New5900 g_graph :ref:`g_ellipse` prints an ellipse. .. function:: r = g_ellipse(ctx, rsX1, rsY1, rsX2, rsY2, rsXS, rsYS, rsXE, rsYE) :: rect: rsX1, rsY1, rsX2, rsY2 start point: rsXS, rsYS end point: rsXE, rsYE .. ------------------------------------------------------------------------------ .. index:: g_arc .. _g_arc: g_arc ------------------ .. us.tag g_arc NOTREADYENGLISH New5900 g_graph :ref:`g_arc` adds an arc to the active path. *rsX*, *rsY* specify the bottom left corner of the rectangle with size *rsWidth* and *rsHeigth*. .. function:: r = g_arc(ctx, rsX, rsY, rsWidth, rsHeight, rsStartAngle, rsSweepAngle) :: def test_g_arc() { hText = _g_helper_new_text_doc("g_4", [0,200,50], [0,200,50]); ctx = g_create(hText); g_set_transformation(ctx, "WC"); xc = 128.0; yc = 128.0; radius = 100.0; angle1 = 180.0; angle2 = 135.0; g_set_line_cap(ctx, PS_ENDCAP_FLAT) g_set_line_join(ctx, PS_JOIN_MITER) g_set_line_width (ctx, 50.0); g_new_path(ctx) g_arc(ctx, xc-radius, yc-radius, 2*radius, 2*radius, angle1, angle2); g_stroke (ctx); /* draw helping lines */ g_set_source_rgb (ctx, [0.6*255, 1.0*255, 0.2*255, 0.2*255]); g_set_line_width (ctx, 16.0); g_set_line_cap(ctx, PS_ENDCAP_FLAT) g_new_path(ctx) g_arc(ctx, xc-10/2, yc-10/2, 10.0, 10, 0, 360); // 2*M_PI); g_fill (ctx); g_arc(ctx, xc-radius, yc-radius, 2*radius, 2*radius, angle1, 0.01); g_line_to (ctx, xc, yc); g_stroke (ctx); g_arc(ctx, xc-radius, yc-radius, 2*radius, 2*radius, angle1+angle2, 0.011); g_line_to (ctx, xc, yc); g_stroke (ctx); g_close(ctx); } .. image:: S:/uniplot-obj/images/g_arc.* .. ------------------------------------------------------------------------------ Path ^^^^^^^ .. index:: g_new_path .. _g_new_path: g_new_path -------------- .. us.tag g_new_path NOTREADYENGLISH New5900 g_graph :ref:`g_new_path` deletes the active path and creates a new path. This function is called by :ref:`g_fill` and :ref:`g_stroke` automatically. .. function:: r = g_new_path(ctx) .. ------------------------------------------------------------------------------ .. index:: g_close_path .. _g_close_path: g_close_path -------------- .. us.tag g_close_path NOTREADYENGLISH New5900 g_graph :ref:`g_close_path` closes a path. The function adds a line from the last point to the first point. .. function:: r = g_close_path(ctx) .. ------------------------------------------------------------------------------ .. index:: g_stroke .. _g_stroke: g_stroke ------------------ .. us.tag g_stroke NOTREADYENGLISH New5900 g_graph :ref:`g_stroke` draws a line along the path. The function invokes :ref:`g_new_path`, which will deactivate the path. .. function:: r = g_stroke(ctx) .. ------------------------------------------------------------------------------ .. index:: g_stroke_preserve .. _g_stroke_preserve: g_stroke_preserve ------------------ .. us.tag g_stroke_preserve NOTREADYENGLISH New5900 g_graph :ref:`g_stroke_preserve` draws a line along the path without invoking :ref:`g_new_path`. .. function:: r = g_stroke_preserve(ctx) Siehe auch :ref:`g_stroke`, :ref:`g_new_path`, :ref:`g_close_path` .. ------------------------------------------------------------------------------ .. index:: g_fill .. _g_fill: g_fill ------------------ .. us.tag g_fill NOTREADYENGLISH New5900 g_graph :ref:`g_fill` fills a path. The function invokes :ref:`g_new_path`, which will deactivate the path. .. function:: r = g_fill(ctx) .. ------------------------------------------------------------------------------ .. index:: g_fill_preserve .. _g_fill_preserve: g_fill_preserve ------------------ .. us.tag g_fill_preserve NOTREADYENGLISH New5900 g_graph :ref:`g_fill_preserve` fills a path without invoking :ref:`g_new_path`. .. function:: r = g_fill_preserve(ctx) Siehe auch :ref:`g_fill`, :ref:`g_stroke`, :ref:`g_new_path`, :ref:`g_close_path` .. ------------------------------------------------------------------------------ Lines and Color ^^^^^^^^^^^^^^^^^^^^^^ .. index:: g_set_source_rgb .. _g_set_source_rgb: g_set_source_rgb ------------------ .. us.tag g_set_source_rgb NOTREADYENGLISH New5900 g_graph :ref:`g_set_source_rgb` sets the color and transparency for lines and fillings. .. function:: r = g_set_source_rgb(ctx, rvColor) *rvColor* is a vector with 3 ``[R, G, B]`` or 4 ``[A, R, G, B]`` elements in the range 0 to 255. ``[A, R, G, B]``: A is the alpha value, 0, transparent, 255 is opaque, RGB: red, green, blue. .. ------------------------------------------------------------------------------ .. index:: g_pattern_create_linear .. _g_pattern_create_linear: g_pattern_create_linear ------------------------- .. us.tag g_pattern_create_linear NOTREADYENGLISH New5900 g_graph :ref:`g_pattern_create_linear` creates a linear color gradient along the line (x0,y0) to (x1,y1). .. function:: pattern = g_pattern_create_linear(x0, y0, x1, y1) .. ------------------------------------------------------------------------------ .. index:: g_pattern_add_color_stop_rgb .. _g_pattern_add_color_stop_rgb: g_pattern_add_color_stop_rgb ----------------------------- .. us.tag g_pattern_add_color_stop_rgb NOTREADYENGLISH New5900 g_graph :ref:`g_pattern_add_color_stop_rgb` adds color stops to the color gradient. The value of *offset* are between 0.0 und 1.0. The offset sets the position of a color inside the color gradient. See example. .. function:: r = g_pattern_add_color_stop_rgb(pattern, offset, rvARGB) :: def test_g_polyline_color() { hText = _g_helper_new_text_doc("g_polyline_color", [0,2*PI, 2*PI/10], [-1,1,0.5]); ctx = g_create(hText); g_set_transformation(ctx, "WC"); n = 1000; x = linspace(0, 2*PI, n); y = sin(x); g_set_line_width(ctx, 20); g_polyline(ctx, x, y); p = g_pattern_create_linear(0, -1.1, 0, 1.1); g_pattern_add_color_stop_rgb(p, 1, [200, 255,0,0]); g_pattern_add_color_stop_rgb(p, 0.5, [200, 0,255,255]); g_pattern_add_color_stop_rgb(p, 0, [255, 0,0,255]); g_set_source(ctx, p); g_stroke(ctx); g_close(ctx); } .. image:: S:/uniplot-obj/images/g_polyline_color.* .. ------------------------------------------------------------------------------ .. index:: g_pattern_destroy .. _g_pattern_destroy: g_pattern_destroy ----------------------------- .. us.tag g_pattern_destroy NOTREADYGERMAN New5900 g_graph :ref:`g_pattern_destroy` destroys a color gradient. .. function:: r = g_pattern_destroy(pattern) .. ------------------------------------------------------------------------------ .. index:: g_set_source .. _g_set_source: g_set_source ----------------------------- .. us.tag g_set_source NOTREADYENGLISH New5900 g_graph :ref:`g_set_source` sets a color gradient created with :ref:`g_pattern_create_linear`. .. function:: r = g_set_source(ctx, pattern) :: def test_g_pattern() { hText = _g_helper_new_text_doc("g_pattern"); ctx = g_create(hText); g_set_transformation(ctx, "WC"); p = g_pattern_create_linear(0.5, 2, 2, 0.5); g_pattern_add_color_stop_rgb(p, 0, [200, 0,0,0]); g_pattern_add_color_stop_rgb(p, 1, [255, 255,255,255]); g_new_path(ctx); g_polyline(ctx, [0.5,2.5,1.5], [0.5, 1.5, 2.5]); g_close_path(ctx); g_set_line_width(ctx, 20); g_set_source_rgb(ctx, [0, 0,255,0]) g_stroke_preserve(ctx); g_set_source(ctx, p); g_fill(ctx); g_close(ctx); } .. image:: S:/uniplot-obj/images/g_pattern.* .. ------------------------------------------------------------------------------ .. index:: g_set_line_width .. _g_set_line_width: g_set_line_width ------------------ .. us.tag g_set_line_width NOTREADYENGLISH New5900 g_graph :ref:`g_set_line_width` sets the line width in 0.1 mm steps. .. function:: r = g_set_line_width(ctx, width) .. ------------------------------------------------------------------------------ .. index:: g_set_line_style .. _g_set_line_style: g_set_line_style ------------------ .. us.tag g_set_line_style NOTREADYENGLISH New5900 g_graph :ref:`g_set_line_style` sets the line style. .. function:: r = g_set_line_style(ctx, style) :: PS_SOLID 0 PS_DASH 1 PS_DOT 2 PS_DASHDOT 3 PS_DASHDOTDOT 4 PS_NULL 5 .. ------------------------------------------------------------------------------ .. index:: g_set_line_cap .. _g_set_line_cap: g_set_line_cap ------------------ .. us.tag g_set_line_cap NOTREADYENGLISH New5900 g_graph :ref:`g_set_line_cap` sets the line cap. .. function:: r = g_set_line_cap(ctx, linecap) :: PS_ENDCAP_ROUND 0x00000000 PS_ENDCAP_SQUARE 0x00000100 PS_ENDCAP_FLAT 0x00000200 .. ------------------------------------------------------------------------------ .. index:: g_set_line_join .. _g_set_line_join: g_set_line_join ------------------ .. us.tag g_set_line_join NOTREADYENGLISH New5900 g_graph :ref:`g_set_line_join` sets the line join. .. function:: r = g_set_line_join(ctx, linejoin) :: PS_JOIN_ROUND 0x00000000 PS_JOIN_BEVEL 0x00001000 PS_JOIN_MITER 0x00002000 Marker ^^^^^^^^ .. ------------------------------------------------------------------------------ .. index:: g_set_marker .. _g_set_marker: g_set_marker ------------------ .. us.tag g_set_marker NOTREADYENGLISH New5900 g_graph :ref:`g_set_marker` sets a marker style. :: oMarker = [. "edge-color" = "black", "edge-width" = 1, "fill-color" = "red", size = 0.2, style = "circle"]; .. function:: r = g_set_marker(ctx, oMarker) .. ------------------------------------------------------------------------------ .. index:: g_marker .. _g_marker: g_marker ------------------ .. us.tag g_marker NOTREADYENGLISH New5900 g_graph :ref:`g_marker` plots markers at the specified position. *rvX* and *rvY* are vectors of the same length. .. function:: r = g_marker(ctx, rvX, rvY) .. ------------------------------------------------------------------------------ Texte ^^^^^^^^^^^ .. index:: g_text .. _g_text: g_text ------------------ .. us.tag g_text NOTREADYENGLISH New5900 g_graph :ref:`g_text` plots text. .. function:: r = g_text(ctx, ssText, rvRect, nAttrib) :: G_TEXT_CLIP 1 G_TEXT_WORDWRAP 2 G_TEXT_SHRINK 4 .. ------------------------------------------------------------------------------ .. index:: g_set_font_handle .. _g_set_font_handle: g_set_font_handle ------------------ .. us.tag g_set_font_handle NOTREADYENGLISH New5900 g_graph :ref:`g_set_font_handle` sets a font. .. function:: r = g_set_font_handle(ctx, hfont) .. ------------------------------------------------------------------------------ .. index:: g_set_font .. _g_set_font: g_set_font ------------------ .. us.tag g_set_font NOTREADYENGLISH New5900 g_graph :ref:`g_set_font` sets a font. :: oFont = [. "face-name" = "Arial", size = 12, weight = 400, "pitch-and-family" = 49, underline = 0, italic = 0, "strike-out" = 0, angle = 0, color = "black"]; .. function:: r = g_set_font(ctx, oFont) .. ------------------------------------------------------------------------------ .. us.history **History** .. list-table:: :header-rows: 1 * - Version - Description * - R2017 - New. .. seealso:: :ref:`overview-drawing-objects` :sub:`id-1761312`