Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                    // This file demonstrates how to present lines.
    // There are two ways to define a line.
    // Note: You can not specify both the angle and positions for the same object.
    
    const jsPsych = initJsPsych({
        on_finish: function() {
            jsPsych.data.displayData();
        }
    })
    console.log(`jsPsych Version ${jsPsych.version()}`)

    const pixi_flag = jsPsych.data.getURLVariable('pixi_flag') === '1' ? true : false;

    const instruction = {
        type: jsPsychHtmlButtonResponse,
        stimulus: 'Click on the Start button.',
        choices: ['Start'],
        prompt: "This is a sample program for the jspsych-psychophysics plugin.",
    }

    // The line_object1 defines a line using the angle and line_length.
    const line_object1 = {
        obj_type: 'line',        
        startX: 200, // location in the canvas
        startY: 400,
        angle: 45,
        line_length: 200,
        line_width: 4,
        line_color: 'black', // You can use the HTML color name instead of the HEX color.
        show_start_time: 500, // ms after the start of the trial
        endX: 300,
        endY: 400,
        motion_start_time: 1500,
        motion_end_time: 3000,
    }

    // The line_object2 defines a line using the start and end positions.
    const line_object2 = {
        obj_type: 'line',
        x1: 300,
        y1: 200,
        x2: 200,
        y2: 400,
        line_width: 6,
        line_color: 'red', // You can use the HTML color name instead of the HEX color.
        show_start_time: 1000, // ms after the start of the trial
        vert_pix_frame: 5,
        motion_start_time: 1500,
        motion_end_time: 3000,
    }

    const trial = {
        type: jsPsychPsychophysics,
        pixi: pixi_flag,
        stimuli: [line_object1, line_object2],
    }

    jsPsych.run([instruction, trial])
              
            
!
999px

Console