Skip to content

IChartDrawSink

InterfaceChartGuruChartGuru
public interface IChartDrawSink

Backend-neutral immediate-mode draw target used by ChartGuru.ChartRenderer to emit geometry without binding to a specific rendering pipeline.

Implementations in this project:

  • [ChartGuru.GLDrawSink](/tools/chartguru/api/chartguru-gldrawsink/) - forwards to GL.Begin/Vertex3/Color/End. Used by the uGUI [ChartGuru.ChartGraphic](/tools/chartguru/api/chartguru-chartgraphic/) path (render-to-texture) and the Scene [ChartGuru.ChartComponent](/tools/chartguru/api/chartguru-chartcomponent/) path.
  • UITKMeshDrawSink - emits into a MeshGenerationContext for the UI Toolkit ChartGuruElement.

The API intentionally mirrors GL's state machine: Begin(topology, material), any number of Color/Vertex pairs, then End. Color state persists until the next Color call, matching GL's current-color model. Scissoring and transform stack are managed out-of-band so the renderer can match GL's MultMatrix/LoadPixelMatrix patterns during morph passes without caring which backend is active.

void Begin(DrawTopology topology, DrawMaterial material = DrawMaterial.Standard)

Begins a primitive batch with the given topology and material bucket. Must be balanced with ChartGuru.IChartDrawSink.End before another ChartGuru.IChartDrawSink.Begin(ChartGuru.DrawTopology%2cChartGuru.DrawMaterial).

Parameters

Name Type Description
topology ChartGuru.DrawTopology
material ChartGuru.DrawMaterial
void Color(Color c)

Sets the current vertex color. Applies to all subsequently emitted vertices until overridden.

Parameters

Name Type Description
c UnityEngine.Color
void Vertex(float x, float y)

Emits a vertex at the specified chart-space pixel coordinate (Y up, bottom-left origin).

Parameters

Name Type Description
x System.Single
y System.Single
void End()

Closes the current primitive batch started by ChartGuru.IChartDrawSink.Begin(ChartGuru.DrawTopology%2cChartGuru.DrawMaterial).

void SetScissor(Rect? clipRectPixels)

Sets an axis-aligned scissor rectangle in pixel coordinates, or clears it when null. Intended for morph and inset panels; the GL sink translates this to an SRP scissor, the UI Toolkit sink to a clipping descendant or manual CPU-side clipping.

Parameters

Name Type Description
clipRectPixels System.Nullable{UnityEngine.Rect}
void PushTransform(Matrix4x4 m)

Pushes a transform onto the sink’s matrix stack. Subsequent ChartGuru.IChartDrawSink.Vertex(System.Single%2cSystem.Single) calls are effectively multiplied by the top-of-stack matrix. Matches GL.PushMatrix + GL.MultMatrix(m).

Parameters

Name Type Description
m UnityEngine.Matrix4x4
void PopTransform()

Pops the top matrix from the sink’s transform stack. Matches GL.PopMatrix.