Sketch Interface

Discussion in 'ShapeJS' started by AlanHudson, Apr 15, 2017.

  1. AlanHudson
    AlanHudson Shapeways Employee Dev Team
    We've added an experimental Sketch interface for image parameters.

    sketch.jpg

    Try out these creators which have it turned on:

    Ornament
    https://shapejs.com/products/WlZD5ADTBE90/view
    Candy Dish:
    https://shapejs.com/products/Ga5aVMG1AcTs/view
    Tea light:
    https://shapejs.com/products/q4qcKTLAREG5/view

    In order to use it for your creators today you'll need to name a URI parameter "image". Next week we'll release a new shapejs server which will do it the right way.

    Going forward you'll set the mimeType of the uri param to "image/*" as in the following definition:

    {
    name: "image",
    desc: "Image",
    type: "uri",
    defaultVal: "https://static1.sw-cdn.net/files/cms/shapejs/images/icosa_sphere_part_thin20.png",
    mimeType: ["image/*"]
    }

    I'm still working through issues such as image size and background images.
     
    pendarestan likes this.
  2. AlanHudson
    AlanHudson Shapeways Employee Dev Team
    We've improved the sketch interface and added a few more fields for parameter management.

    The editor field lets you configure the editor. Currently only the DrawingCanvas is supported.

    {
    name: "image",
    desc: "Image",
    type: "uri",
    defaultVal: "https:\/\/static1.sw-cdn.net\/files\/cms\/shapejs\/images\/icosa_sphere_part_thin20.png",
    mimeType:"image/*",
    editor: {
    type: "DrawingCanvas",
    params: {
    backgroundImage: "/rrstatic/img/icosa_sphere_02.png",
    defaultAspectRatio: 1.62,
    imageType: "GRAY"
    }
    }
    },

    The backgroundImage controls whats behind the image. In this case since I knew the creator wanted half triangle input I put that there. The aspectRatio is typically 1. If you know images need to be different for best use then set that, its width / height.

    If your creator can support color images(more on that soon) then select imageType: "RGB".
    In order to get a DrawingCanvas for URI params you need to set the mimeType to "image/*". This says that the URI param is of type image. Other valid types would be something like stl, vrml etc, ie 3d models.

    In addition we added two other fields

    visible: true
    enabled: true

    These let you hide fields and say whether they can be edited. This is useful if your script has lots of parameters but users really only need to see a few of them. Ie my typical way of developing a script is to add as many params as I think of and then widdle them down to the few that users really want to edit.

    In terms of hosting for the images we still need to add the ability to add resources for a script. For now if you want to use a background image it will need to be a publically available url. If you have dropbox it has a public folder you can use.