smile.infrastructure
Members list
Type members
Classlikes
Renders elements into bitmaps and SVGs in the browser. Scala.js only. It is a stable entry point of smile.infrastructure, as smile.infrastructure.Renderer is.
Renders elements into bitmaps and SVGs in the browser. Scala.js only. It is a stable entry point of smile.infrastructure, as smile.infrastructure.Renderer is.
Both go through the shared draw plan. Bitmaps are drawn on a canvas by smile.infrastructure.CanvasPlanRenderer and SVGs are built by smile.infrastructure.SvgPlanRenderer, so that they agree with each other and with the JVM.
Attributes
- Source
- JSRenderer.scala
- Supertypes
- Self type
-
JSRenderer.type
Attributes
- Companion
- trait
- Source
- Renderer.scala
- Supertypes
- Self type
-
Renderer.type
Renders elements into bitmaps through the shared draw plan, which every platform's backend draws the same way. Renderer() gives the platform's renderer.
Renders elements into bitmaps through the shared draw plan, which every platform's backend draws the same way. Renderer() gives the platform's renderer.
Renderer, with its JVM extension smile.infrastructure.renderInto, and, on Scala.js, smile.infrastructure.JSRenderer are the stable entry points of smile.infrastructure. Everything else in the package is internal to SMILe.
Attributes
- Companion
- object
- Source
- Renderer.scala
- Supertypes
- Known subtypes
-
object JSRenderer
Extensions
Extensions
Draws picture onto target with scaleFactor device pixels per logical pixel. It draws what drawing the bitmap smile.infrastructure.Renderer.createBitmapFrom gives for the same arguments at the target's translation would draw, and makes no bitmap. On graphics whose transform only translates, it draws as target.drawImage(bitmap.toAWTImage(settings), 0, 0, null) does. JVM only.
Draws picture onto target with scaleFactor device pixels per logical pixel. It draws what drawing the bitmap smile.infrastructure.Renderer.createBitmapFrom gives for the same arguments at the target's translation would draw, and makes no bitmap. On graphics whose transform only translates, it draws as target.drawImage(bitmap.toAWTImage(settings), 0, 0, null) does. JVM only.
The drawing is on the target's device pixels. The upper left corner of the bitmap lands where the translation of the target's transform is, rounded to the nearest whole device pixel, with a half going to the even one. That corner is the corner of the picture's bounds, covered by whole device pixels, which is seldom the picture's origin. A circle is centered on its origin, so its bounds start above and to the left of it. The rest of the transform is not used, so a target whose transform scales, as a Swing component's does on a high-DPI screen, takes that scale as scaleFactor. Only the target's clip is drawn into. Its transform, clip, composite, paint and hints are left as they were. The empty picture draws nothing.
To place the picture's origin on the translation instead, translate the target further by the upper left corner of the picture's smile.pictures.Element.bounds, in device pixels, or in logical pixels on a target whose transform already scales by scaleFactor. The origin then lands exactly there when that corner is on whole device pixels. Otherwise it can land one device pixel off, because the bitmap's corner is the bounds' corner rounded down to a whole device pixel, while the translation is rounded to the nearest one.
In a Swing component's paintComponent:
val g2d = graphics.asInstanceOf[java.awt.Graphics2D]
val scale = g2d.getDeviceConfiguration.getDefaultTransform.getScaleX
Renderer().renderInto(g2d, picture, scale)
Value parameters
- scaleFactor
-
Device pixels per logical pixel. Must be positive and finite, and 1 when the settings ask for
ResamplingMode.Stepwise. - settings
-
The settings the picture is drawn with. See smile.RenderSettings.
- timeMillis
-
The instant the picture is drawn at, as for smile.infrastructure.Renderer.createBitmapFrom.
Attributes
- Source
- JVMRendering.scala
