PHP code example of pushinbr / pam-native-canvas
1. Go to this page and download the library: Download pushinbr/pam-native-canvas library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pushinbr / pam-native-canvas example snippets
use Pam\Native\Canvas\Canvas;
use Pam\Native\Canvas\CanvasView;
use Pam\Native\Canvas\FontWeight;
use Pam\Native\Canvas\Path;
use Pam\Native\Canvas\PathMode;
use Pam\Native\Canvas\TextAlign;
$line = Path::start(0, 120)
->curveTo(40, 120, 60, 40, 100, 40)
->curveTo(140, 40, 160, 90, 200, 90)
->curveTo(240, 90, 260, 20, 300, 20);
$area = $line->lineTo(300, 160)->lineTo(0, 160)->close();
$scene = (new Canvas())
->dashedLine(0, 160, 300, 160, '#2c3947', 1, 4, 4)
->save()
->alpha(0.35)
->gradientPath($area, 0, 20, 0, 160, '#19c5ff', '#19c5ff00')
->restore()
->path($line, '#19c5ff', 2, PathMode::Stroke)
->circle(300, 20, 4, '#19c5ff')
->label('R$ 1.234', 300, 10, 12, '#f4f7fa', TextAlign::Right, FontWeight::SemiBold)
->label('Seg', 0, 178, 11, '#a0adbb')
->label('Sex', 300, 178, 11, '#a0adbb', TextAlign::Right)
->scene();
return CanvasView::make($scene, revision: 1)->dp();
CanvasView::make($scene, revision: $tick)
->dp()
->onPointer(fn (CanvasEventKind $kind, float $x, float $y) => $this->select($x));
bash
composer install
php tests/run.php # PHP contracts (wire snapshots, validation, enums)
vendor/bin/phpstan analyse # level max
vendor/bin/pam-native-plugin validate pam-native.plugin.json