The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

HTML::Object::DOM::Element::Canvas - HTML Object DOM Canvas Class

SYNOPSIS

    use HTML::Object::DOM::Element::Canvas;
    my $canvas = HTML::Object::DOM::Element::Canvas->new || 
        die( HTML::Object::DOM::Element::Canvas->error, "\n" );

VERSION

    v0.2.0

DESCRIPTION

This interface provides properties and methods that are used for the <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.

This interface also inherits the properties and methods of the HTML::Object::Element interface.

INHERITANCE

    +-----------------------+     +---------------------------+     +-------------------------+     +----------------------------+     +------------------------------------+
    | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Canvas |
    +-----------------------+     +---------------------------+     +-------------------------+     +----------------------------+     +------------------------------------+

PROPERTIES

Inherits properties from its parent HTML::Object::DOM::Element

The description provided here is from Mozilla documentation.

height

The height HTML attribute of the <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 <canvas>, then this value will also be used as the height of the canvas in the length-unit CSS Pixel.

Example:

    <canvas id="canvas" width="300" height="300"></canvas>

    my $canvas = $doc->getElementById('$canvas');
    say( $canvas->height ); # 300

See also Mozilla documentation

mozOpaque

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.

Example:

    <canvas id="canvas" width="300" height="300" moz-opaque></canvas>

    my $canvas = $doc->getElementById('$canvas');
    say( $canvas->mozOpaque ); # true
    # deactivate it
    $canvas->mozOpaque = 0;

See also Mozilla documentation

mozPrintCallback

Is a function that is initially 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 printState object that implements the MozCanvasPrintState interface. The callback can get the context to draw to from the printState object and must then call done() on it when finished. The purpose of mozPrintCallback is to obtain a higher resolution rendering of the canvas at the resolution of the printer being used. See this blog post.

See also Mozilla documentation

width

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.

Example:

    <canvas id="canvas" width="300" height="300"></canvas>

    my $canvas = $doc->getElementById('$canvas');
    say( $canvas->width ); # 300

See also Mozilla documentation

METHODS

Inherits methods from its parent HTML::Object::DOM::Element

Keep in mind that none of those methods do anything and they all return undef. The description provided here is from Mozilla documentation.

captureStream

Returns undef since this feature is unavailable under perl.

See also Mozilla documentation

getContext

Returns undef since this feature is unavailable under perl.

See also Mozilla documentation

toBlob

Returns undef since this feature is unavailable under perl.

See also Mozilla documentation

toDataURL

Returns undef since this feature is unavailable under perl.

See also Mozilla documentation

transferControlToOffscreen

Returns undef since this feature is unavailable under perl.

See also Mozilla documentation

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

Mozilla documentation, Mozilla documentation on canvas element

COPYRIGHT & LICENSE

Copyright(c) 2021 DEGUEST Pte. Ltd.

All rights reserved

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.