RunMat
GitHub

patch — Create MATLAB-compatible colored polygon patch objects from coordinate data or Faces/Vertices definitions.

patch creates filled polygon graphics objects. RunMat supports practical MATLAB forms including patch(X,Y,C), patch(X,Y,Z,C), name-value XData/YData/ZData, Faces/Vertices, struct input, explicit axes handles, and common face, edge, alpha, line-width, display-name, and visibility properties.

How patch works

  • Vector coordinate inputs create one polygon.
  • Matrix coordinate inputs create one polygon per column.
  • Patch edges close automatically, matching MATLAB's open-polygon behavior.
  • Faces values are interpreted as MATLAB-style one-based vertex indices.
  • 2-D vertices are accepted as N-by-2; 3-D vertices are accepted as N-by-3.
  • The returned value is a patch graphics handle that works with get, set, ishandle, and isgraphics.
  • Per-vertex or per-face CData colormap interpolation is not yet implemented; non-scalar color data is accepted only as compatibility input and currently falls back to the default face color unless FaceColor supplies a concrete RGB/color-name value.

Options

  • FaceColor accepts color names, RGB triples, flat, or none.
  • EdgeColor accepts color names, RGB triples, or none.
  • FaceAlpha and EdgeAlpha accept numeric values from 0 to 1.
  • LineWidth, DisplayName, and Visible use the shared plotting property model.
  • FaceColor, EdgeColor, alpha, line width, display name, visibility, Faces, Vertices, XData, YData, and ZData are the first supported patch property set. Lighting, normals, texture coordinates, and callback properties are deferred.

How RunMat runs patch on the GPU

Patch rendering is a plotting sink and fusion barrier.

Host and gathered-GPU inputs produce the same graphics object and handle behavior.

A future direct GPU path should preserve the same Faces/Vertices semantics and only replace the triangulation/packing step.

GPU memory and residency

patch gathers GPU-resident coordinate inputs in the first implementation because MATLAB-compatible patch parsing requires shape validation, one-based Faces handling, NaN padding, and polygon triangulation. The rendered geometry still flows through the shared GPU plotting renderer.

Examples

Create a triangle patch

x = [0 1 0];
y = [0 0 1];
patch(x, y, 'red');

Create two rectangle patches from matrix columns

X = [0 2; 1 3; 1 3; 0 2];
Y = [0 0; 0 0; 1 1; 1 1];
patch(X, Y, 'cyan', 'EdgeColor', 'black');

Create a patch from Faces and Vertices

V = [0 0; 1 0; 1 1; 0 1];
F = [1 2 3 4];
h = patch('Faces', F, 'Vertices', V, 'FaceColor', [0.2 0.6 0.9]);
get(h, 'Type')

Expected output:

ans =
    'patch'

Create a 3-D patch

V = [0 0 0; 1 0 0; 0.5 1 0.5];
F = [1 2 3];
patch('Faces', F, 'Vertices', V, 'FaceAlpha', 0.6);
view(3);

FAQ

Does patch close polygons automatically?

Yes. You can provide open polygon coordinate lists; RunMat closes the edge loop when rendering the patch.

Are Faces indices zero-based or one-based?

They are one-based to match MATLAB. Faces = [1 2 3] references the first, second, and third rows of Vertices.

Does patch have a direct GPU-resident geometry path?

Not yet. RunMat gathers GPU-resident patch inputs for validation and triangulation, then submits the resulting geometry to the shared GPU renderer. A direct GPU triangulation/packing path can be added later for very large patch meshes.

2D Charts

area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem

3D & Surface

contour · contourf · mesh · meshc · plot3 · quiver · scatter3 · surf · surfc

Images

image · imagesc · imshow

Axes & Layout

axis · box · grid · sgtitle · subplot · title · view · zlabel

Appearance

colorbar · colormap · legend · shading

Handle Access

gca · gcf · get · set

Other

cla · clf · figure · fill3 · hold · suptitle · xline · yline

More plotting resources

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how patch works, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.

  • Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
  • Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
  • A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.

Getting started · Benchmarks · Pricing

Try RunMat for free

Write code or describe what you want to compute. The sandbox is free, no account required.