.. ------------------------------------------------------------------------------ .. ------------------------------------------------------------------------------ .. ------------------------------------------------------------------------------ .. highlightlang:: us .. index:: g_graph .. _g_graph: g_graph ================ Erzeugen und Schließen ^^^^^^^^^^^^^^^^^^^^^^^^ .. index:: g_create .. _g_create: g_create -------------- .. us.tag g_create NOTREADYGERMAN New5900 g_graph :ref:`g_create` erzeugt eine UniPlot-Metadatei mit Vektor-Grafiken im Speicher. Die Grafik wird bei :ref:`g_close` in einem Zeichenobjekt oder Datensatz gespeichert (*hObject*) und zusammen mit diesem ausgegeben. .. 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 NOTREADYGERMAN New5900 g_graph :ref:`g_close` beendet die Erzeugung der UniPlot-Metadatei und kopiert die Bits in das bei :ref:`g_create` angegebenen Zeichenobjekts oder Datensatzes. .. function:: r = g_close(ctx) .. ------------------------------------------------------------------------------ .. index:: g_set_transformation .. _g_set_transformation: g_set_transformation --------------------- .. us.tag g_set_transformation NOTREADYGERMAN New5900 g_graph :ref:`g_set_transformation` setzt die Transformation für die verwendeten Koordinaten in Weltkoordinaten oder Zentimeter-Koordinaten (*ssType* gleich "WC" oder 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 NOTREADYGERMAN New5900 g_graph :ref:`g_move_to` setzt den Zeichenstift an die angegebene Position. .. function:: r = g_move_to(ctx, x, y) .. ------------------------------------------------------------------------------ .. index:: g_line_to .. _g_line_to: g_line_to -------------- .. us.tag g_line_to NOTREADYGERMAN New5900 g_graph :ref:`g_line_to` fügt dem Pfad eine Linie von der aktuellen Position zum Punkt (x, y) zu. .. function:: r = g_line_to(ctx, x, y) .. ------------------------------------------------------------------------------ .. index:: g_polyline .. _g_polyline: g_polyline ------------------ .. us.tag g_polyline NOTREADYGERMAN New5900 g_graph :ref:`g_polyline` fügt dem Pfad Linien hinzu. .. 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 NOTREADYGERMAN New5900 g_graph :ref:`g_ellipse` gibt einen Ellipsenbogen aus. .. 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 NOTREADYGERMAN New5900 g_graph :ref:`g_arc` gibt einen Kreisbogen aus. .. 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.* .. ------------------------------------------------------------------------------ Pfade ^^^^^^^ .. index:: g_new_path .. _g_new_path: g_new_path -------------- .. us.tag g_new_path NOTREADYGERMAN New5900 g_graph :ref:`g_new_path` löscht den aktuellen Pfad und erzeugt einen neuen Pfad. Dies Funktion wird auch automatisch nach :ref:`g_fill` und :ref:`g_stroke` aufgerufen. .. function:: r = g_new_path(ctx) .. ------------------------------------------------------------------------------ .. index:: g_close_path .. _g_close_path: g_close_path -------------- .. us.tag g_close_path NOTREADYGERMAN New5900 g_graph :ref:`g_close_path` schließt den Pfad, d. h. fügt dem Pfad eine Linie vom aktuellen Punkt zum Anfangspunkt zu. .. function:: r = g_close_path(ctx) .. ------------------------------------------------------------------------------ .. index:: g_stroke .. _g_stroke: g_stroke ------------------ .. us.tag g_stroke NOTREADYGERMAN New5900 g_graph :ref:`g_stroke` zieht eine Linie entlang des Pfades. Anschließend wird :ref:`g_new_path` aufgerufen. .. function:: r = g_stroke(ctx) Siehe auch :ref:`g_stroke_preserve`, :ref:`g_new_path`, :ref:`g_close_path` .. ------------------------------------------------------------------------------ .. index:: g_stroke_preserve .. _g_stroke_preserve: g_stroke_preserve ------------------ .. us.tag g_stroke_preserve NOTREADYGERMAN New5900 g_graph :ref:`g_stroke_preserve` zieht eine Linie entlang des Pfades. Der Pfad bleibt erhalten. .. 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 NOTREADYGERMAN New5900 g_graph :ref:`g_fill` füllt den Pfad. Anschließend wird :ref:`g_new_path` aufgerufen. .. function:: r = g_fill(ctx) Siehe auch :ref:`g_fill_preserve`, :ref:`g_stroke`, :ref:`g_new_path`, :ref:`g_close_path` .. ------------------------------------------------------------------------------ .. index:: g_fill_preserve .. _g_fill_preserve: g_fill_preserve ------------------ .. us.tag g_fill_preserve NOTREADYGERMAN New5900 g_graph :ref:`g_fill_preserve` füllt den Pfad. Der Pfad bleibt erhalten. .. function:: r = g_fill_preserve(ctx) Siehe auch :ref:`g_fill`, :ref:`g_stroke`, :ref:`g_new_path`, :ref:`g_close_path` .. ------------------------------------------------------------------------------ Linien und Farben ^^^^^^^^^^^^^^^^^^^^^^ .. index:: g_set_source_rgb .. _g_set_source_rgb: g_set_source_rgb ------------------ .. us.tag g_set_source_rgb NOTREADYGERMAN New5900 g_graph :ref:`g_set_source_rgb` setzt die Farbe und Transparenz für Linienausgaben oder Flächen. .. function:: r = g_set_source_rgb(ctx, rvColor) *rvColor* ist ein Vektor mit 3 ``[R, G, B]`` oder 4 ``[A, R, G, B]`` Zahlenwerten im Bereich 0 bis 255. ``[A, R, G, B]``: A ist der Alpha-Wert, 0, vollständig transparent, 255 ist Opaque, RGB: Rot-, Grün-, Blau-Anteil. .. ------------------------------------------------------------------------------ .. index:: g_pattern_create_linear .. _g_pattern_create_linear: g_pattern_create_linear ------------------------- .. us.tag g_pattern_create_linear NOTREADYGERMAN New5900 g_graph :ref:`g_pattern_create_linear` erzeugt einen linearen Farbverlauf entlang der Linie (x0,y0) nach (x1,y1). Vor der Verwendung sollten dem Farbverlauf einige Farbstufen mit :ref:`g_pattern_add_color_stop_rgb` zugefügt werden. .. 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 NOTREADYGERMAN New5900 g_graph :ref:`g_pattern_add_color_stop_rgb` fügt dem Farbverlauf Farbstufen zu. *offset* ist zwischen 0.0 und 1.0. Siehe Beispiel. .. 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` löscht den Farbverlauf. .. function:: r = g_pattern_destroy(pattern) .. ------------------------------------------------------------------------------ .. index:: g_set_source .. _g_set_source: g_set_source ----------------------------- .. us.tag g_set_source NOTREADYGERMAN New5900 g_graph :ref:`g_set_source` setzt den mit :ref:`g_pattern_create_linear` erzeugten Farbverlauf für die Ausgabe. .. 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 NOTREADYGERMAN New5900 g_graph :ref:`g_set_line_width` setzt die Dicke von Linien in 0.1mm-Schritten. .. 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 NOTREADYGERMAN New5900 g_graph :ref:`g_set_line_style` setzt den Linienstil. .. 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 NOTREADYGERMAN New5900 g_graph :ref:`g_set_line_cap` legt fest wie die Endpunkte eines Pfades ausgegeben werden. .. 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 NOTREADYGERMAN New5900 g_graph :ref:`g_set_line_join` legt fest wie die Enden von zwei Linien zusammengefügt werden. .. 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 NOTREADYGERMAN New5900 g_graph :ref:`g_set_marker` legt das Aussehen von Markern fest. :: 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 NOTREADYGERMAN New5900 g_graph :ref:`g_marker` gibt Marker an den Positionen rvX[i], rvY[i] aus. .. function:: r = g_marker(ctx, rvX, rvY) .. ------------------------------------------------------------------------------ Texte ^^^^^^^^^^^ .. index:: g_text .. _g_text: g_text ------------------ .. us.tag g_text NOTREADYGERMAN New5900 g_graph :ref:`g_text` gibt einen Text aus. .. 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 NOTREADYGERMAN New5900 g_graph :ref:`g_set_font_handle` setzt den Font. .. function:: r = g_set_font_handle(ctx, hfont) .. ------------------------------------------------------------------------------ .. index:: g_set_font .. _g_set_font: g_set_font ------------------ .. us.tag g_set_font NOTREADYGERMAN New5900 g_graph :ref:`g_set_font` setzt den 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 - Beschreibung * - R2017 - Neu. .. seealso:: :ref:`overview-drawing-objects` :sub:`id-1761312`