{{ store.width }} x {{ store.height }}

JSON Save Restore

{{ item.title }}

{{ definition.value }}

We can convert a Point or PointList to JSON. Any pointlist will cast and parse from a string:

const strPoints = points.toJSON()
`[
    [250,150,10,270],
    [450,520,8,270]
]`
points.fromJSON(stringPoints)

In this example, any change is written to localStorage. Refreshing the page will restore the previous changes. A JSON dump of stage.points exists in localStorage["polypoint-json-example"]

Meta Data
title JSON Save Restore
imports ()
files ('../point_src/core/head.js', '../point_src/pointpen.js', '../point_src/pointdraw.js', '../point_src/math.js', '../point_src/extras.js', '../point_src/point-content.js', '../point_src/pointlist.js', '../point_src/pointlistpen.js', '../point_src/point.js', '../point_src/stage.js', 'mouse', 'dragging', 'stroke')
unused_keys ()
unknown_keys ('categories',)
categories ['json']
filepath_exists True
path json-example
filepath json-example.js
clean_files ('../point_src/core/head.js', '../point_src/pointpen.js', '../point_src/pointdraw.js', '../point_src/math.js', '../point_src/extras.js', '../point_src/compass.js', '../point_src/center.js', '../point_src/point-content.js', '../point_src/pointlistdraw.js', '../point_src/pointlistgradient.js', '../point_src/pointlistshape.js', '../point_src/pointlistgenerator.js', '../point_src/unpack.js', '../point_src/pointlist.js', '../point_src/pointlistpen.js', '../point_src/relative-xy.js', '../point_src/pointcast.js', '../point_src/point.js', '../point_src/stage-resize.js', '../point_src/functions/resolve.js', '../point_src/stage.js', '../point_src/events.js', '../point_src/automouse.js', '../point_src/functions/clamp.js', '../point_src/distances.js', '../point_src/protractor.js', '../point_src/text/beta.js', '../point_src/dragging.js', '../point_src/setunset.js', '../point_src/stroke.js')
Logger Install Logger {{ store.words }}
{{ store.errorText.message }}
{{ store.errorText.stackText }}