dot_globe 0.2.0
dot_globe: ^0.2.0 copied to clipboard
A dotted (halftone) 3D globe for Flutter — spin it, drop any widget as a lat/lng marker. Pure Dart, zero deps, light & dark presets out of the box.
Changelog #
0.2.0 #
- Custom dot clouds — new
DotGlobeGeometryclass with four constructors:fromLatLng— build a cloud from a list of lat/lng degree pairs.fromPackedInt16— decode the bundled.binformat (little-endian int16 pairs) from anyByteDatasource.fromAsset— async loader for a.binasset; throws a descriptiveExceptionnaming the asset key if missing or malformed.fromUnitVectors— power-user path; accepts a flatFloat32Listof pre-computed unit vectors with caller-owned axis convention.
DotGlobe(geometry:)— new optional parameter; pass aDotGlobeGeometryto replace the built-in Earth point cloud.null(default) loads the bundled data as before, so existing usage is unchanged.- Documented
.binbinary format — flat little-endian int16 pairs of(round(lat × 100), round(lng × 100)), 4 bytes per point, no header/footer, quantization 0.01° ≈ 1.1 km at the equator. - Added
tool/gen_land_dots.py— Python 3 generator (shapely required, numpy optional) to compile your own.binfrom Natural Earth GeoJSON at 110m / 50m / 10m resolution; flags:--geojson,--resolution,--samples,--out,--quiet. - Pinch-to-zoom — two-finger pinch scales the globe in
[minScale, maxScale]; one-finger drag rotates as before. While zoomed in, drag sensitivity scales down proportionally for finer control. - Programmatic zoom & fly-to —
DotGlobeControllergains:animateTo({latitude?, longitude?, scale?, hold, duration, curve})— compose a rotate + zoom into one eased move (scale is a new optional axis; existing callers are unaffected).zoomTo(scale, {hold, duration, curve})— ease to a zoom level without changing the facing coordinate.resetView({duration, curve})— ease back toinitialLatitude/initialLongitude/initialScale.jumpTo({latitude?, longitude?, scale?, hold})— instant snap;scaleis a new optional parameter (existing callers are unaffected).scalegetter — read the current zoom factor (nullwhen not attached).hold(onanimateTo/zoomTo/jumpTo, defaultfalse) — whentrue, the globe parks at the destination (no auto-rotation or pitch spring-back) until the next drag or move, instead of resuming idle spin.
- New
DotGlobeparameters (all non-breaking, with defaults):initialScale(1.0) — zoom at first build andresetViewtarget.minScale(1.0) — lower zoom bound for gesture and programmatic zoom.maxScale(6.0) — upper zoom bound; set equal tominScaleto disable.zoomGesture(true) — whether pinch-to-zoom is active.clipBehavior(Clip.none) — clip a zoomed globe to its container withClip.hardEdge; default preserves previous behaviour.markersScaleWithZoom(true) — global default for whether markers magnify with the globe's zoom.
DotGlobeMarker.scaleWithZoom(bool?, defaultnull) — per-marker override:falsekeeps the marker at a constant on-screen size (crisp pin) while still tracking the zoomed position;truemagnifies it with the globe;nullinheritsDotGlobe.markersScaleWithZoom.- Per-dot colours —
DotGlobeGeometrynow carries an optionalInt32List? colors(one packed ARGB-8888 int per dot;null= every dot uses the style's singledotColor, pixel-identical to the previous behaviour). A dot whose alpha is0is hidden. - Immutable colour fillers — each returns a new
DotGlobeGeometrysharing the originalunitVectors:withColors(Int32List colors)— explicit per-dot ARGB list (length == pointCount).colorize(int Function(double latDeg, double lngDeg, int index) toArgb)— colour by an arbitrary callback; return alpha0to hide a dot.colorizeByValues(List<double> values, {required DotGlobeColormap colormap, double? min, double? max, double? hideBelow})— map a per-dot scalar through a colour ramp (values.length == pointCount;min/maxdefault to the data extent; values belowhideBeloware hidden).Future<DotGlobeGeometry> colorizeFromImage(ui.Image equirectangular, {double hideBelowAlpha = 0.0, bool wrapLongitude = true})— sample an equirectangular (plate-carrée) image per dot (u = lng/360 + 0.5,v = 0.5 - lat/180); pixels belowhideBelowAlphaare hidden.Future<DotGlobeGeometry> colorizedFromImageProvider(ImageProvider provider, {double hideBelowAlpha = 0.0, ImageConfiguration configuration = ImageConfiguration.empty})— one-liner forAssetImage/NetworkImage; decodes then delegates tocolorizeFromImage.
DotGlobeColormap(new, exported) — immutable colour ramp over[0, 1]with linear interpolation between evenly-spaced stops.const DotGlobeColormap(List<Color> colors)/DotGlobeColormap.gradient([…])Color at(double t)/int argbAt(double t)- Built-in presets:
viridis(perceptually-uniform blue→green→yellow),turbo(high-contrast rainbow),heat(black-body black→red→orange→yellow→white),grayscale(black→white),cool(blue→cyan→white).
- Render path for coloured clouds:
drawRawAtlas(one batched call per depth band, zero per-frame allocation). The single-colour default retains the originaldrawRawPointsfast path.
0.1.0 — initial release #
DotGlobe— a dotted (halftone) 3D globe rendered with a single batcheddrawRawPointsper depth band; ~6300 land dots from Natural Earth 110m.DotGlobeMarker— pin any widget at a latitude/longitude; projected onto the sphere, back-face culled, and faded near the silhouette.DotGlobeArc— great-circle connection arcs that bow off the sphere, solid on the near side and dashed around the back; configurable altitude, color, width, dash pattern, and back-side opacity.- Gesture rotation with inertia, pitch spring-back, and idle auto-rotate; an eager pan recognizer keeps drags from being stolen by an ancestor scrollable.
DotGlobeStylewith nine ready-made presets —light,dark,polymarket,neon,sunset,mono,emerald,pastel,midnight— pluscopyWithand apresetsmap.DotGlobeController—animateTo/jumpToa coordinate and observe thefacingpoint (it is aChangeNotifier).pausedflag to stop the frame loop while off-screen within a route.- Pure Dart, zero third-party dependencies, no texture assets. Runs on iOS, Android, Web, macOS, Windows, and Linux.
