⚠ This website is the beta version of the PCIbex documentation and is still under development. ⚠
Link Search Menu Expand Document

Canvas element

since

beta 0.3

description

Creates a rectangular surface that other elements can be placed onto.

syntax

newCanvas("ELEMENT_NAME",WIDTH,HEIGHT)
  • "ELEMENT_NAME": The name of the newly-created element.
  • WIDTH : The width of the Canvas, in pixels.
  • HEIGHT : The height of the Canvas, in pixels.

note(s)

  • Use the CanvasCreation tool to help visualize Canvas layouts and generate code that can be added directly to a PennController script.

example

newImage("square", "square.png")
  .size(400, 400)
,
newImage("triangle", "triangle.png")
  .size(400, 400)
,
newCanvas("shapes", 800, 400)
    .add(   0, 0, getImage("square"))
    .add( 400, 0, getImage("triangle"))
    .print()
  1. Creates a 800x400px Canvas.
  2. Places the Image "square" at the (x=0, y=0) coordinate and the Image "triangle" at the (x=400, y=0) coordinate.

Action commands

canvas.add

syntax

getCanvas(“ELEMENT_NAME”).add()

description

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

example

click to expand
// example
↑ back to top

canvas.color

syntax

getCanvas(“ELEMENT_NAME”).color()

description

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

example

click to expand
// example
↑ back to top

canvas.log

syntax

getCanvas(“ELEMENT_NAME”).log()

description

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

example

click to expand
// example
↑ back to top

standard.after

syntax

getX(“ELEMENT_NAME”).after(getX(“ARGUMENT_NAME”))

description

Takes an element as an argument, and adds that element’s content to the right of the element that the command is called on.

example

click to expand

@// Option 1: Pass a new element as an argument
@newTrial("option-1",
@    newText("center", "BANANA")
@        .before(newText("left", "apple"))
$        .after(newText("right", "orange"))
@        .print()
@)
@
@// Option 2: Pass an existing element as an argument
@newTrial("option-2",
@    newText("left", "apple")
@    ,
@    newText("right", "orange")
@    ,
@    newText("center", "BANANA")
@        .before(getText("left"))
$        .after(getText("right"))
@        .print()
@)

↳ Prints appleBANANAorange to the screen.

↑ back to top

standard.before

syntax

getX(“ELEMENT_NAME”).before(getX(“ARGUMENT_NAME”))

description

Takes an element as an argument, and adds that element’s content to the left of the element that the command is called on.

example

click to expand

@// Option 1: Pass a new element as an argument
@newTrial("option-1",
@    newText("center", "BANANA")
$        .before(newText("left", "apple"))
@        .after(newText("right", "orange"))
@        .print()
@)
@
@// Option 2: Pass an existing element as an argument
@newTrial("option-2",
@    newText("left", "apple")
@    ,
@    newText("right", "orange")
@    ,
@    newText("center", "BANANA")
$        .before(getText("left"))
@        .after(getText("right"))
@        .print()
@)

↳ Prints appleBANANAorange to the screen.

↑ back to top

standard.center

syntax

getX(“ELEMENT_NAME”).center()

description

Horizontally centers the element.

example

click to expand

@newButton("centered-button", "Hello, button!")
$    .center()
@    .print()

↳ Prints a horizontally centered button that says Hello, button!.

↑ back to top

standard.css

syntax

getX(“ELEMENT_NAME”).css(“CSS_PROPERTY”, “VALUE”)

description

Applies the specified CSS property and value pair to the element.

example

click to expand

@newText("framed-text", "Hello, text!")
$    .css("border", "solid 1px red")
@    .print()
*,
@newButton("orchid-smallcaps-button", "Hello, button!")
$    .css({"background-color":"orchid", "font-variant":"small-caps"})
@    .print()

↳ Prints Hello, text! surrounded by a 1px solid red border. On a new line, prints a button with an orchid background color that says Hello, button! in small caps.

optional parameters

  • getX(“ELEMENT_NAME”).css({“CSS_PROPERTY_1”:”VALUE_1”, “CSS_PROPERTY_2”:”VALUE_2”})
↑ back to top

standard.cssContainer

syntax

getX(“ELEMENT_NAME”).cssContainer(“CSS_PROPERTY”, “VALUE”)

description

Applies the specified CSS property and value pair to the container of the element.

example

click to expand
newText("center", "BANANA")
    .before(newText("left", "apple"))
    .after(newText("right", "orange"))
    .css("color", "red")
    .cssContainer("background-color", "aqua")
    .print()

↳ Prints appleBANANAorange to the screen. The substring BANANA has a red text color, and the entire string has an aqua background color.

optional parameters

  • getX(“ELEMENT_NAME”).cssContainer({“CSS_PROPERTY_1”:”VALUE_1”, “CSS_PROPERTY_2”:”VALUE_2”})
↑ back to top

standard.hidden

syntax

getX(“ELEMENT_NAME”).hidden()

description

Hides an element. If the element is printed, it occupies space on the screen but its content is not visible.

example

click to expand

@newText("hidden-text", "Surprise!")
$    .hidden()
@    .print()
*,
@newButton("reveal", "Click to reveal a surprise")
@    .print()
@    .wait()
*,
@getText("hidden-text")
@    .visible()

↳ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

↑ back to top

standard.left

syntax

getX(“ELEMENT_NAME”).left()

description

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

example

click to expand
// example
↑ back to top

standard.print

syntax

getX(“ELEMENT_NAME”).print()

description

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

example

click to expand
// example
↑ back to top

standard.refresh

syntax

getX(“ELEMENT_NAME”).refresh()

description

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

example

click to expand
// example
↑ back to top

standard.remove

syntax

getX(“ELEMENT_NAME”).remove()

description

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

example

click to expand
// example
↑ back to top

standard.right

syntax

getX(“ELEMENT_NAME”).right()

description

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

example

click to expand
// example
↑ back to top

standard.scaling

syntax

getX(“ELEMENT_NAME”).scaling()

description

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

example

click to expand
// example

that zooms an element in/out to fit the argument(s), which can be: a ratio (with 1 for 100%), a unit dimension (eg. “10vw”), or the page/screen (pass "page")

↑ back to top

standard.selector

syntax

getX(“ELEMENT_NAME”).selector()

description

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

example

click to expand
// example
↑ back to top

standard.setVar

syntax

getX(“ELEMENT_NAME”).setVar()

description

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

example

click to expand
// example
↑ back to top

standard.size

syntax

getX(“ELEMENT_NAME”).size()

description

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

example

click to expand
// example
↑ back to top

standard.visible

syntax

getX(“ELEMENT_NAME”).visible()

description

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

example

click to expand

@newText("hidden-text", "Surprise!")
@    .hidden()
@    .print()
*,
@newButton("reveal", "Click to reveal a surprise")
@    .print()
@    .wait()
*,
@getText("hidden-text")
$    .visible()

↳ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

↑ back to top

Test commands


standard.test.printed

syntax

getX(“ELEMENT_NAME”).test.printed()

description

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

example

click to expand
// example
↑ back to top