Skip to content

Commit d2093a0

Browse files
committed
Start of retro text.
1 parent cc26fc5 commit d2093a0

File tree

11 files changed

+208
-68
lines changed

11 files changed

+208
-68
lines changed

config.source.php

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -33,66 +33,6 @@
3333
Config::IMAGICKDEMOS_ENVIRONMENT => 'local'
3434
];
3535

36-
37-
//
38-
//// Default settings
39-
//$default = [
40-
// 'varnish.pass_all_requests' => false,
41-
// 'varnish.allow_non_ssl' => false,
42-
// 'system.build_debug_php_containers' => false,
43-
// 'php.memory_limit' => getenv('php.memory_limit') ?: '64M',
44-
// 'php.web.processes' => 20,
45-
// 'php.web.memory' => '24M',
46-
// 'php.display_errors' => 'Off',
47-
//
48-
// 'php.post_max_size' => '1M',
49-
// 'php.opcache.validate_timestamps' => 0,
50-
//
51-
// Config::PHPOPENDOCS_ASSETS_FORCE_REFRESH => false,
52-
// Config::PHPOPENDOCS_COMMIT_SHA => $sha,
53-
//
54-
//
55-
// Config::PHPOPENDOCS_REDIS_INFO => [
56-
// 'host' => 'redis',
57-
// 'password' => 'ePvDZpYTXzT5N9xAPu24',
58-
// 'port' => 6379
59-
// ],
60-
//
61-
//// 'phpopendocs.allowed_access_cidrs' => [
62-
//// '86.7.192.0/24',
63-
//// '10.0.0.0/8',
64-
//// '127.0.0.1/24',
65-
//// "172.0.0.0/8", // docker local networking
66-
//// '192.168.0.0/16'
67-
//// ]
68-
//];
69-
//
70-
//// Settings for local development.
71-
//$local = [
72-
// 'varnish.pass_all_requests' => true,
73-
// 'varnish.allow_non_ssl' => true,
74-
75-
//
76-
// 'php.display_errors' => 'On',
77-
// 'php.opcache.validate_timestamps' => 1,
78-
//
79-
////// Redis connection settings
80-
//// Config::PHPOPENDOCS_REDIS_INFO => [
81-
//// 'host' => 'redis',
82-
//// 'password' => 'ePvDZpYTXzT5N9xAPu24',
83-
//// 'port' => 6379
84-
//// ],
85-
//
86-
//
87-
//// const PHPOPENDOCS_CORS_ALLOW_ORIGIN = 'http://local.phpopendocs.com';
88-
// Config::PHPOPENDOCS_ENVIRONMENT => 'local',
89-
// Config::PHPOPENDOCS_ASSETS_FORCE_REFRESH => true,
90-
//
91-
// // Domains. Used for generating links back to the platform,
92-
// // e.g. for stripe auth flow.
93-
// // $options['phpopendocs']['app_domain'] = 'http://local.app.phpopendocs.com';
94-
// ];
95-
9636
$prod = [
9737
Config::IMAGICKDEMOS_ENVIRONMENT => 'prod',
9838

containers/js_builder/entrypoint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -x
55

66
cd /var/app
77

8-
npm update
8+
# tail -f /var/app/README.md
99

10+
npm update
1011
npm run build:dev:watch

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"dependencies": {
4646
"argv": "0.0.2",
4747
"command-line-args": "^5.1.1",
48-
"preact": "^10.6.3",
48+
"preact": "^10.6.4",
4949
"promise-polyfill": "^8.2.1",
5050
"rc-slider": "^9.7.5",
5151
"react-colorful": "^5.5.1",

public/tsx/ControlPanel.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {h, Component} from "preact";
22
import {Integer} from "./components/Integer";
33
import {KernelMatrix} from "./components/KernelMatrix";
44
import {Number} from "./components/Number";
5+
import {TextInput} from "./components/TextInput";
56
import {ValueSelect} from "./components/ValueSelect";
67
import {triggerEvent, EventType, registerEvent, unregisterEvent} from "./events";
78
import {SelectOption} from "./components/Select";
@@ -28,6 +29,7 @@ interface Schema {
2829
maximum: (string|number|undefined);
2930
enum: Array<string>|undefined;
3031
type: OpenApiType;
32+
maxLength:(number|undefined);
3133
}
3234

3335
interface ControlInfo {
@@ -370,10 +372,20 @@ export class ControlPanel extends Component<AppProps, AppState> {
370372
return this.createEnumControl(control_info);
371373
}
372374

373-
console.log("Don't know how to render ");
375+
console.log("Attempting to render ");
374376
console.log(control_info);
375377

376-
return <div>I don't know how to render this string.</div>
378+
return <div>
379+
<TextInput
380+
name={map_api_name(control_info.name)}
381+
// @ts-ignore: blah blah blah
382+
default={control_info.schema.default}
383+
maxLength={control_info.schema.maxLength}
384+
updateFn={(newValue) => {
385+
this.setCurrentValue(control_info.name, newValue);
386+
}}
387+
/>
388+
</div>
377389
}
378390

379391
createKernelMatrixControl(control_info: ControlInfo) {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { h, Component } from 'preact';
2+
3+
4+
export interface TextInputProps {
5+
name: string;
6+
maxLength: number|undefined;
7+
value: number|string;
8+
updateFn?(newValue:any): void;
9+
}
10+
11+
export class TextInput extends Component<TextInputProps, {}> {
12+
13+
updateValue(value:string ) {
14+
let new_string = value;
15+
if (this.props.maxLength !== undefined) {
16+
new_string = value.slice(0, this.props.maxLength);
17+
}
18+
19+
this.props.updateFn(new_string);
20+
}
21+
22+
render() {
23+
return <span>
24+
{this.props.name}
25+
<input
26+
type="text"
27+
name={this.props.name}
28+
value={this.props.value}
29+
// @ts-ignore: blah blah
30+
onchange={(event) => this.updateValue(event.target.value) }
31+
/>
32+
</span>;
33+
}
34+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ImagickDemo\Params;
6+
7+
use Params\ExtractRule\GetStringOrDefault;
8+
use Params\InputParameter;
9+
use Params\Param;
10+
use Params\ProcessRule\MaxLength;
11+
12+
#[\Attribute]
13+
class UserText implements Param
14+
{
15+
public function __construct(
16+
private string $name,
17+
private int $max_length,
18+
private string $default
19+
) {
20+
}
21+
22+
public function getInputParameter(): InputParameter
23+
{
24+
return new InputParameter(
25+
$this->name,
26+
new GetStringOrDefault($this->default),
27+
new MaxLength($this->max_length)
28+
);
29+
}
30+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace ImagickDemo\Tutorial\Controls;
6+
7+
use ImagickDemo\Params\UserText;
8+
9+
use ImagickDemo\ToArray;
10+
use Params\Create\CreateFromVarMap;
11+
use Params\InputParameterList;
12+
use Params\InputParameterListFromAttributes;
13+
use Params\SafeAccess;
14+
15+
16+
class RetroControls implements InputParameterList
17+
{
18+
// use SafeAccess;
19+
use CreateFromVarMap;
20+
use ToArray;
21+
use InputParameterListFromAttributes;
22+
23+
public function __construct(
24+
#[UserText('first_line', 32, "First line")]
25+
private string $first_line,
26+
27+
#[UserText('second_line', 32, "Second line")]
28+
private string $second_line,
29+
) {
30+
}
31+
32+
/**
33+
* @return string
34+
*/
35+
public function getFirstLine(): string
36+
{
37+
return $this->first_line;
38+
}
39+
40+
/**
41+
* @return string
42+
*/
43+
public function getSecondLine(): string
44+
{
45+
return $this->second_line;
46+
}
47+
48+
49+
50+
51+
52+
// public function getValuesForForm(): array
53+
// {
54+
// return [
55+
// 'image_path' => getOptionFromOptions($this->image_path, getImagePathOptions()),
56+
// 'virtual_pixel_type' => getOptionFromOptions($this->virtualPixelType, getVirtualPixelOptions()),
57+
// ];
58+
// }
59+
60+
61+
}

src/ImagickDemo/Tutorial/functions.php

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,5 +1041,39 @@ function imageGeometryReset()
10411041
}
10421042
//Example end
10431043

1044-
1044+
//Example Tutorial::retro
1045+
function retro(\ImagickDemo\Tutorial\Controls\RetroControls $retroControls)
1046+
{
1047+
$imagick = new \Imagick();
1048+
$imagick->newPseudoimage(640, 480, 'gradient:black-white');
1049+
$imagick->setFormat('png');
1050+
1051+
$first_line = $retroControls->getFirstLine();
1052+
if (strlen(trim($first_line)) !== 0) {
1053+
$draw = new \ImagickDraw();
1054+
$draw->setFont("../fonts/CANDY.TTF");
1055+
$draw->setFontSize(64);
1056+
$draw->setFillColor('red');
1057+
$draw->setStrokeColor('white');
1058+
$draw->setStrokeWidth(3);
1059+
$draw->annotation(20, 80, $first_line);
1060+
$imagick->drawImage($draw);
1061+
}
1062+
1063+
$second_line = $retroControls->getSecondLine();
1064+
if (strlen(trim($first_line)) !== 0) {
1065+
$draw = new \ImagickDraw();
1066+
$draw->setFont("../fonts/CANDY.TTF");
1067+
$draw->setFontSize(64);
1068+
$draw->setFillColor('red');
1069+
$draw->setStrokeColor('white');
1070+
$draw->setStrokeWidth(3);
1071+
$draw->annotation(20, 280, $second_line);
1072+
$imagick->drawImage($draw);
1073+
}
1074+
1075+
header("Content-Type: image/png");
1076+
echo $imagick->getImageBlob();
1077+
}
1078+
//Example end
10451079
}

src/ImagickDemo/Tutorial/retro.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace ImagickDemo\Tutorial;
4+
5+
use ImagickDemo\Tutorial\Controls\RetroControls;
6+
7+
class retro extends \ImagickDemo\Example
8+
{
9+
public function renderTitle(): string
10+
{
11+
return "retro";
12+
}
13+
14+
public function renderDescription()
15+
{
16+
$text = <<< END
17+
retro generator
18+
END;
19+
20+
return nl2br($text);
21+
}
22+
23+
public static function getParamType(): string
24+
{
25+
return RetroControls::class;
26+
}
27+
}

0 commit comments

Comments
 (0)