bviguier / phpresent
从Php创建并运行演示文稿。
dev-master
2019-11-09 19:48 UTC
Requires
- php: ^7.2
- ext-imagick: ^3.4
- ext-sdl: ^2.1
Requires (Dev)
- phpstan/phpstan-shim: ^0.11.8
- sensiolabs-de/deptrac-shim: ^0.5.0
This package is auto-updated.
Last update: 2024-09-10 06:06:27 UTC
README
PhPresent 是一个库,允许您使用 Php 创建幻灯片程序,就像使用 JavaScript 的 RevealJs 一样。这是通过 Php-SDL 扩展 和 Imagick 扩展 实现的。
⚠️ 此库是全新的,它可能在您的特定环境中无法按预期工作。请尝试使用它,并欢迎提供有关它的反馈。
安装
确保已安装所需扩展
⚠️ 有时,我们可能需要尚未发布的 Php-SDL
的某些功能。请注意,某些版本可能需要直接从源代码编译扩展。
创建您的项目并通过 Composer 安装此库。
composer require bviguier/phpresent
用法
ℹ️ 查看代码目录中的 examples
以快速检查一切是否按预期为您工作。当您的程序运行时,按 h
键以获取有关可用命令的帮助。
启动您的演示文稿
<?php require __DIR__.'/../vendor/autoload.php'; // Contains specific implementation. use PhPresent\Adapter; // All stuff related to mathematics. use PhPresent\Geometry; // Here we speak about bitmaps, colours, fonts… use PhPresent\Graphic; // The heart of the matter, the tools to create a presentation. use PhPresent\Presentation; /** * You need 2 things to create a slideshow: * * A theme, to share some graphic expectations between slides (fonts, colors…) * * A background slide, that will be displayed… in the background! */ $presentation = new Presentation\SlideShow( Graphic\Theme::createDefault(), new Presentation\Template\Simple\FullscreenColor(Graphic\Color::white()) ); // Here, we will have to insert some slides (see next step) /** * The Screen class gives information about the rendering area. * Although the window will be resizeable, this initial screen ratio will be used to define the *safe* zone. * The safe zone is the larger available area in the screen with the expected size ratio. * It will guarantee the final rendering of your slides whatever the actual screen size. */ $screen = Presentation\Screen::fromSizeWithExpectedRatio(Geometry\Size::fromDimensions(640, 480)); /** * The engine that will render your presentation, thanks to SDL extension. */ $engine = new Adapter\SDL\Render\Engine($screen); /** * The drawer let you create complex images or texts. * Current implementation uses Imagick extension. */ $drawer = new Adapter\Imagick\Graphic\Drawer(); // Let's start the show! $engine->start($presentation, $drawer);
使用现有的幻灯片模板
一些模板包含在 PhPresent\Presentation\Template\Simple
命名空间中。
$presentation ->addSlide(new Presentation\Template\Simple\TitleAndSubtitle( 'PhPresent', 'A Slideshow tool' )) ->addSlide(new Presentation\Template\Simple\FullscreenAnimatedImage( $bitmapSequenceLoader->fromFile(__DIR__.'/../assets/images/whirlyGif.gif') )) ->addSlide(new Presentation\Template\Simple\BigTitle( "Hello\nWorld!" )) ;
创建您自己的幻灯片模板
提供的模板非常通用,您可能很快就会想创建自己的模板。查看 02-creating-slide.php
示例 了解其工作原理。
创建动画幻灯片
这是有趣的!有关详细信息,请查看 03-animating-slide.php
示例。
贡献
composer analyse
:静态代码分析composer cs
:代码风格(使用composer cs-fix
自动修复)composer deps
:检查命名空间之间的依赖关系composer ci
:运行所有之前的命令用于 CI