scalacv.graphs
Members list
Type members
Classlikes
Animation — a drawing that is a function of the frame number, rendered to a video.
Animation — a drawing that is a function of the frame number, rendered to a video.
The natural extension of a composable Picture: describe frame i as frame(i), and record draws every frame onto a fresh canvas and writes them out through a Recorder. Creative coding, a rendered data animation, a synthetic test clip — all fall out of the same graphics vocabulary.
// `.avi`, not `.mp4`: the default codec is MJPG, which opens only in an AVI container — see [[Codec.Mjpg]].
Animation.record("spin.avi", frames = 60, width = 320, height = 240) { i =>
Picture.regularPolygon(Point(160, 120), sides = 5, radius = 80, rotation = i * 6)
.strokeColor(Color.hsl(i * 6, 0.8, 0.6)).strokeWidth(3)
}
Attributes
- Source
- Animation.scala
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Animation.type
The axis-aligned bounding box of a Picture — what the layout combinators (Picture.beside, Picture.above) measure to place pictures next to each other.
The axis-aligned bounding box of a Picture — what the layout combinators (Picture.beside, Picture.above) measure to place pictures next to each other.
Attributes
- Source
- Picture.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Minimal data visualisation, built from Picture — proof that the graphics layer composes into charts, and a handy way to overlay a plot on an image (a histogram beside a detection, a signal on a frame).
Minimal data visualisation, built from Picture — proof that the graphics layer composes into charts, and a handy way to overlay a plot on an image (a histogram beside a detection, a signal on a frame).
Each returns a Picture sized to a width×height box with its origin at the top-left, so it composes and transforms like any other picture: Chart.bars(counts, 200, 80).at(Point(10, 10)) drops a chart into a corner.
Attributes
- Source
- Chart.scala
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Chart.type
Attributes
- Companion
- class
- Source
- Color.scala
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
Color.type
A colour with an alpha channel — the palette for Picture graphics.
A colour with an alpha channel — the palette for Picture graphics.
Doodle-inspired: colours are values you build and transform (.lighten, .fadeOut, .blend) rather than raw BGR triples. Stored as RGBA in [0, 255]; the renderer converts to OpenCV's BGR at the boundary, and alpha drives per-shape transparency when a picture is drawn over an image.
Attributes
- Companion
- object
- Source
- Color.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Source
- Picture.scala
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
Dash.type
A stroke dash pattern — alternating on/off run lengths in pixels. OpenCV has no dashed line, so Picture draws them by hand from this.
A stroke dash pattern — alternating on/off run lengths in pixels. OpenCV has no dashed line, so Picture draws them by hand from this.
Attributes
- Companion
- object
- Source
- Picture.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
The OpenCV image backend. Rendering consumes the input Image exactly as image.draw does; the returned Image is owned by the caller. Shape construction and geometry need no native loading.
The OpenCV image backend. Rendering consumes the input Image exactly as image.draw does; the returned Image is owned by the caller. Shape construction and geometry need no native loading.
Attributes
- Source
- Graphics.scala
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
OpenCvRenderer.type
An immutable, composable 2D drawing — the graphics layer, inspired by Doodle and adapted to image space.
An immutable, composable 2D drawing — the graphics layer, inspired by Doodle and adapted to image space.
A Picture is a value: build primitives, style them, compose them, and only then render onto an image. Because it composes, the same vocabulary annotates a detection, draws a chart, or makes generative art.
import scalacv.*
import scalacv.graphs.*
OpenCv.load()
// A dashed green box with a label — an overlay for a detected face:
val overlay =
Picture.rectangle(face.box).strokeColor(Color.Green).strokeWidth(2).dashed
.on(Picture.text("face", Point(face.box.x, face.box.y - 6)).strokeColor(Color.Green))
image.draw(overlay) // draw it on
Coordinates are image pixels (origin top-left, y down). Styling is contextual: a style set on a group is the default its members inherit unless they set their own. Alpha in a Color gives real transparency when drawn over an image.
Attributes
- Companion
- object
- Source
- Picture.scala
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- trait
- Source
- Picture.scala
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
Picture.type
Geometry and layout with explicitly chosen text metrics. Shape-only measurement never calls the measurer; text remains axis-aligned at its transformed anchor. Bounds describe geometry, not ink.
Geometry and layout with explicitly chosen text metrics. Shape-only measurement never calls the measurer; text remains axis-aligned at its transformed anchor. Bounds describe geometry, not ink.
Attributes
- Companion
- object
- Source
- PictureLayout.scala
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- class
- Source
- PictureLayout.scala
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
PictureLayout.type
The resolved style a renderer receives. Stroke widths remain in pixels under scene transforms; only circle radii and text scales scale with the geometry.
The resolved style a renderer receives. Stroke widths remain in pixels under scene transforms; only circle radii and text scales scale with the geometry.
Attributes
- Source
- Picture.scala
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Backend-neutral drawing commands in image coordinates. Transforms have already been applied; text stays axis-aligned at its transformed baseline anchor, as in the original Picture API.
Backend-neutral drawing commands in image coordinates. Transforms have already been applied; text stays axis-aligned at its transformed baseline anchor, as in the original Picture API.
Attributes
- Source
- Renderer.scala
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A destination-bound renderer. Implement draw for a raster, an SVG sink, or a command recorder; the library supplies scene traversal, transform composition and contextual style resolution. The implementation owns its destination's lifetime. No native type or flag is required by this contract.
A destination-bound renderer. Implement draw for a raster, an SVG sink, or a command recorder; the library supplies scene traversal, transform composition and contextual style resolution. The implementation owns its destination's lifetime. No native type or flag is required by this contract.
An open trait that consumers may implement: within a minor line a new member added to it always carries a default implementation, so an existing implementation keeps compiling.
Attributes
- Source
- Renderer.scala
- Supertypes
-
class Objecttrait Matchableclass Any
Backend-controlled text measurement. The result includes the descender baseline, as in Draw.textSize. Measurement deliberately uses the historical one-pixel glyph metrics, independently of stroke width.
Backend-controlled text measurement. The result includes the descender baseline, as in Draw.textSize. Measurement deliberately uses the historical one-pixel glyph metrics, independently of stroke width.
An open trait that consumers may implement: within a minor line a new member added to it always carries a default implementation, so an existing implementation keeps compiling.
Attributes
- Companion
- object
- Source
- PictureLayout.scala
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class TextMetricCache
Attributes
- Companion
- trait
- Source
- PictureLayout.scala
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
TextMeasurer.type
Opt-in, session-owned text metrics for one stable backend. No cache is installed on the default renderer. Pass this measurer to PictureLayout or return it from a custom Renderer.textMeasurer.
Opt-in, session-owned text metrics for one stable backend. No cache is installed on the default renderer. Pass this measurer to PictureLayout or return it from a custom Renderer.textMeasurer.
The backend must return the same metrics for a text/font/effective-scale key until clear is called. Clear after changing backend configuration and at the end of a session to release retained text; this is reference removal, not secure erasure. Do not share a cache across unrelated privacy domains.
All operations, including backend measurements, are synchronized. Concurrent callers through this wrapper are serialized; external backend mutation/access still needs caller coordination. Exceptions are not cached. Least-recently-used entries are evicted to satisfy both limits. Characters are UTF-16 code units, counted per key even when several keys share one string. Oversized texts bypass the cache without eviction; a zero limit disables retention. The limits bound retained keys, not transient measurement allocations.
Attributes
- Source
- TextMetricCache.scala
- Supertypes
Extensions
Extensions
Draws a composable Picture onto the image — the high-level graphics layer (shapes, dashed strokes, text, transforms, transparency). Consumes this image and returns the annotated one.
Draws a composable Picture onto the image — the high-level graphics layer (shapes, dashed strokes, text, transforms, transparency). Consumes this image and returns the annotated one.
Attributes
- Source
- Graphics.scala
The reverse of Color.toBgrScalar: read an OpenCV BGR Scalar into the RGBA Color palette, for handing an OpenCV colour to the Picture graphics layer. Channels are rounded and clamped to [0, 255]; the result is fully opaque (a Scalar's fourth channel is not a reliable alpha, so it is not carried over). An extension rather than a method on Scalar so the core Scalar type stays free of any dependency on this graphics-layer palette.
The reverse of Color.toBgrScalar: read an OpenCV BGR Scalar into the RGBA Color palette, for handing an OpenCV colour to the Picture graphics layer. Channels are rounded and clamped to [0, 255]; the result is fully opaque (a Scalar's fourth channel is not a reliable alpha, so it is not carried over). An extension rather than a method on Scalar so the core Scalar type stays free of any dependency on this graphics-layer palette.
Attributes
- Source
- Color.scala