| 1 | ##---------------------------------------------------------------------------- | ||||||||||
| 2 | ## HTML Object - ~/lib/HTML/Object/DOM/Element/Canvas.pm | ||||||||||
| 3 | ## Version v0.2.0 | ||||||||||
| 4 | ## Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||
| 6 | ## Created 2021/12/23 | ||||||||||
| 7 | ## Modified 2022/09/18 | ||||||||||
| 8 | ## All rights reserved | ||||||||||
| 9 | ## | ||||||||||
| 10 | ## | ||||||||||
| 11 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||
| 12 | ## under the same terms as Perl itself. | ||||||||||
| 13 | ##---------------------------------------------------------------------------- | ||||||||||
| 14 | package HTML::Object::DOM::Element::Canvas; | ||||||||||
| 15 | BEGIN | ||||||||||
| 16 | { | ||||||||||
| 17 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 1 | ▶ | warnings::register_categories( 'HTML::Object' ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 1 | ▶ | use parent qw( HTML::Object::DOM::Element ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 1 | ▶ | use vars qw( $VERSION ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 1 | ▶ | use HTML::Object::DOM::Element::Shared qw( :canvas ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 1 | our $VERSION = 'v0.2.0'; | |||||||||
| 24 | }; | ||||||||||
| 25 | |||||||||||
| 26 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | |||||||||||
| 29 | sub init | ||||||||||
| 30 | { | ||||||||||
| 31 | 0 | ▶ | my $self = shift( @_ ); | ||||||||
|
Subroutine
init: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 32 | 0 | $self->{_init_strict_use_sub} = 1; | |||||||||
| 33 | 0 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | ▶ | $self->{tag} = 'canvas' if( !CORE::length( "$self->{tag}" ) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | return( $self ); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub captureStream { return; } | ||||||||
|
Subroutine
captureStream: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | sub getContext { return; } | ||||||||
|
Subroutine
getContext: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 41 | |||||||||||
| 42 | # Note: property height is inherited | ||||||||||
| 43 | |||||||||||
| 44 | # Note: property | ||||||||||
| 45 | 0 | ▶ | sub mozOpaque : lvalue { return( shift->_set_get_property( { attribute => 'moz-opaque', is_boolean => 1 }, @_ ) ); } | ||||||||
|
Subroutine
mozOpaque: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 46 | |||||||||||
| 47 | # Note: property | ||||||||||
| 48 | 0 | ▶ | sub mozPrintCallback : lvalue { return( shift->_set_get_code( 'mozprintcallback', @_ ) ); } | ||||||||
|
Subroutine
mozPrintCallback: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub onwebglcontextcreationerror : lvalue { return( shift->on( 'webglcontextcreationerror', @_ ) ); } | ||||||||
|
Subroutine
onwebglcontextcreationerror: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | sub onwebglcontextlost : lvalue { return( shift->on( 'webglcontextlost', @_ ) ); } | ||||||||
|
Subroutine
onwebglcontextlost: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | sub onwebglcontextrestored : lvalue { return( shift->on( 'webglcontextrestored', @_ ) ); } | ||||||||
|
Subroutine
onwebglcontextrestored: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | sub toBlob { return; } | ||||||||
|
Subroutine
toBlob: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | sub toDataURL { return; } | ||||||||
|
Subroutine
toDataURL: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub transferControlToOffscreen { return; } | ||||||||
|
Subroutine
transferControlToOffscreen: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 61 | |||||||||||
| 62 | # Note: property width is inherited | ||||||||||
| 63 | |||||||||||
| 64 | 1 | 1; | |||||||||
| 65 | # NOTE: POD | ||||||||||
| 66 | __END__ | ||||||||||
| 67 | |||||||||||
| 68 | =encoding utf-8 | ||||||||||
| 69 | |||||||||||
| 70 | =head1 NAME | ||||||||||
| 71 | |||||||||||
| 72 | HTML::Object::DOM::Element::Canvas - HTML Object DOM Canvas Class | ||||||||||
| 73 | |||||||||||
| 74 | =head1 SYNOPSIS | ||||||||||
| 75 | |||||||||||
| 76 | use HTML::Object::DOM::Element::Canvas; | ||||||||||
| 77 | my $canvas = HTML::Object::DOM::Element::Canvas->new || | ||||||||||
| 78 | die( HTML::Object::DOM::Element::Canvas->error, "\n" ); | ||||||||||
| 79 | |||||||||||
| 80 | =head1 VERSION | ||||||||||
| 81 | |||||||||||
| 82 | v0.2.0 | ||||||||||
| 83 | |||||||||||
| 84 | =head1 DESCRIPTION | ||||||||||
| 85 | |||||||||||
| 86 | This interface provides properties and methods that are used for the C<<canvas>> element. However, since this is a perl framework, there is no such capability and it is provided here only to implement the properties and methods as accessors. | ||||||||||
| 87 | |||||||||||
| 88 | This interface also inherits the properties and methods of the L<HTML::Object::Element> interface. | ||||||||||
| 89 | |||||||||||
| 90 | =head1 INHERITANCE | ||||||||||
| 91 | |||||||||||
| 92 | +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+ | ||||||||||
| 93 | | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Canvas | | ||||||||||
| 94 | +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +------------------------------------+ | ||||||||||
| 95 | |||||||||||
| 96 | =head1 PROPERTIES | ||||||||||
| 97 | |||||||||||
| 98 | Inherits properties from its parent L<HTML::Object::DOM::Element> | ||||||||||
| 99 | |||||||||||
| 100 | The description provided here is from Mozilla documentation. | ||||||||||
| 101 | |||||||||||
| 102 | =head2 height | ||||||||||
| 103 | |||||||||||
| 104 | The height HTML attribute of the C<<canvas>> element is a positive integer reflecting the number of logical pixels (or RGBA values) going down one column of the canvas. When the attribute is not specified, or if it is set to an invalid value, like a negative, the default value of 150 is used. If no [separate] CSS height is assigned to the C<<canvas>>, then this value will also be used as the height of the canvas in the length-unit CSS Pixel. | ||||||||||
| 105 | |||||||||||
| 106 | Example: | ||||||||||
| 107 | |||||||||||
| 108 | <canvas id="canvas" width="300" height="300"></canvas> | ||||||||||
| 109 | |||||||||||
| 110 | my $canvas = $doc->getElementById('$canvas'); | ||||||||||
| 111 | say( $canvas->height ); # 300 | ||||||||||
| 112 | |||||||||||
| 113 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/height> | ||||||||||
| 114 | |||||||||||
| 115 | =head2 mozOpaque | ||||||||||
| 116 | |||||||||||
| 117 | Is a boolean value reflecting the moz-opaque HTML attribute of the <canvas> element. It lets the canvas know whether or not translucency will be a factor. If the canvas knows there's no translucency, painting performance can be optimized. This is only supported in Mozilla-based browsers; use the standardized canvas.getContext('2d', { alpha: false }) instead. | ||||||||||
| 118 | |||||||||||
| 119 | Example: | ||||||||||
| 120 | |||||||||||
| 121 | <canvas id="canvas" width="300" height="300" moz-opaque></canvas> | ||||||||||
| 122 | |||||||||||
| 123 | my $canvas = $doc->getElementById('$canvas'); | ||||||||||
| 124 | say( $canvas->mozOpaque ); # true | ||||||||||
| 125 | # deactivate it | ||||||||||
| 126 | $canvas->mozOpaque = 0; | ||||||||||
| 127 | |||||||||||
| 128 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/mozOpaque> | ||||||||||
| 129 | |||||||||||
| 130 | =head2 mozPrintCallback | ||||||||||
| 131 | |||||||||||
| 132 | Is a function that is initially C<undef>. Web content can set this to a JavaScript function that will be called when the canvas is to be redrawn while the page is being printed. When called, the callback is passed a C<printState> object that implements the C<MozCanvasPrintState> interface. The callback can get the context to draw to from the C<printState> object and must then call C<done()> on it when finished. The purpose of C<mozPrintCallback> is to obtain a higher resolution rendering of the canvas at the resolution of the printer being used. L<See this blog post|https://blog.mozilla.org/labs/2012/09/a-new-way-to-control-printing-output/>. | ||||||||||
| 133 | |||||||||||
| 134 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/mozPrintCallback> | ||||||||||
| 135 | |||||||||||
| 136 | =head2 width | ||||||||||
| 137 | |||||||||||
| 138 | The width HTML attribute of the <canvas> element is a positive integer reflecting the number of logical pixels (or RGBA values) going across one row of the canvas. When the attribute is not specified, or if it is set to an invalid value, like a negative, the default value of 300 is used. If no [separate] CSS width is assigned to the <canvas>, then this value will also be used as the width of the canvas in the length-unit CSS Pixel. | ||||||||||
| 139 | |||||||||||
| 140 | Example: | ||||||||||
| 141 | |||||||||||
| 142 | <canvas id="canvas" width="300" height="300"></canvas> | ||||||||||
| 143 | |||||||||||
| 144 | my $canvas = $doc->getElementById('$canvas'); | ||||||||||
| 145 | say( $canvas->width ); # 300 | ||||||||||
| 146 | |||||||||||
| 147 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/width> | ||||||||||
| 148 | |||||||||||
| 149 | =head1 METHODS | ||||||||||
| 150 | |||||||||||
| 151 | Inherits methods from its parent L<HTML::Object::DOM::Element> | ||||||||||
| 152 | |||||||||||
| 153 | Keep in mind that none of those methods do anything and they all return C<undef>. The description provided here is from Mozilla documentation. | ||||||||||
| 154 | |||||||||||
| 155 | =head2 captureStream | ||||||||||
| 156 | |||||||||||
| 157 | Returns C<undef> since this feature is unavailable under perl. | ||||||||||
| 158 | |||||||||||
| 159 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/captureStream> | ||||||||||
| 160 | |||||||||||
| 161 | =head2 getContext | ||||||||||
| 162 | |||||||||||
| 163 | Returns C<undef> since this feature is unavailable under perl. | ||||||||||
| 164 | |||||||||||
| 165 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext> | ||||||||||
| 166 | |||||||||||
| 167 | =head2 toBlob | ||||||||||
| 168 | |||||||||||
| 169 | Returns C<undef> since this feature is unavailable under perl. | ||||||||||
| 170 | |||||||||||
| 171 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob> | ||||||||||
| 172 | |||||||||||
| 173 | =head2 toDataURL | ||||||||||
| 174 | |||||||||||
| 175 | Returns C<undef> since this feature is unavailable under perl. | ||||||||||
| 176 | |||||||||||
| 177 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL> | ||||||||||
| 178 | |||||||||||
| 179 | =head2 transferControlToOffscreen | ||||||||||
| 180 | |||||||||||
| 181 | Returns C<undef> since this feature is unavailable under perl. | ||||||||||
| 182 | |||||||||||
| 183 | See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen> | ||||||||||
| 184 | |||||||||||
| 185 | =head1 AUTHOR | ||||||||||
| 186 | |||||||||||
| 187 | Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> | ||||||||||
| 188 | |||||||||||
| 189 | =head1 SEE ALSO | ||||||||||
| 190 | |||||||||||
| 191 | L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement>, L<Mozilla documentation on canvas element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas> | ||||||||||
| 192 | |||||||||||
| 193 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 194 | |||||||||||
| 195 | Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||
| 196 | |||||||||||
| 197 | All rights reserved | ||||||||||
| 198 | |||||||||||
| 199 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||
| 200 | |||||||||||
| 201 | =cut | ||||||||||