load-shape

shape

shape-modeclj

load-shape

Arguments
[filename]
Docstring

Load a geometry from a file as a PShape in clj, and a Geometry in cljs.

Works only inside sketch functions?
Yes
Original Processing method
loadShape()
Original p5js method
loadModel()
Example
clojure specific
  • ; 
    ; setup
    ; 
    (let
      [sh (q/load-shape
            "https://upload.wikimedia.org/wikipedia/en/2/22/Heckert_GNU_white.svg")]
      (q/set-state! :shp sh))
    ; 
    ; draw
    ; 
    (let [sh (q/state :shp)]
      (q/shape sh)
      (q/shape sh 100 100)
      (q/shape sh 300 300 200 200))
clojurescript specific
  • ; 
    ; setup
    ; 
    (let [sh (q/load-shape "octahedron.obj")] (q/set-state! :shp sh))
    ; 
    ; draw
    ; 
    (let [sh (q/state :shp)] (q/shape sh))
    try example

shape

Arguments
[sh x y width height]clj[sh x y]clj[sh]
Docstring

Displays shapes to the screen. The shapes must have been loaded with load-shape. Processing currently works with SVG shapes only. The sh parameter specifies the shape to display and the x and y parameters define the location of the shape from its upper-left corner. The shape is displayed at its original size unless the width and height parameters specify a different size. The shape-mode function changes the way the parameters work. A call to (shape-mode :corners) for example, will change the width and height parameters to define the x and y values of the opposite corner of the shape.

Note complex shapes may draw awkwardly with the renderers :p2d, :p3d, and :opengl. Those renderers do not yet support shapes that have holes or complicated breaks.

Works only inside sketch functions?
Yes
Original Processing method
shape()
Original p5js method
model()
Example
clojure specific
  • ; 
    ; setup
    ; 
    (let
      [sh (q/load-shape
            "https://upload.wikimedia.org/wikipedia/en/2/22/Heckert_GNU_white.svg")]
      (q/set-state! :shp sh))
    ; 
    ; draw
    ; 
    (let [sh (q/state :shp)]
      (q/shape sh)
      (q/shape sh 100 100)
      (q/shape sh 300 300 200 200))
clojurescript specific
  • ; 
    ; setup
    ; 
    (let [sh (q/load-shape "octahedron.obj")] (q/set-state! :shp sh))
    ; 
    ; draw
    ; 
    (let [sh (q/state :shp)] (q/shape sh))
    try example

shape-modeclj

Arguments
[mode]
Docstring

Modifies the location from which shapes draw. Available modes are:

 * `:corner`  - specifies the location to be the upper left corner of the
              shape and uses the third and fourth parameters of shape
              to specify the width and height. **(default)**
 * `:corners` - uses the first and second parameters of shape to set
              the location of one corner and uses the third and fourth
              parameters to set the opposite corner.
 * `:center`  - draws the shape from its center point and uses the third
              and forth parameters of shape to specify the width and
              height.
Works only inside sketch functions?
Yes
Original Processing method
shapeMode()
Original p5js method
None.
Example
clojure specific
  • (let
      [sh (q/load-shape
            "https://upload.wikimedia.org/wikipedia/en/2/22/Heckert_GNU_white.svg")]
      (q/stroke-weight 5)
      (q/stroke 255 0 0)
      (q/shape-mode :corner)
      (q/shape sh 20 20 200 200)
      (q/point 20 20)
      (q/shape-mode :corners)
      (q/shape sh 270 20 370 120)
      (q/point 270 20)
      (q/point 370 120)
      (q/shape-mode :center)
      (q/shape sh 100 350 150 150)
      (q/point 100 350))