const NOK_COLOR = '#D0167C';
const CONFETTI_COLOR = '#E4FF19';
- protected $animations=[];
+ const TEXT_COLOR = "#ffffff";
+
+ protected $animations = [];
/**
* @param $vdir VirtualDirectory
$colors = [
self::OK_COLOR => $this->theme->okColor,
self::CONFETTI_COLOR => $this->theme->okColor,
- self::NOK_COLOR => $this->theme->nokColor
+ self::NOK_COLOR => $this->theme->nokColor,
+ self::TEXT_COLOR => $this->theme->getTextsColor(),
];
$animationReplace = [];
$animationPregReplace = [];
// Replace colors
foreach ($colors as $from => $to) {
- $f = (new Color($from))->toLottie(5,true);
+ $f = (new Color($from))->toLottie(5, true);
$t = (new Color($to))->toLottie();
- $animationPregReplace['/\[' . $f[0] . ',' . $f[1] . ',' . $f[2] . '/'] = '[' . $t[0] . ',' . $t[1] . ',' . $t[2];
+ $animationPregReplace['/"c":{"a":0,"k":\[' . $f[0] . ',' . $f[1] . ',' . $f[2] . '/'] = '"c":{"a":0,"k":[' . $t[0] . ',' . $t[1] . ',' . $t[2];
+ $animationPregReplace['/"fc":\[' . $f[0] . ',' . $f[1] . ',' . $f[2] . '/'] = '"fc":[' . $t[0] . ',' . $t[1] . ',' . $t[2];
}
// Replace font
$font = FluidbookFont::getAvailableFonts()[$this->theme->font ?: 'SourceSans'];
use Cubist\Util\CommandLine\Imagemagick;
use Cubist\Util\Files\Files;
use Cubist\Util\Graphics\Resizer;
+use function PHPUnit\Framework\matches;
class QuizTheme extends ToolboxModel
{
protected function _font()
{
$this->addField('sectionTexts', FormSection::class, __('Textes'));
- $this->addField('textColor', SelectFromArray::class, __('Couleur des textes'), ['default' => 'auto', 'options' => ['auto' => __('Automatique'), '#ffffff' => __('Blanc'), '#000000' => __('Noir')]]);
+ $this->addField('textColor', SelectFromArray::class, __('Couleur des textes'), ['default' => 'auto', 'options' => ['auto' => __('Automatique'), 'light' => __('Blanc'), 'dark' => __('Noir')]]);
$this->addField('font', FluidbookFont::class, __('Police de caractères'), ['default' => 'SourceSans', 'databaseDefault' => 'SourceSans']);
}
$this->addField('backgroundImageMobile', FluidbookThemeImage::class, __('Image ou animation'), ['hint' => __('Taille recommandée : :size', ['size' => '390 x 844px']), 'when' => ['backgroundCustom' => 1]]);
}
-
protected function _intro()
{
$this->addField('sectionIntro', FormSection::class, __('Écran d\'introduction'));
public function getTextsColor()
{
+ $darkColor = '#383838';
+ $lightColor = '#ffffff';
+
if ($this->textColor == 'auto' || !$this->textColor) {
// If auto mode, check between black and white which have the biggest distance (i.e. most contrast) with neutralColor
$neutral = new \Cubist\Util\Graphics\Color($this->neutralColor);
- $black = new \Cubist\Util\Graphics\Color('#000000');
- $white = new \Cubist\Util\Graphics\Color('#ffffff');
+ $black = new \Cubist\Util\Graphics\Color($darkColor);
+ $white = new \Cubist\Util\Graphics\Color($lightColor);
$distBlack = $neutral->distance($black);
$distWhite = $neutral->distance($white);
if ($distWhite > $distBlack) {
- return '#ffffff';
+ return $lightColor;
} else {
- return '#000000';
+ return $darkColor;
}
}
- return $this->textColor;
+ return match ($this->textColor) {
+ 'dark' => $darkColor,
+ '#000000' => $darkColor,
+ '#ffffff' => $lightColor,
+ 'light' => $lightColor,
+ };
}
/**