cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


Save Automatically?

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.

              function Surface (jelem, width, height) {
    // Add an element to the surface
    // jelem:  jQuery object representing the DOM element
    // x,y:    Top left corner (virtual coordinates)
    // w,h:    Width and height of the element in (virtual coordinate sizes)
    // return: An integer representing the created surface element

    this.Add_Elem = function (jelem, x, y, w, h) {...};

    // Remove an element from the surface
    // ielem: index of the element to be removed.  This must be a value returned
    //        by Add_Elem
    this.Remove_Elem = function (ielem) {...};

    // Sets the scaling of the virtual coordinates to actual pixel positions on
    // the screen.
    // pwidth,pheight:  Pixel width and height of the surface that the virtual
                        coordinates must be mapped to
    this.Set_Scale = function (pwidth, pheight) {...};

    // Positions all the elements added to the surface based on the current
    // scaling
    this.Position_All = function () {...};

    // Move an element from it's current position to a new one
    // to_x, to_y:  The virtual coordinates to move the element to
    // callback:    a function to be called when the move has occured.  This is
    //              relevant when the move is animated and not happening
    //              instantly
    this.Move_Elem = function (ielem, to_x, to_y, callback) {...};

    // Change the duration of the animation of a move
    // offset:  The change to the current duration in milliseconds.  The initial
    //          duration is 300ms
    this.Change_Duration = function (offset) {...};

Loading ..................