pushinbr / pam-native-svg
Native SVG for PAM Native: retained vector nodes, gradients, dashes and render-thread animations on Android Canvas and Core Animation.
Package info
github.com/push-in/pam-native-svg
Language:Kotlin
Type:pam-native-plugin
pkg:composer/pushinbr/pam-native-svg
Requires
- php: ^8.5
- pushinbr/pam-native: ^1.0
Requires (Dev)
- pushinbr/pam-native-plugin-kit: ^0.2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
PAM Native SVG
Native vector graphics and render-thread animations for PAM Native.
Icons, progress rings, gradients and dashed strokes parsed once, retained natively and animated without crossing back to PHP.
Documentation · Quick start · iOS validation · PAM ecosystem · Issues
Why PAM Native SVG
A drop-in replacement for react-native-svg in PAM Native apps. PHP builds or loads the markup; the
native side parses each content hash once into a retained tree (Android Canvas + RenderNode,
iOS CAShapeLayer) and runs animations itself, so a progress ring updating 30 times a second never
re-renders PHP or re-parses a path.
| Best for | Icons, progress rings, badges, gradients, decorative vectors |
| Native path | Android Canvas / RenderNode · Core Animation |
| Animation | Choreographer (only while visible) · CABasicAnimation |
| Dependencies | None beyond the platform SDKs |
Quick start
pam composer require pushinbr/pam-native-svg
use Pam\Native\Svg\{Svg, Path, ProgressRing, SvgAnimation, SvgProperty}; ProgressRing::make($upload->fraction)->size(44)->strokeWidth(3)->color('#ffffff'); Svg::fromFile(__DIR__.'/assets/send.svg')->tint('#1d9bf0')->size(24); Svg::make(24, 24) ->add(Path::make('M5 12l5 5L19 7')->id('check')->fill('none')->stroke('#fff', 2)->pathLength(1)->trim(0, 0)) ->animate(SvgAnimation::to('check', SvgProperty::TrimEnd, $done ? 1 : 0)->duration(260));
<SvgIcon src="assets/icons/send.svg" tint="#1d9bf0" size="24" /> <ProgressRing :progress="$fraction" size="44" stroke="3" color="#fff" />
Features
Svg,Path(all commands incl. arcs),Circle,Ellipse,Rect,Line,Polyline,Polygon,G,ClipPath,LinearGradient,RadialGradient, transforms, opacity, dash arrays/offsets withpathLength,trim().Svg::fromString()/Svg::fromFile()with hash-keyed caches on both sides;tint(),color()(currentColor),size(),fit().- Native animations of opacity, dash offset, trim, rotation, scale, translation and stroke
width; continuous retargeting; repeat/reverse/delay;
onAnimationEnd. - Bounded memory: 128-entry/4 MiB PHP source LRU, 64-document/2 MiB native LRU trimmed on memory pressure; no frames while a view is hidden or detached.
See docs/svg.md for the full API, supported markup and the comparison with
react-native-svg, and examples/UploadProgress.php.
Testing
pam tests/run.php # PHP contracts cd android && gradle -PpamPluginApi=/path/pam-native-android-plugin-api-1.39.2.aar \ testDebugUnitTest connectedDebugAndroidTest # JVM + emulator instrumentation
iOS: follow docs/ios-validation.md on a Mac.
License
Apache-2.0.