Search by

pushinbr / pam-native-svg

DavidWilliamBalbino

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

Documentation

Language:Kotlin

Type:pam-native-plugin

pkg:composer/pushinbr/pam-native-svg

Statistics

Installs: 58

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.1 2026-11-18 01:13 UTC

This package is auto-updated.

Last update: 2026-11-18 04:03:31 UTC


README

pam-native-svg: Native vector graphics and render-thread animations for PAM Native.

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.

Packagist Latest release PHP 8.5 License

Install · Quick example · Platforms · Features · Docs · Issues

Install

Inside a PAM Native project, add only this capability:

pam composer require pushinbr/pam-native-svg
pam doctor --fix

New to PAM? Create a project with pam init my-app --template native (see the PAM Native overview), then come back here. Composer owns the manifest and the lockfile; pam composer runs it on PAM's verified PHP runtime.

Quick example

<?php

declare(strict_types=1);

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));

Declarative .pam components use the same native view:

<SvgIcon src="assets/icons/send.svg" tint="#1d9bf0" size="24" />
<ProgressRing :progress="$fraction" size="44" stroke="3" color="#fff" />

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. A complete screen is in examples/UploadProgress.php.

Platform support

Platform Support Notes
Android API 24+ Canvas / RenderNode; Choreographer animations only while visible
iOS 15.0+ Core Animation (CAShapeLayer, CABasicAnimation); see iOS validation
PAM Native 1.0.0 to < 2.0.0 From pam-native.plugin.json (composer.json requires ^1.0.15); PHP 8.5+

Requirements

No permissions and no dependencies beyond the platform SDKs (iOS frameworks: CoreGraphics, QuartzCore, UIKit). The plugin registers one host view, svg.view.

Features

  • Svg, Path (all commands incl. arcs), Circle, Ellipse, Rect, Line, Polyline, Polygon, G, ClipPath, LinearGradient, RadialGradient, transforms, opacity, dash arrays/offsets with pathLength, 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.
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

See docs/svg.md for the full API, supported markup and the comparison with react-native-svg.

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.

Docs

Part of the PAM ecosystem

PAM

PAM runs PHP natively on servers, desktops and phones. This repository is one piece of it.

PAM PAM Desktop PAM Native Ecosystem
the runtime and CLI native desktop apps in PHP native Android and iOS apps in PHP every official package and plugin

Docs: push-in.github.io/pam-docs · Issues

Apache License 2.0 · Made in Brazil by Pushin