From 1354ae066c991f1c6814ef64cb5b57b751176e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20M=C3=B6nig?= Date: Wed, 23 Mar 2022 11:54:04 +0100 Subject: [PATCH] SciSnap2 extension update (ImagePad), thanks, Eckart! --- HISTORY.md | 2 + libraries/SciSnap!2Blocks.xml | 2 +- libraries/SciSnapExtensions.js | 626 +++++++++++++++++++++++++++++++-- 3 files changed, 592 insertions(+), 38 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index d6914589..86d54464 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -9,6 +9,7 @@ * exporting a library includes dependencies (auto-select all referenced blocks) * exporting / importing a sprite includes dependencies (global custom blocks and palette categories) * moved "append", "reshape", "combinations" blocks down one group in the palette + * SciSnap2 extension update (ImagePad), thanks, Eckart! * **Notable Fixes:** * fixed relabelling "sum", "product", "minimum" and "maximum" reporters * fixed relabelling local custom blocks to global ones and vice-versa @@ -24,6 +25,7 @@ ### 2022-03-23 * byob: fixed #3020 +* SciSnap2 extension update (ImagePad), thanks, Eckart! ### 2022-03-22 * blocks: fixed relabelling "sum", "product", "minimum" and "maximum" reporters diff --git a/libraries/SciSnap!2Blocks.xml b/libraries/SciSnap!2Blocks.xml index 2c352d15..8beabbc3 100644 --- a/libraries/SciSnap!2Blocks.xml +++ b/libraries/SciSnap!2Blocks.xml @@ -1 +1 @@ -Initialization of SciSnap!
Creates global variables "SciSnap!Properties", "SciSnap!Data", and "SciSnap!Messages". Sets the default values of global SciSnap!-properties for items typeOfData width height minValue maxValue columns rows maxSetValue
Returns the value of an existing global SciSnap!-property or "not found". Items: typeOfData width height minValue maxValue columns rows maxSetValue
minValuetypeOfData width height minValue maxValue columns rows maxSetValue
Sets the value of an existing global SciSnap!-property or inserts it anew. Items: typeOfData width height minValue maxValue columns rows maxSetValue
minValuetypeOfData width height minValue maxValue columns rows maxSetValue
Shows the message with headline in the middle of the window.
headlinetheMessage
Adds a new entry to SciSnap!Messages and shows the error message.
something wrong!
Reports a copy of a costume.
Reports the costume of a sprite.
Returns a random number between 0 and 1.
Reports Pi.
Reports Euler's number.
Rounds value x to n digits.
1.23572
Reports n faculty.
50
Reports a binomial coefficient.
531result1n1i1
Test on vector, matrix, table, predicate, interval, list of intervals, set, or complex-number.
vectorvector transposed-vector matrix table complex-number complex-number-Cartesian-style complex-number-polar-style set comparisonOperator interval listOfIntervals numericalListcomplex-numbercomplex-number-Cartesian-stylecomplex-number-polar-styletransposed-vectorvectormatrixwidth11table1width1SciS_isTable(data)intervalfalselistOfIntervalsset2344listOfIntervals55numericalListfalse
Reports a substring of a string.
thisString14
Reports a string without first/all instances of substring.
allall firstthisthisString
Reports a string in upper case.
thisString
Reports a string in lower case.
ThisString
Stores a string in a file.
this textthis file
Reports the index of first appearance of substring in string.
ringthisString
Reports a string with replacement instead of substring.
allall firstthisthatthisString
Reports date and time in standard notation.
day10hour10minute10second10--T::
seconds todayJulian Date decimal years days this year hours this year minutes this year seconds this year hours today minutes today seconds todayYYYY17MM54DD21h12m45s7daysi11402Julian Date2JD365.2530.6001172099531121531101215821260360024
Takes any number of Boolean (true/false) inputs (use the left and right arrowheads to adjust the number of input slots) and reports TRUE only if all of the inputs are TRUE, otherwise FALSE. Like AND but for multiple inputs.
pt:todas as afirmações _ são verdadeiras 1
Takes any number of Boolean (true/false) inputs (use the left and right arrowheads to adjust the number of input slots) and reports TRUE if at least one input is TRUE, otherwise FALSE.
pt:alguma das afirmações _ é verdadeira 1
Returns an empty costume of the given width and height with background color r/g/b.
400300245245245
Tests the value of a property.
falsetypeOfConfigurationMathPad
Reports the row or column name of the row or column with the number entered, or reports an error message.
columncolumn row1SciSnap!Datatable0columnrow
Turns a row-wise (in Lisp terminology) function into a column-wise one.
Takes a dyadic scalar function as input, and hyperizes it, so that it can take lists as inputs. Don't use on slow functions (this has compiled map calls). Meant for use on primitives.
ab
pt:a aplicação a _ de _ 1
Evaluates the predicate with a given parameter.
ringified predicate
Evaluates the intervals with a given parameter.
ringified predicateitem3<true
Reports the intersection of two sets.
set1set2are these two sets?setresultset2234element34element344
Reports the union of two sets.
set1set2are these two sets?setresultset223344
Reports the difference between two sets.
set1set2are these two sets?setresultset2234element32set1set24433m14n1m1compare the mth interval with all intervals of set144
Reports the Cartesian product between two sets.
set1set2set4040resultset22item_133
implication
10
equivalence
10
Converts numbers to booleans
1
Converts booleans to numbers
true
Intervals should be of structure [leftLimit,operator1,operator2,rightLimit]
2resultn1
1111111111212121212121212
Intervals should be of structure [leftLimit,operator1,operator2,rightLimit]
11define left edge and operator44define right edge and operator
11resultn1m1n1
11resultn1
0listOfIntervalsitemfalse
Returns all elements of a list not covered by the predicate.
Returns all elements of a list not covered by the intervals.
result3lst_sort(list, fn)34
Test wether the predicate is translatable to a list of intervals.
ringified predicate1comparisonOperator112233false
Intervals should be of structure [leftLimit,operator1,operator2,rightLimit]
interval1interval2intersection0result1144341444341444
1141413<232<3<2<4414142<323<2<3<true
Creates a new empty costume of the specified size and color and sets the local properties
thisSpritethisSprite theStage anotherSprite400300245245245costumeWidthcostumeHeightscaleProperties2212126-10-102211600falsefalsefalsefalsetruetruefalseStagecostume properties: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for Image position on stage 7: upper offset for Image position on stage 8: front color red 9: front color green 10: front color blue line properties: 1: line width 2: line style 3: line color red 4: line color green 5: lineColor blue marker properties: 1: marker style 2: marker width 3: marker connected 4: marker color red 5: marker color green 6: marker color blue data properties: 1: minValue 2: maxValue 3: columns 4: rows scale offsets: 1:left offset 2: right offset 3: upper offset 4: lower offset labels: 1: title 2: x label 3: y label 4: title height 5: x label height 6: y label height 7: x unit 8: y unit ranges: 1: x left 2: x right 3: y lower 4: y upper scale properties: 1: scales x precision 2: scales y precision 3: scales x textheight 4: scales y textheight 5: scales x intervals 6: scales y intervals 7: scales x start 8: scales y start 9: scales x step 10: scales y step 11: scales x scaling 12: scales y scaling 13: scales ticlength 14: scales x minitics 15: scales y minitics 16: scales x grid 17: scales y grid 18: scales x centered 19: scales y centered 20: scales show x scale 21: scales show y scale 22: plot border
thisSpritethisSprite theStage anotherSprite
Reads the value of an existing property.
costumePropertiestypeOfConfiguration typeOfData costumeProperties lineProperties markerProperties dataProperties scaleOffsets labels ranges scalePropertiesthisSpritethisSprite theStage anotherSpriteresultnot foundname1 hmyProperties
Sets the value of an existing property or inserts it anew.
costumePropertiestypeOfConfiguration typeOfData costumeProperties lineProperties markerProperties dataProperties scaleOffsets labels ranges scalePropertiesthisSpritethisSprite theStage anotherSpritename1 donefalsehmyPropertiesmyProperties
a simple way to set some costume attributes: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for Image position on stage 7: upper offset for Image position on stage 8: front color red 9: front color green 10: front color blue
40030024524524518018018000thisSpritethisSprite theStage anotherSpriteStage
a simple way to set some net attributes: line properties: 1: line style 2: lineWidth 3: line color red 4: line color green 5: lineColor blue
continuouscontinuous dashed dash-dot dot-dot rainbow inverse-rainbow1000thisSpritethisSprite theStage anotherSpritelineProperties
a simple way to set some net attributes: marker properties: 1: marker style 2: marker width 3: marker connected 4: marker color red 5: marker color green 6: marker color blue
squarenone o_circle ._point +_plus x_ex square triangle5000falsethisSpritethisSprite theStage anotherSpritemarkerProperties
Sets some properties for scales.
2212121010thisSpritethisSprite theStage anotherSpritescalePropertiesscaleProperties123456scaleProperties
Sets the labels and textheights of the diagrams of a PlotPad.
thisSpritethisSprite theStage anotherSpriteDiagram Title18x-label16y-label16labels
Sets the distances of the diagram axes to the edges of the Sketchpad.
thisSpritethisSprite theStage anotherSpriteupperOffset13scalePropertiesUPPER OFFSET1labels013scaleProperties0lowerOffset13scalePropertiesLOWER OFFSET19scalePropertiesrightOffset1.54scalePropertiesRIGHT OFFSET.13scaleProperties0leftOffset14scalePropertiesLEFT OFFSET18scaleProperties13scaleProperties0scaleOffsets
Sets the ranges for the axes of the diagrams of a Sketchpad.
-1010-1010false0.1truethisSpritethisSprite theStage anotherSpriterangesranges
Draws the graph of a function given as rigified Snap!-function or coefficient-list of a polynomial.
ringified operator or polynomialthisSpritethisSprite theStage anotherSpritevectorSciS_addGraphToPlotpad(costume,ranges,offsets,lineattributes,aFunction,proc)rangesscaleOffsetslineProperties
Draws the data points of a two-dimensional table with numerical values. With a lot of additions from Rick Hessman. Thanks!
myDatathisSpritethisSprite theStage anotherSpritemyDatamatrix12SciS_addNumericDataplotToPlotpad(costume,ranges,offsets,labels,lineattributes,dataattributes,data)rangesscaleOffsetslabelslinePropertiesmarkerProperties
Draws the data points of a two-dimensional table with numerical values in column 2. Text values should be used to set the x-label.
myDatatruetruethisSpritethisSprite theStage anotherSpritemyDatatableSciS_addMixedDataplotToPlotpad(costume,ranges,offsets,labels,lineattributes,dataattributes,data)rangesscaleOffsetslabelslinePropertiesmarkerPropertiesscalePropertiesscalePropertieswasXscaled?20wasYscaled?212021scaleProperties
Draws a histogram of histogram data.With a lot of additions by Rick Hessman. Thanks!
myData10truethisSpritethisSprite theStage anotherSpritemyDatavector0transposed-vectorminmaxdeltah2resulti1221i1source0.1SciS_addHistogramToPlotpad(costume,ranges,offsets,lineattributes,data,datapointattributes)rangesscaleOffsetslinePropertiesmarkerProperties
Draws and labels the axes of a PlotPad. With lot of additions of Rick Hessman. Thanks!
thisSpritethisSprite theStage anotherSpriteSciS_addAxesAndScalesToPlotpad(costume,scaleattributes,labels,offsets,ranges,plotcolors)scalePropertieslabelsscaleOffsetsrangescostumeProperties
thisSpriteSciS_newcostume(w,h,r,g,b)3costumeProperties4costumeProperties5costumeProperties
Sets the ranges to "pretty" values. Many thanks to Rick Hessman!
thisSpritethisSprite theStage anotherSpritescalePropertiesscalePropertiesrangesrangespretty125get dictionary of pretty values.72192311245631261427pretty346get dictionary of pretty values.821102312246842261527rangesscaleProperties
"Pretty" scaling from Rick Hessman. Many thanks!
-1010620002000Numbers are too big for pretty printing.nintpretty0.0010.0020.0050.010.020.050.10.20.512510205010020050010002000between91341341341341341341places33322211100000000000sign2index1i21dticnintresultdeltanstartstart*scaling is the actual starting value (start is the value displayed next to the tic)stop1stepstep*scaling is the actual stepping value (step is the difference between the tic labels).scalingintervalsprecisionminitics
thisSpritethisSprite theStage anotherSpritemyData0.1myData2dy43ranges1234scalePropertiesscaleProperties7192151111418310436121151scaleProperties
Calculates the ranges of two columns of a table.
Conversion of coordinates.
100xpxp yp x ythisSpritethisSprite theStage anotherSpriteoffsetsscaleOffsetsrangesrangesdiagramWidth1diagramHeight34x0112y0443coordinate1 xpypxy
Obtaining coordinates of a PlotPad by mouse.
costume-coordinatescostume-coordinates graph-coordinatesthisSpritethisSprite theStage anotherSpriteselection1 targetCostumetargetCostumeWidthtargetCostumeHeighttargetXPositiontargetYPositiontargetSizecostume-coordinatescostume coordinates.graph-coordinatescostume coordinates.
400300xycontinuouso_circle000
400300xycontinuous000
00600400continuousnone continuous dashed dash-dot dot-dot rainbow inverse rainbowsquarenone o_circle ._point +_plus x_ex square triangle000
Changes the Snap!-Logo. ;-)
Creates SQL variables and sets some properties.
Establishes connection and sets the corresponding properties. Change parameters if necessary.
connectionhttps://snapextensions.uni-goettingen.de/mysqlquery.php?server=db1&user=snapexuser&password=snap!userconnection&type=connect12ok0115ERROR
Imports the results of an SQL-query to SQLData and sets the corresponding properties.
typeOfDatatable0minValuenotSetmaxValuenotSet
Reports a list of databases on the server and sets the corresponding properties.
dbsconnection&type=getDBs000115ERROR
Selects one of the databases and sets the corresponding properties.
2databasescurrentDatabasedatabasesresultconnection&command=USE currentDatabasetablestablesconnection&command=SHOW TABLES FROM currentDatabase&type=getTables000115ERROR
Reports a list of tables of the chosen database and sets the corresponding properties.
tblsconnection&command=SHOW TABLES FROM currentDatabase&type=getTables000115ERROR
Reads the attributes of the specified table and sets the corresponding properties.
1databases0115ERROR
Selects one of the tables and sets the corresponding properties.
1tables0115ERROR
Generates a simplified SQL query.
* DISTINCTi11result FROM 0result2
Generates an almost complete SQL query.
* DISTINCTASCASC DESC10i11result FROM 0result20result20resultASC
Executes an SQL query.
1:ERROR
Returns an SQL predicate.
Returns an SQL predicate.
Returns an SQL predicate.
Returns an SQL predicate.
Returns an SQL predicate.
Returns an SQL predicate.
Returns an SQL predicate.
Returns an SQL predicate.
Returns an SQL value.
Returns an SQL value.
Returns an SQL value.
Returns an SQL value.
Returns an SQL value.
Creates a new empty costume of the specified size and color and sets local properties. If sprite is the stage, the old costume# of stage is stored. So you can draw graphs on maps, for example.
thisSpritethisSprite theStage anotherSprite400300245245245targettheStageStagethisSpriteStagetheStagecostume properties: 1: width 2: height 3: back color red 4: back color green 5: back color blue vertex properties: 1: ranges for random coordinates (xLeft,xRight, yUpper,yLower) 2: minimal radius of a vertex, should be changed is vertices are not growing with number of edges 3: boolean: vertices grow with number of connected edges 4: boolean: vertex content is shown. If there is no content, the vertex number is shown edge properties: 1: line width 2: line color red 3: line color green 4: line color blue 5: boolean: edge is directed 6: boolean: edge has a weight 7: boolean: edge shows weight
thisSpritethisSprite theStage anotherSprite
Reads the value of an existing property.
costumePropertiestypeOfConfiguration typeOfData costumeProperties vertexProperties edgePropertiesthisSpritethisSprite theStage anotherSpriteresultnot foundname1 hmyProperties
Sets the value of an existing property or inserts it anew.
costumePropertiestypeOfConfiguration typeOfData costumeProperties vertexProperties edgePropertiesthisSpritethisSprite theStage anotherSpritename1 donefalsehmyPropertiesmyProperties
a simple way to set some costume attributes. 1: width 2: height 3: back color red 4: back color green 5: back color blue
400300245245245thisSpritethisSprite theStage anotherSpritecostumeProperties
a simple way to set some vertex attributes: 1: ranges for random coordinates (xLeft,xRight, yUpper,yLower) 2: minimal radius of a vertex, should be changed is vertices are not growing with number of edges 3: boolean: vertices grow with number of connected edges 4: boolean: vertex content is shown. If there is no content, the vertex number is shown
3truefalsethisSpritethisSprite theStage anotherSpritevertexProperties1vertexPropertiesThe ranges are maintained.
a simple way to set some edge attributes: 1: line width 2: line color red 3: line color green 4: line color blue 5: boolean: edge is directed 6: boolean: edge has a weight 7: boolean: edge shows weight
1000falsefalsefalsethisSpritethisSprite theStage anotherSpriteedgeProperties
100100thisSpritethisSprite theStage anotherSprite1vertexListvertexList
adds n vertices to the vertexList of a GraphPad: Vertex attributes have the following order: 1: x 2: y 3: size 4: content 5: isMarked 6: colorNr 7: numberOfLinks
1thisSpritethisSprite theStage anotherSpritevertexListSciS_addVerticesToVertexlist(n,vlist,vAttributes)vertexListvertexPropertiesadjacencyMatrixSciS_addVerticesToAdjacencymatrix(n,amatrix)adjacencyMatrix
Moves a vertex to another position measured in Snap! sprite-coordinates
1thisSpritethisSprite theStage anotherSprite100100vertexList
Creates n new edges randomly.
1thisSpritethisSprite theStage anotherSpriteresultSciS_addRandomEdgesToGraph(amatrix,n,lAttributes,vlist)adjacencyMatrixedgePropertiesvertexListadjacencyMatrix1vertexList2
Creates a new edge between two vertices.
12thisSpritethisSprite theStage anotherSprite0vertexList0vertexListadjacencyMatrixXadjacencyMatrixX5edgeProperties
draws the graph on a GraphPad.
thisSpritethisSprite theStage anotherSpriteStageoldCostumeStageSciS_drawGraph(amatrix,vlist,cAttributes,vAttributes,lAttributes,oldCostume)adjacencyMatrixvertexListcostumePropertiesvertexPropertiesedgeProperties
Deletes a vertex.
1thisSpritethisSprite theStage anotherSprite0vertexListvertexListadjacencyMatrix
Deletes an edge.
12thisSpritethisSprite theStage anotherSprite0vertexList0vertexListadjacencyMatrix05edgeProperties
12thisSpritethisSprite theStage anotherSprite0vertexList0vertexList
Sets the weight of an edge.
121thisSpritethisSprite theStage anotherSprite0vertexList0vertexList
thisSpritethisSprite theStage anotherSpritefrom vertex nr
Input for start vertex.
thisSpritethisSprite theStage anotherSpritenew start vertexwidth (1....20)
1thisSpritethisSprite theStage anotherSprite0vertexList
Sets the content of a vertex.
1thisSpritethisSprite theStage anotherSprite0vertexList
Input for a new vertex content.
thisSpritethisSprite theStage anotherSpritevertex number
Tells a vertex to be marked.
1thisSpritethisSprite theStage anotherSprite0vertexList
Deletes a marker.
1thisSpritethisSprite theStage anotherSprite0vertexList
Deletes all markers.
thisSpritethisSprite theStage anotherSpriteitemvertexList
Depth first search in a graph.
1thisSpritethisSprite theStage anotherSprite0vertexList
Breadth first search in a graph.
1thisSpritethisSprite theStage anotherSprite0vertexList
Reports the distance of two vertices.
thisSpritethisSprite theStage anotherSprite120vertexList0vertexList
Shortes path between two vertices, using Dijkstra-method.
12thisSpritethisSprite theStage anotherSprite0vertexList0vertexList
Shortes paths between startVertex and all connected vertices, using Dijkstra-method.
1thisSpritethisSprite theStage anotherSprite0vertexList
Returns the vertexnumber of a vertex near (x|y), if there is one.
10050thisSpritethisSprite theStage anotherSpriteSciS_vertexnumberAtGraph(vlist,cAttributes,vAttributes,x,y)vertexListcostumePropertiesvertexProperties
00thisSpritethisSprite theStage anotherSpritetargetSize10011001
Reports the vertexnumber of the vertex with the specified content. If not found then reports 0.
PeterthisSpritethisSprite theStage anotherSpritenr0itemvertexListFamilyTree
numberXdiagramSpriteDiagramSpriteDiagramSprite400300245245245DiagramSpriteEdges per Node18Number of Edges16Number of Vertices1610trueDiagramSpriteDiagramSprite
spriteName
spriteName
Imports a stored sprite from a file.
new name
Imports stored blocks to another palette. All blocks should be from the same category!
Lookslibrarybegincategory=10end"50oldcat2libraryall""""SciS_importLibrary2(src)
Creates a new empty costume of the specified size and color ans sets local properties for a NeuralNet.
thisSpritethisSprite theStage anotherSprite400300245245245costumeWidthcostumeHeightStagecostume properties: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for NN position on stage 7: upper offset for NN position on stage neural net properties: 1: number of layers 2: layer width 3: width of NN image 4: height of NN image
thisSpritethisSprite theStage anotherSprite
Reads the value of an existing property.
netPropertiestypeOfConfiguration typeOfData costumeProperties netPropertiesthisSpritethisSprite theStage anotherSpriteresultnot foundname1 hmyProperties
Sets the value of an existing property or inserts it anew.
netPropertiestypeOfConfiguration typeOfData costumeProperties netPropertiesthisSpritethisSprite theStage anotherSpritename1 donefalsehmyPropertiesmyProperties
a simple way to set some costume attributes: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for NN position on stage 7: upper offset for NN position on stage
40030024524524500thisSpritethisSprite theStage anotherSpritecostumeProperties
a simple way to set some net attributes: 1: number of layers 2: layer width 3: width of NN image 4: height of NN image
23400300thisSpritethisSprite theStage anotherSpritenetProperties
Reports the output of the nth layer of a neural network with given input.
last1 lastthisSpritethisSprite theStage anotherSpritevector2netProperties
Creates a fully connected neural network of perceptrons. Inputs should be connected to layer 1, outputs to last layer.
23thisSpritethisSprite theStage anotherSpritemyDataone matrix for each layer1myDatapropertiesnetPropertiesnetProperties34typeOfDataweights
Draws the nodes and current status of connections of an NN as new costume.
thisSpritethisSprite theStage anotherSpritenetWidth2netPropertiesSciS_NNshowStatus(cAttributes,nAttributes,weights,outputs,costume,sprite)costumePropertiesnetPropertiesmyData
A block for teaching a neural net.
0.1thisSpritethisSprite theStage anotherSpritewidth2netPropertiesmyDataSciS_NNteach(weights,width,depth,input,output,eta)myData1netProperties
thisSpritethisSprite theStage anotherSprite
creates a temporary or static Sprite.
truenewSprite
Removes the calling sprite.
Reports the row or column number of the row or column with the name entered, or reports an error message. If the the name is a number You can mark this with a # (e.g. #123).
columncolumn rownameSciSnap!Datatable010columnfirstlast1#n0i10i100ERROR: name not found!rowfirstlast1#n0i10i10ERROR: name not found!ERROR: something wrong!
Input dialog for a list of items. Click item by mouse and then ok. Returns the selected item.
thisSpritethisSprite theStage anotherSpritetitlewidth9costume400245245245continuous1000245245245 (click on it)102018truei12530505281218true70301005ok751218trueokfalse70100305
Returns an empty table.
Reports a new table initialized with value.
23result
Reports a table with labeled columns.
20i1rowERROR: labels required!
Reports the copy of a list or an empty list.
Imports table-CSV-data, costume-data, SQL-data or FITS-data to SciSnap!Data.
costume-(RGB)-datatable-(CSV)-data costume-(RGB)-data SQL-(query)-data FITS-datacurrent-costumecurrent-costume filepicker other-sourceFITS-datatable-(CSV)-datacolumns10rows1000hmaxcolumnSciSnap!DatatrueminValuemaxValuecostume-(RGB)-datahminValuemaxValueSQL-(query)-datatypeOfDatatable0columns10rows1000hmaxcolumntrueminValuemaxValue
Reads a file using the filepicker.
Stores a list in a CSV file. JS-code copied from Snap!-code.
SciSnap!Datafilename
Reports randomly distributed points in the form of a rectangle, circle, or ring.
100-100100-100100squaresquare circle ringcirclering
Creates new random data in the specified ranges swaying by a straight.
10-55102
Generates a list of points "near" a given graph.
20-552
Creates the transpose of a table or a list.
01valuevaluetableERROR: data are not transposable!
Adds a row, a column, or column headers to a table.
rowrow column column-headersSciSnap!Datachoice1 tablerowi1column0i1column-headersi11
Reports the row or column of a table identified by number or name, or reports an error message. If the the name is a number You can mark this with a # (e.g. #123).
rowrow columnnumberOrNamefirst last numberOrNameSciSnap!Datatruechoice1 tablerowlast1columnlast11ERROR: something wrong!
Deletes a row or column of a table. identified by number or name, or reports an error message. If the the name is a number You can mark this with a # (e.g. #123).
rowrow columnnumberOrNamefirst last numberOrNameSciSnap!Datatablerowlastcolumnlast11item
Reports the element a position x|y of a table, identified by numbers or names.
numberOrNamenumberOrNameSciSnap!Datatablexcolumnyrow001
Replaces the value at position x|y of a table.
numberOrNamenumberOrNameSciSnap!Datatablexcolumnyrow001
Reports the columns from row startnr to row endnr.
SciSnap!DatanumberOrNamelastlast numberOrNametablelaststartnrrowendnrrowcolNumbersitemSciS_columncopy(data,cols,start,stop)
Reports a subsection of an image or table.
RGB-datatable-data matrix-data list-data RGB-data FITS-dataSciSnap!DatanumberOrNamenumberOrNamenumberOrNamenumberOrNamelist-dataresultdummyvalueindextable-datamatrix-datab1columnb2rowe1columne2rowbeginendSciS_subsection(data,begin,end)RGB-dataFITS-dataRGB-datawidthwidthheightheightFITS-datawidthwidthheightheightbeginendSciS_subsectionImage(data,begin,end,width,height)
Determines the rows of a table with certain properties.
SciSnap!DatanumberOrNameless-thanless-than greater-than equal-to different-fromtablencolumn11op1less-thangreater-thanequal-todifferent-from
counts the appearances of the values of a list.
sortedDatacountedValuesvalue1n0item
returns the entropy of a list of data
Copy of corresponding Snap!-library-block: Reports a new list whose items are the same as in the input list, except that if two or more equal items appear in the input list, only the last one is kept in the result.
SciSnap!Datatable
Normalizes a table by dividing it by the specified value.
SciSnap!Datameanmean max number sum median softmaxchoice1 vector0
Reports a compressed version of a vector or matrix.
SciSnap!Data2isMatrixmatrixvector11resulti11iresultcolumnNr11
Pooling operation with matrices, images and vectors.
maxmax meanSciSnap!Data21typeOfPooling1 matrixvectorFITSRGBmatrixFITSRGBSciS_pooling(data,width,height,typeOfPooling,stride,typeOfData)
Reports a sorted list.
Sorts a list or table.
SciSnap!DatanumberOrNametruetrueisTabletableresult1
Determines a group of properties of a table.
meanmin max number sum meannumberOrNameSciSnap!DatanumberOrNametruetablegroupcolumncolumn11valuecolumncolumn11choice1 copytruecolumn0SciS_groupeddata(aTable,compaircolumn,operation,groupcolumn)
Calculates the ranges, the covariance or the correlation between two columns of a table.
rangesranges covariance correlationnumberOrNamenumberOrNameSciSnap!Datatruetablencolumn11mcolumn11copychoice1 1SciS_propertiesoftable(selection,table,x,y)1
Calculates the parameters of a regression line.
SciSnap!DatamatrixsumX0sumY0numerator0denominator0dummymeanXmeanYdummymb
Determines the next k neighbours of a point in data. The class of the point has to be in column 3.
5SciSnap!Datatablepoint2neighbors3truetruetable-data114
Applies a convolution to a table with FITS, RGB, or table values.
tableimage tableSciSnap!Data100100matrixSciS_convolution(kernel,data,width,height,typeOfData,mIndex,kWidth)
Custering of n-dimensional data with k-means-method. Cluster numbers are attached to the data.
3SciSnap!DatamatrixSciS_k-means-clustering(k,data)
Custering of n-dimensional data with k-means-method. A metric has to be delivered as a ringified term. Cluster numbers are attached to the data.
3SciSnap!Dataringified operatormatrixresultadd cluster number 0 to datadimension1minmaxi1calculate min and max for all columnscentersi1choose k random centerscalculate min and max for all columnsanyChangestruen0anyChangesfalsedummycenter1pointbuild clustersadjust centers
Metric for Strtings.
SaturdaySunday
labels of data: -1 not visited, 0 visited, -2 noise, >0 clusternr
SciSnap!Data505matrix2SciS_DBSCAN(data,r,minMembers)-1
reports a ID3 decision tree constructed on the base of labeled data
0empty datasetcountedValuescolumnlasttrue1only one result --> ready11only one attribut left --> readyinformation gainsi111calculate information gains for all attributesinformation gains2falsetruecompareColumn11take attribute with max information gain as compare criterioncountedValuescolumntruelinksitemrecursive construction of ID3 trees for all other attributesnode11
Creates a new empty costume of the specified size and color and sets local properties
thisSpritethisSprite theStage anotherSprite400300245245245costumeWidthcostumeHeightStagecostume properties: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for Image position on stage 7: upper offset for Image position on stage line properties: 1: lineWidth 2: line color red 3: line color green 4: lineColor blue data properties: 1: minValue 2: maxValue 3: columns 4: rows image properties: 1: type (RGB,FITS) 2: imageWidth 3: imageHeight
thisSpritethisSprite theStage anotherSprite
Reads the value of an existing property.
costumePropertiestypeOfConfiguration typeOfData costumeProperties lineProperties dataProperties imagePropertiesthisSpritethisSprite theStage anotherSpriteresultnot foundname1 hmyProperties
Sets the value of an existing property or inserts it anew.
costumePropertiestypeOfConfiguration typeOfData costumeProperties lineProperties dataProperties imagePropertiesthisSpritethisSprite theStage anotherSpritename1 donefalsehmyPropertiesmyProperties
a simple way to set some costume attributes: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for Image position on stage 7: upper offset for Image position on stage
40030024524524500thisSpritethisSprite theStage anotherSpriteStage
a simple way to set some net attributes: line properties: 1: line style 2: lineWidth 3: line color red 4: line color green 5: lineColor blue 6: fill color red 6: fill color green 8: fill color blue
continuouscontinuous dashed dash-dot dot-dot1000180180180thisSpritethisSprite theStage anotherSpritelineProperties
Generates an image from the FITS or RGB data of the DataSprite in gray or false colors
graygray false-color RGBmyData0255falsethisSpritethisSprite theStage anotherSpritecolor1 sourcemyDatamyDatatypeOfDataFITS1costumePropertiestheStage2costumePropertiestheStage1costumeProperties2costumeProperties1costumeProperties2costumeProperties1costumePropertiestheStage2costumePropertiestheStage1costumeProperties2costumeProperties
Imports costume-data or FITS-data to a data list.
costume(RGB)datacostume(RGB)data FITSDatacurrentCostumecurrentCostume filepicker list with dimensions at topmyDatathisSpritethisSprite theStage anotherSpritechoice1 filepickerFITSData6typeOfConfigurationImagePadmyPropertiestypeOfDataFITSmyPropertieslineProperties1000myPropertiesdataProperties16myPropertiesimagePropertiesFITSmyPropertiesheader5011Stagecostume(RGB)dataw1h211costumeDatacostumePropertiesminmin123maxmax123typeOfConfigurationImagePadmyPropertiestypeOfDataRGBmyPropertieslineProperties1000myPropertiesdataProperties1myPropertiesimagePropertiesRGBmyPropertiesStage
Draws a line on present costume using line properties. Attention: JS coordinates are used.
1010100100thisSpritethisSprite theStage anotherSprite
Draws a rectangle on present costume using line properties. Attention: JS coordinates are used.
1010100100thisSpritethisSprite theStage anotherSpriteSciS_drawRectangleOnImagepad(costume,x1,y1,width,height,lineAttributes)lineProperties
Fills a rectangle on present costume using surface properties. Attention: JS coordinates are used.
1010100100thisSpritethisSprite theStage anotherSpriteSciS_fillRectangleOnImagepad(costume,x1,y1,width,height,lineAttributes)lineProperties
Draws a circle on present costume using line properties. Attention: JS coordinates are used.
10010020thisSpritethisSprite theStage anotherSpriteSciS_drawCircleOnImagepad(costume,x,y,radius,lineAttributes)lineProperties
Fills a circle on present costume using surface properties. Attention: JS coordinates are used.
10010020thisSpritethisSprite theStage anotherSpriteSciS_fillCircleOnImagepad(costume,x,y,radius,lineAttributes)lineProperties
Draws a text on present costume using line properties. Attention: JS coordinates are used.
my text1005012truethisSpritethisSprite theStage anotherSpriteSciS_drawTextOnImagepad(costume,x,y,text,height,horizontal,lineAttributes)lineProperties
Sets the RGB value al (x|y) on costume. Attention: JS-coordinates are used!
11thisSpritethisSprite theStage anotherSprite255100301costumeProperties2costumeProperties11
Reports the RGB value at the position (x|y) of the costume. JS-code-snippets copied from Snap!-code. Attention: JS-coordinates are used!
11thisSpritethisSprite theStage anotherSprite1costumeProperties2costumeProperties11
Sets the value at (x|y) in myData. Attention: JS-coordinates are used!
11thisSpritethisSprite theStage anotherSpritetypeOfDataRGBtypeOfDataFITS
Reads the data value at the position (x/y) of an image stored in myData. Attention: JS-coordinates are used!
11thisSpritethisSprite theStage anotherSpritetypeOfDataRGBtypeOfDataFITS
Obtaining data with the mouse from an image stored in myData.
image-valueimage-value costume-coordinates slice-data line-data circle-data brightnessthisSpritethisSprite theStage anotherSpriteselection1 targetCostumetargetCostumeWidthtargetCostumeHeightStagecostume-coordinatescostume coordinates.line-dataokfalseokfalsexold1yold21212Stageline dataimage-value11image valueslice-dataslice datacircle-datacircle dataokfalseokfalsecontinuous32552000180180180112112continuous1255200018018018012Stagebrightnessbrightness
Applies an affine transformation to a costume.
currentCostumeoktrueP11P22P33Q11Q22Q33S1221221220ERROR: denominator is zero
Reports the brightness of a FITS or RGB image around x|y in a circle with radius r. Attention: JS-coordinates are used!
10010010thisSpritethisSprite theStage anotherSpritedatamyDatatypeOfDataFITStypeOfDataRGB
Draws a list of "point" as "balls". Attention: JS-coordinates are used!
myDatacirclescircles squares5thisSpritethisSprite theStage anotherSpritesourcemyDatamatrix012SciS_drawListOfPoints(costume,data,shape,size,lineAttributes)121lastlineProperties
thisSpritethisSprite theStage anotherSprite
Returns the vertexnumber of a vertex near mouse position, if there is one.
thisSpritethisSprite theStage anotherSpriteSciS_vertexnumberAtGraph(vlist,cAttributes,vAttributes,x,y)vertexListcostumePropertiesvertexProperties
returns the class of a dataset using an ID3-decision-tree
1leaf (unambiguous)1nodei1ERROR: no sensefull data to compare found!
Reports a vector, built by the items.
Returns a new vector of dimension n with random elements.
3110
Returns a matrix formed from the input vectors.
length1resultitem
Returns a new nxm-matrix with random elements.
32110i1
Creates the transpose of a vector or a matrix.
valuevalue
Determines a property of a vector.
minmin max minpos maxpos number sum mean median variance standard-deviation softmaxdatatransposed-vector1choice1 softmaxmedianminmaxnumbersummeanminposmaxposvariancestandard-deviationvariancestandard-deviationERROR: unknown option!
Linear operations with scalars, vectors and matrices.
*+ - * X-*ERROR: illegal operation between numbers!vectormatrixERROR: illegal operation with numbers!vectorvector+-*Xmatrixvector matrix operationERROR: illegal operation with vectors!matrixvectormatrix vector operationmatrixmatrix matrix operation-*ERROR: wrong operation!ERROR: illegal operation
Applies a mapping matrix to an object that is given as a matrix of points.
Soves a linear system of max. 50 equations.
some tests for correct data01transposed-vectormatrixcreates matrix with attached column bsolvedtruen50i1dTry to solve matrixr1rowswap rowshelpnormalize row1k11k1k1diagonalizer1
Reports a list of matrix A in triangle form, the rank of A, column change and column positions.
0Aba copy of A is used to let A unchangedrankrow1columchangefalsecolumn positions11i1search downwardsi1search to the rightc0row1row1row-1transform to diagonal form E
Calculates the coefficients of the interpolation polynomial for a 2xn-matrix of points.
212matrixcreate matrix of powers of x and y-valuesolvedtruen50i1j-12dTry to solve matrixr1rowswap rowshelpnormalize row1k11k1k1diagonaizer1
Calculates the value of a polynomial for input x.
polynomial as list of coefficients11result12i3
Applies an affine transformation to a list of points.
SciSnap!DataoktrueP11P22P33Q11Q22Q33S1221221220ERROR: denominator is zero
Reports a complex number in Cartesian style.
23
Reports a complex number in polar style.
230
Reports a complex number in polar style.
Reports a complex number in Cartesian style.
Reports properties of complex numbers.
real-partabsolute-value real-part imaginary-part phase conjugatereal-partimaginary-partphaseconjugateERROR: unknown operator!
Reports arithmetic results of two complex numbers.
++ - * /complex-numbercomplex-number-polar-stylecomplex-number-polar-style+-*/complexNumberCartesianStyle22333223
Creates a new empty costume of the specified size and color and sets local properties
thisSpritethisSprite theStage anotherSprite400300245245245theStagecostumeWidthcostumeHeighttheStagecostume attributes: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for MathPad position on stage 7: upper offset for MathPad position on stage other attributes: 1: line width 2: draw only ponts, not arrows 3: dimension of coordinate system 4: max. value on scales 5: start point of arrows
thisSpritethisSprite theStage anotherSprite
Reads the value of an existing property.
costumePropertiestypeOfConfiguration typeOfData costumeProperties lineProperties dimension maxValue startPointthisSpritethisSprite theStage anotherSpriteresultnot foundname1 hmyProperties
Sets the value of an existing property or inserts it anew.
costumePropertiestypeOfConfiguration typeOfData costumeProperties lineProperties dimension maxValue startPointthisSpritethisSprite theStage anotherSpritename1 donefalsehmyProperties
a simple way to set some costume attributes: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for MathPad position on stage 7: upper offset for MathPad position on stage
40030024524524500thisSpritethisSprite theStage anotherSpritecostumeProperties
a simple way to set some MathPad attributes: 1: line width 2: draw only ponts, not arrows 3: dimension of coordinate system 4: max. value on scales 5: start point of arrows
1false310000thisSpritethisSprite theStage anotherSpriteoldDimensiondimensionoldMaxValuemaxValuelinePropertiesdimensionmaxValuestartPoint
Draws axes on a MathPad in 2 or 3 dimensions.
thisSpritethisSprite theStage anotherSpriteSciS_mathpadaddaxes(cAttributes,type,maxValue,dimension,costume)costumePropertiestypeOfDatamaxValuedimension
Draws a vector, complex number or object of points from the start point stored in the properties.
vectorvector complex-number line-to object-of25500thisSpritethisSprite theStage anotherSpritefalsedataobject-ofdimension1SciS_mathpadplot(costume,data,r,g,b,maxValue,linewidth,dimension,onlypoints,cAttributes,startpoint,choice)maxValue1linePropertiesdimension2linePropertiescostumePropertiesstartPointcomplex-numberdata23dimensionSciS_mathpadplot(costume,data,r,g,b,maxValue,linewidth,dimension,onlypoints,cAttributes,startpoint,choice)maxValue1linePropertiesdimension2linePropertiescostumePropertiesstartPoint
Returns a root of an equation calculated with Newton's method.
ringified term1epsilon0.00001fi110001000
Reports an element of a sequence.
ringified term1
Returns a list of the n first elements of a sequence.
1ringified termresulti1
Returns a list of secant slopes calculated with the given sequence.
ringified term21/nresulti1
Reports the secant slope "nearby" the given point.
ringified term1epsilon0.00001
Returns a finite sum.
10ringified term10result0i
Returns the integral of a term calculated with n trapezoids.
2ringified term11000result0dxx1
Reports either - data Fourier transformed to frequency-space - "raw" FFT (Fast Forier Transformation)data formatted as SciSnap! complex numbers - or iFFT real data
frequency_spectrumfrequency_spectrum complex_FFTdata iFFT_of_FFTdata100iFFT_of_FFTdataSciS_FFTops(data,freq,choice)
Reports coefficient of the binomial distribution b(N,p,k)=(N choose k)*p^k(1-p)^(N-k)
100.12ERROR: wrong parameter!
Reports binomial distribution B(N,p,k).
1100.1ERROR: wrong parameter!
Reports coefficient of the hypergeometric distribution.
10352ERROR: wrong parameter!
Reports hypergeometric distribution.
11035ERROR: wrong parameter!
Reports coefficient of the Poisson distribution.
0.052ERROR: wrong parameter!
Reports Poisson distribution.
20.05ERROR: wrong parameter!
Reports coefficient of the Pareto distribution.
132
Reports coefficient of the normal distribution.
101
The empty set.
The real (computer-) numbers.
Returns a set by listing the elements, predicates, and defined intervals. The sequence is: set isNumerical list of elements list of intervals predicate.
Creation of a set by a predicate. Intervals and elements should be defined by another block. If possible the predicate is translated to a list of intervals. The sequence is: set isNumerical list of elements list of intervals predicate.
ringified predicatepredicateTreeERROR: pure predicate sets are not supported yet.
Returns a set with one numerical interval. The sequence is: set isNumerical list of elements list of intervals predicate.
-Infinity-Infinity≤ <≤ <InfinityInfinitysettrue
Reports whether "element" is element of "set".
elementset43
Reports the intersection, union, difference, or cross product of two sets.
set1∩ ∪ \ Xset2are these two sets?set\set1set24433m14n1m1compare the mth interval with all intervals of set144Xresultset22item_133
Is set1 subset of set2?
set1set2are these two sets?setinterval4element3Compare elementstrue
Are theses two sets equal?
set1set2set
Reports up to n elements of a set. Numers are natural numbers smaller than maxSetValue in SciSnap!-properties.
10setresult340i1maxSetValue should be close to infinity ;-)resultvalueindexlistclean up1
Reports simple types, sets and lists as string.
i1maxSetValue should be close to infinity ;-)elementsvalueindexlist20item18is first elementtrueitem18ERROR: no simple type!
Converts a string to a list of elements.
1,2,[3,4],{6,7,8..12}]10]0]0}10}0}0find lists
\ No newline at end of file +Initialization of SciSnap!
Creates global variables "SciSnap!Properties", "SciSnap!Data", and "SciSnap!Messages". Sets the default values of global SciSnap!-properties for items typeOfData width height minValue maxValue columns rows maxSetValue
Returns the value of an existing global SciSnap!-property or "not found". Items: typeOfData width height minValue maxValue columns rows maxSetValue
minValuetypeOfData width height minValue maxValue columns rows maxSetValue
Sets the value of an existing global SciSnap!-property or inserts it anew. Items: typeOfData width height minValue maxValue columns rows maxSetValue
minValuetypeOfData width height minValue maxValue columns rows maxSetValue
Shows the message with headline in the middle of the window.
headlinetheMessage
Adds a new entry to SciSnap!Messages and shows the error message.
something wrong!
Reports a copy of a costume.
Reports the costume of a sprite.
Returns a random number between 0 and 1.
Reports Pi.
Reports Euler's number.
Rounds value x to n digits.
1.23572
Reports n faculty.
50
Reports a binomial coefficient.
531result1n1i1
Test on vector, matrix, table, predicate, interval, list of intervals, set, or complex-number.
vectorvector transposed-vector matrix table complex-number complex-number-Cartesian-style complex-number-polar-style set comparisonOperator interval listOfIntervals numericalListcomplex-numbercomplex-number-Cartesian-stylecomplex-number-polar-styletransposed-vectorvectormatrixwidth11table1width1SciS_isTable(data)intervalfalselistOfIntervalsset2344listOfIntervals55numericalListfalse
Reports a substring of a string.
thisString14
Reports a string without first/all instances of substring.
allall firstthisthisString
Reports a string in upper case.
thisString
Reports a string in lower case.
ThisString
Stores a string in a file.
this textthis file
Reports the index of first appearance of substring in string.
ringthisString
Reports a string with replacement instead of substring.
allall firstthisthatthisString
Reports date and time in standard notation.
day10hour10minute10second10--T::
seconds todayJulian Date decimal years days this year hours this year minutes this year seconds this year hours today minutes today seconds todayYYYY17MM54DD21h12m45s7daysi11402Julian Date2JD365.2530.6001172099531121531101215821260360024
Takes any number of Boolean (true/false) inputs (use the left and right arrowheads to adjust the number of input slots) and reports TRUE only if all of the inputs are TRUE, otherwise FALSE. Like AND but for multiple inputs.
pt:todas as afirmações _ são verdadeiras 1
Takes any number of Boolean (true/false) inputs (use the left and right arrowheads to adjust the number of input slots) and reports TRUE if at least one input is TRUE, otherwise FALSE.
pt:alguma das afirmações _ é verdadeira 1
Returns an empty costume of the given width and height with background color r/g/b.
400300245245245
Tests the value of a property.
falsetypeOfConfigurationMathPad
Reports the row or column name of the row or column with the number entered, or reports an error message.
columncolumn row1SciSnap!Datatable0columnrow
Turns a row-wise (in Lisp terminology) function into a column-wise one.
Takes a dyadic scalar function as input, and hyperizes it, so that it can take lists as inputs. Don't use on slow functions (this has compiled map calls). Meant for use on primitives.
ab
pt:a aplicação a _ de _ 1
Evaluates the predicate with a given parameter.
ringified predicate
Evaluates the intervals with a given parameter.
ringified predicateitem3<true
Reports the intersection of two sets.
set1set2are these two sets?setresultset2234element34element344
Reports the union of two sets.
set1set2are these two sets?setresultset223344
Reports the difference between two sets.
set1set2are these two sets?setresultset2234element32set1set24433m14n1m1compare the mth interval with all intervals of set144
Reports the Cartesian product between two sets.
set1set2set4040resultset22item_133
implication
10
equivalence
10
Converts numbers to booleans
1
Converts booleans to numbers
true
Intervals should be of structure [leftLimit,operator1,operator2,rightLimit]
2resultn1
1111111111212121212121212
Intervals should be of structure [leftLimit,operator1,operator2,rightLimit]
11define left edge and operator44define right edge and operator
11resultn1m1n1
11resultn1
0listOfIntervalsitemfalse
Returns all elements of a list not covered by the predicate.
Returns all elements of a list not covered by the intervals.
result3lst_sort(list, fn)34
Test wether the predicate is translatable to a list of intervals.
ringified predicate1comparisonOperator112233false
Intervals should be of structure [leftLimit,operator1,operator2,rightLimit]
interval1interval2intersection0result1144341444341444
1141413<232<3<2<4414142<323<2<3<true
Creates a new empty costume of the specified size and color and sets the local properties
thisSpritethisSprite theStage anotherSprite400300245245245costumeWidthcostumeHeightscaleProperties2212126-10-102211600falsefalsefalsefalsetruetruefalseStagecostume properties: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for Image position on stage 7: upper offset for Image position on stage 8: front color red 9: front color green 10: front color blue line properties: 1: line width 2: line style 3: line color red 4: line color green 5: lineColor blue marker properties: 1: marker style 2: marker width 3: marker connected 4: marker color red 5: marker color green 6: marker color blue data properties: 1: minValue 2: maxValue 3: columns 4: rows scale offsets: 1:left offset 2: right offset 3: upper offset 4: lower offset labels: 1: title 2: x label 3: y label 4: title height 5: x label height 6: y label height 7: x unit 8: y unit ranges: 1: x left 2: x right 3: y lower 4: y upper scale properties: 1: scales x precision 2: scales y precision 3: scales x textheight 4: scales y textheight 5: scales x intervals 6: scales y intervals 7: scales x start 8: scales y start 9: scales x step 10: scales y step 11: scales x scaling 12: scales y scaling 13: scales ticlength 14: scales x minitics 15: scales y minitics 16: scales x grid 17: scales y grid 18: scales x centered 19: scales y centered 20: scales show x scale 21: scales show y scale 22: plot border
thisSpritethisSprite theStage anotherSprite
Reads the value of an existing property.
costumePropertiestypeOfConfiguration typeOfData costumeProperties lineProperties markerProperties dataProperties scaleOffsets labels ranges scalePropertiesthisSpritethisSprite theStage anotherSpriteresultnot foundname1 hmyProperties
Sets the value of an existing property or inserts it anew.
costumePropertiestypeOfConfiguration typeOfData costumeProperties lineProperties markerProperties dataProperties scaleOffsets labels ranges scalePropertiesthisSpritethisSprite theStage anotherSpritename1 donefalsehmyPropertiesmyProperties
a simple way to set some costume attributes: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for Image position on stage 7: upper offset for Image position on stage 8: front color red 9: front color green 10: front color blue
40030024524524518018018000thisSpritethisSprite theStage anotherSpriteStage
a simple way to set some net attributes: line properties: 1: line style 2: lineWidth 3: line color red 4: line color green 5: lineColor blue
continuouscontinuous dashed dash-dot dot-dot rainbow inverse-rainbow1000thisSpritethisSprite theStage anotherSpritelineProperties
a simple way to set some net attributes: marker properties: 1: marker style 2: marker width 3: marker connected 4: marker color red 5: marker color green 6: marker color blue
squarenone o_circle ._point +_plus x_ex square triangle5000falsethisSpritethisSprite theStage anotherSpritemarkerProperties
Sets some properties for scales.
2212121010thisSpritethisSprite theStage anotherSpritescalePropertiesscaleProperties123456scaleProperties
Sets the labels and textheights of the diagrams of a PlotPad.
thisSpritethisSprite theStage anotherSpriteDiagram Title18x-label16y-label16labels
Sets the distances of the diagram axes to the edges of the Sketchpad.
thisSpritethisSprite theStage anotherSpriteupperOffset13scalePropertiesUPPER OFFSET1labels013scaleProperties0lowerOffset13scalePropertiesLOWER OFFSET19scalePropertiesrightOffset1.54scalePropertiesRIGHT OFFSET.13scaleProperties0leftOffset14scalePropertiesLEFT OFFSET18scaleProperties13scaleProperties0scaleOffsets
Sets the ranges for the axes of the diagrams of a Sketchpad.
-1010-1010false0.1truethisSpritethisSprite theStage anotherSpriterangesranges
Draws the graph of a function given as rigified Snap!-function or coefficient-list of a polynomial.
ringified operator or polynomialthisSpritethisSprite theStage anotherSpritevectorSciS_addGraphToPlotpad(costume,ranges,offsets,lineattributes,aFunction,proc)rangesscaleOffsetslineProperties
Draws the data points of a two-dimensional table with numerical values. With a lot of additions from Rick Hessman. Thanks!
myDatathisSpritethisSprite theStage anotherSpritemyDatamatrix12SciS_addNumericDataplotToPlotpad(costume,ranges,offsets,labels,lineattributes,dataattributes,data)rangesscaleOffsetslabelslinePropertiesmarkerProperties
Draws the data points of a two-dimensional table with numerical values in column 2. Text values should be used to set the x-label.
myDatatruetruethisSpritethisSprite theStage anotherSpritemyDatatableSciS_addMixedDataplotToPlotpad(costume,ranges,offsets,labels,lineattributes,dataattributes,data)rangesscaleOffsetslabelslinePropertiesmarkerPropertiesscalePropertiesscalePropertieswasXscaled?20wasYscaled?212021scaleProperties
Draws a histogram of histogram data.With a lot of additions by Rick Hessman. Thanks!
myData10truethisSpritethisSprite theStage anotherSpritemyDatavector0transposed-vectorminmaxdeltah2resulti1221i1source0.1SciS_addHistogramToPlotpad(costume,ranges,offsets,lineattributes,data,datapointattributes)rangesscaleOffsetslinePropertiesmarkerProperties
Draws and labels the axes of a PlotPad. With lot of additions of Rick Hessman. Thanks!
thisSpritethisSprite theStage anotherSpriteSciS_addAxesAndScalesToPlotpad(costume,scaleattributes,labels,offsets,ranges,plotcolors)scalePropertieslabelsscaleOffsetsrangescostumeProperties
thisSpriteSciS_newcostume(w,h,r,g,b)3costumeProperties4costumeProperties5costumeProperties
Sets the ranges to "pretty" values. Many thanks to Rick Hessman!
thisSpritethisSprite theStage anotherSpritescalePropertiesscalePropertiesrangesrangespretty125get dictionary of pretty values.72192311245631261427pretty346get dictionary of pretty values.821102312246842261527rangesscaleProperties
"Pretty" scaling from Rick Hessman. Many thanks!
-1010620002000Numbers are too big for pretty printing.nintpretty0.0010.0020.0050.010.020.050.10.20.512510205010020050010002000between91341341341341341341places33322211100000000000sign2index1i21dticnintresultdeltanstartstart*scaling is the actual starting value (start is the value displayed next to the tic)stop1stepstep*scaling is the actual stepping value (step is the difference between the tic labels).scalingintervalsprecisionminitics
thisSpritethisSprite theStage anotherSpritemyData0.1myData2dy43ranges1234scalePropertiesscaleProperties7192151111418310436121151scaleProperties
Calculates the ranges of two columns of a table.
Conversion of coordinates.
100xpxp yp x ythisSpritethisSprite theStage anotherSpriteoffsetsscaleOffsetsrangesrangesdiagramWidth1diagramHeight34x0112y0443coordinate1 xpypxy
Obtaining coordinates of a PlotPad by mouse.
costume-coordinatescostume-coordinates graph-coordinatesthisSpritethisSprite theStage anotherSpriteselection1 targetCostumetargetCostumeWidthtargetCostumeHeighttargetXPositiontargetYPositiontargetSizecostume-coordinatescostume coordinates.graph-coordinatescostume coordinates.
400300xycontinuouso_circle000
400300xycontinuous000
00600400continuousnone continuous dashed dash-dot dot-dot rainbow inverse rainbowsquarenone o_circle ._point +_plus x_ex square triangle000
Changes the Snap!-Logo. ;-)
Creates SQL variables and sets some properties.
Establishes connection and sets the corresponding properties. Change parameters if necessary.
connectionhttps://snapextensions.uni-goettingen.de/mysqlquery.php?server=db1&user=snapexuser&password=snap!userconnection&type=connect12ok0115ERROR
Imports the results of an SQL-query to SQLData and sets the corresponding properties.
typeOfDatatable0minValuenotSetmaxValuenotSet
Reports a list of databases on the server and sets the corresponding properties.
dbsconnection&type=getDBs000115ERROR
Selects one of the databases and sets the corresponding properties.
2databasescurrentDatabasedatabasesresultconnection&command=USE currentDatabasetablestablesconnection&command=SHOW TABLES FROM currentDatabase&type=getTables000115ERROR
Reports a list of tables of the chosen database and sets the corresponding properties.
tblsconnection&command=SHOW TABLES FROM currentDatabase&type=getTables000115ERROR
Reads the attributes of the specified table and sets the corresponding properties.
1databases0115ERROR
Selects one of the tables and sets the corresponding properties.
1tables0115ERROR
Generates a simplified SQL query.
* DISTINCTi11result FROM 0result2
Generates an almost complete SQL query.
* DISTINCTASCASC DESC10i11result FROM 0result20result20resultASC
Executes an SQL query.
1:ERROR
Returns an SQL predicate.
Returns an SQL predicate.
Returns an SQL predicate.
Returns an SQL predicate.
Returns an SQL predicate.
Returns an SQL predicate.
Returns an SQL predicate.
Returns an SQL predicate.
Returns an SQL value.
Returns an SQL value.
Returns an SQL value.
Returns an SQL value.
Returns an SQL value.
Creates a new empty costume of the specified size and color and sets local properties. If sprite is the stage, the old costume# of stage is stored. So you can draw graphs on maps, for example.
thisSpritethisSprite theStage anotherSprite400300245245245targettheStageStagethisSpriteStagetheStagecostume properties: 1: width 2: height 3: back color red 4: back color green 5: back color blue vertex properties: 1: ranges for random coordinates (xLeft,xRight, yUpper,yLower) 2: minimal radius of a vertex, should be changed is vertices are not growing with number of edges 3: boolean: vertices grow with number of connected edges 4: boolean: vertex content is shown. If there is no content, the vertex number is shown edge properties: 1: line width 2: line color red 3: line color green 4: line color blue 5: boolean: edge is directed 6: boolean: edge has a weight 7: boolean: edge shows weight
thisSpritethisSprite theStage anotherSprite
Reads the value of an existing property.
costumePropertiestypeOfConfiguration typeOfData costumeProperties vertexProperties edgePropertiesthisSpritethisSprite theStage anotherSpriteresultnot foundname1 hmyProperties
Sets the value of an existing property or inserts it anew.
costumePropertiestypeOfConfiguration typeOfData costumeProperties vertexProperties edgePropertiesthisSpritethisSprite theStage anotherSpritename1 donefalsehmyPropertiesmyProperties
a simple way to set some costume attributes. 1: width 2: height 3: back color red 4: back color green 5: back color blue
400300245245245thisSpritethisSprite theStage anotherSpritecostumeProperties
a simple way to set some vertex attributes: 1: ranges for random coordinates (xLeft,xRight, yUpper,yLower) 2: minimal radius of a vertex, should be changed is vertices are not growing with number of edges 3: boolean: vertices grow with number of connected edges 4: boolean: vertex content is shown. If there is no content, the vertex number is shown
3truefalsethisSpritethisSprite theStage anotherSpritevertexProperties1vertexPropertiesThe ranges are maintained.
a simple way to set some edge attributes: 1: line width 2: line color red 3: line color green 4: line color blue 5: boolean: edge is directed 6: boolean: edge has a weight 7: boolean: edge shows weight
1000falsefalsefalsethisSpritethisSprite theStage anotherSpriteedgeProperties
100100thisSpritethisSprite theStage anotherSprite1vertexListvertexList
adds n vertices to the vertexList of a GraphPad: Vertex attributes have the following order: 1: x 2: y 3: size 4: content 5: isMarked 6: colorNr 7: numberOfLinks
1thisSpritethisSprite theStage anotherSpritevertexListSciS_addVerticesToVertexlist(n,vlist,vAttributes)vertexListvertexPropertiesadjacencyMatrixSciS_addVerticesToAdjacencymatrix(n,amatrix)adjacencyMatrix
Moves a vertex to another position measured in Snap! sprite-coordinates
1thisSpritethisSprite theStage anotherSprite100100vertexList
Creates n new edges randomly.
1thisSpritethisSprite theStage anotherSpriteresultSciS_addRandomEdgesToGraph(amatrix,n,lAttributes,vlist)adjacencyMatrixedgePropertiesvertexListadjacencyMatrix1vertexList2
Creates a new edge between two vertices.
12thisSpritethisSprite theStage anotherSprite0vertexList0vertexListadjacencyMatrixXadjacencyMatrixX5edgeProperties
draws the graph on a GraphPad.
thisSpritethisSprite theStage anotherSpriteStageoldCostumeStageSciS_drawGraph(amatrix,vlist,cAttributes,vAttributes,lAttributes,oldCostume)adjacencyMatrixvertexListcostumePropertiesvertexPropertiesedgeProperties
Deletes a vertex.
1thisSpritethisSprite theStage anotherSprite0vertexListvertexListadjacencyMatrix
Deletes an edge.
12thisSpritethisSprite theStage anotherSprite0vertexList0vertexListadjacencyMatrix05edgeProperties
12thisSpritethisSprite theStage anotherSprite0vertexList0vertexList
Sets the weight of an edge.
121thisSpritethisSprite theStage anotherSprite0vertexList0vertexList
thisSpritethisSprite theStage anotherSpritefrom vertex nr
Input for start vertex.
thisSpritethisSprite theStage anotherSpritenew start vertexwidth (1....20)
1thisSpritethisSprite theStage anotherSprite0vertexList
Sets the content of a vertex.
1thisSpritethisSprite theStage anotherSprite0vertexList
Input for a new vertex content.
thisSpritethisSprite theStage anotherSpritevertex number
Tells a vertex to be marked.
1thisSpritethisSprite theStage anotherSprite0vertexList
Deletes a marker.
1thisSpritethisSprite theStage anotherSprite0vertexList
Deletes all markers.
thisSpritethisSprite theStage anotherSpriteitemvertexList
Depth first search in a graph.
1thisSpritethisSprite theStage anotherSprite0vertexList
Breadth first search in a graph.
1thisSpritethisSprite theStage anotherSprite0vertexList
Reports the distance of two vertices.
thisSpritethisSprite theStage anotherSprite120vertexList0vertexList
Shortes path between two vertices, using Dijkstra-method.
12thisSpritethisSprite theStage anotherSprite0vertexList0vertexList
Shortes paths between startVertex and all connected vertices, using Dijkstra-method.
1thisSpritethisSprite theStage anotherSprite0vertexList
Returns the vertexnumber of a vertex near (x|y), if there is one.
10050thisSpritethisSprite theStage anotherSpriteSciS_vertexnumberAtGraph(vlist,cAttributes,vAttributes,x,y)vertexListcostumePropertiesvertexProperties
00thisSpritethisSprite theStage anotherSpritetargetSize10011001
Reports the vertexnumber of the vertex with the specified content. If not found then reports 0.
PeterthisSpritethisSprite theStage anotherSpritenr0itemvertexListFamilyTree
numberXdiagramSpriteDiagramSpriteDiagramSprite400300245245245DiagramSpriteEdges per Node18Number of Edges16Number of Vertices1610trueDiagramSpriteDiagramSprite
spriteName
spriteName
Imports a stored sprite from a file.
new name
Imports stored blocks to another palette. All blocks should be from the same category!
Lookslibrarybegincategory=10end"50oldcat2libraryall""""SciS_importLibrary2(src)
Creates a new empty costume of the specified size and color ans sets local properties for a NeuralNet.
thisSpritethisSprite theStage anotherSprite400300245245245costumeWidthcostumeHeightStagecostume properties: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for NN position on stage 7: upper offset for NN position on stage neural net properties: 1: number of layers 2: layer width 3: width of NN image 4: height of NN image
thisSpritethisSprite theStage anotherSprite
Reads the value of an existing property.
netPropertiestypeOfConfiguration typeOfData costumeProperties netPropertiesthisSpritethisSprite theStage anotherSpriteresultnot foundname1 hmyProperties
Sets the value of an existing property or inserts it anew.
netPropertiestypeOfConfiguration typeOfData costumeProperties netPropertiesthisSpritethisSprite theStage anotherSpritename1 donefalsehmyPropertiesmyProperties
a simple way to set some costume attributes: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for NN position on stage 7: upper offset for NN position on stage
40030024524524500thisSpritethisSprite theStage anotherSpritecostumeProperties
a simple way to set some net attributes: 1: number of layers 2: layer width 3: width of NN image 4: height of NN image
23400300thisSpritethisSprite theStage anotherSpritenetProperties
Reports the output of the nth layer of a neural network with given input.
last1 lastthisSpritethisSprite theStage anotherSpritevector2netProperties
Creates a fully connected neural network of perceptrons. Inputs should be connected to layer 1, outputs to last layer.
23thisSpritethisSprite theStage anotherSpritemyDataone matrix for each layer1myDatapropertiesnetPropertiesnetProperties34typeOfDataweights
Draws the nodes and current status of connections of an NN as new costume.
thisSpritethisSprite theStage anotherSpritenetWidth2netPropertiesSciS_NNshowStatus(cAttributes,nAttributes,weights,outputs,costume,sprite)costumePropertiesnetPropertiesmyData
A block for teaching a neural net.
0.1thisSpritethisSprite theStage anotherSpritewidth2netPropertiesmyDataSciS_NNteach(weights,width,depth,input,output,eta)myData1netProperties
thisSpritethisSprite theStage anotherSprite
creates a temporary or static Sprite.
truenewSprite
Removes the calling sprite.
Reports the row or column number of the row or column with the name entered, or reports an error message. If the the name is a number You can mark this with a # (e.g. #123).
columncolumn rownameSciSnap!Datatable010columnfirstlast1#n0i10i100ERROR: name not found!rowfirstlast1#n0i10i10ERROR: name not found!ERROR: something wrong!
Input dialog for a list of items. Click item by mouse and then ok. Returns the selected item.
thisSpritethisSprite theStage anotherSpritetitlewidth9costume400245245245continuous1000245245245 (click on it)102018truei12530505281218true70301005ok751218trueokfalse70100305
Returns an empty table.
Reports a new table initialized with value.
23result
Reports a table with labeled columns.
20i1rowERROR: labels required!
Reports the copy of a list or an empty list.
Imports table-CSV-data, costume-data, SQL-data or FITS-data to SciSnap!Data.
costume-(RGB)-datatable-(CSV)-data costume-(RGB)-data SQL-(query)-data FITS-datacurrent-costumecurrent-costume filepicker other-sourceFITS-datatable-(CSV)-datacolumns10rows1000hmaxcolumnSciSnap!DatatrueminValuemaxValuecostume-(RGB)-datahminValuemaxValueSQL-(query)-datatypeOfDatatable0columns10rows1000hmaxcolumntrueminValuemaxValue
Reads a file using the filepicker.
Stores a list in a CSV file. JS-code copied from Snap!-code.
SciSnap!Datafilename
Reports randomly distributed points in the form of a rectangle, circle, or ring.
100-100100-100100squaresquare circle ringcirclering
Creates new random data in the specified ranges swaying by a straight.
10-55102
Generates a list of points "near" a given graph.
20-552
Creates the transpose of a table or a list.
01valuevaluetableERROR: data are not transposable!
Adds a row, a column, or column headers to a table.
rowrow column column-headersSciSnap!Datachoice1 tablerowi1column0i1column-headersi11
Reports the row or column of a table identified by number or name, or reports an error message. If the the name is a number You can mark this with a # (e.g. #123).
rowrow columnnumberOrNamefirst last numberOrNameSciSnap!Datatruechoice1 tablerowlast1columnlast11ERROR: something wrong!
Deletes a row or column of a table. identified by number or name, or reports an error message. If the the name is a number You can mark this with a # (e.g. #123).
rowrow columnnumberOrNamefirst last numberOrNameSciSnap!Datatablerowlastcolumnlast11item
Reports the element a position x|y of a table, identified by numbers or names.
numberOrNamenumberOrNameSciSnap!Datatablexcolumnyrow001
Replaces the value at position x|y of a table.
numberOrNamenumberOrNameSciSnap!Datatablexcolumnyrow001
Reports the columns from row startnr to row endnr.
SciSnap!DatanumberOrNamelastlast numberOrNametablelaststartnrrowendnrrowcolNumbersitemSciS_columncopy(data,cols,start,stop)
Reports a subsection of an image or table.
RGB-datatable-data matrix-data list-data RGB-data FITS-dataSciSnap!DatanumberOrNamenumberOrNamenumberOrNamenumberOrNamelist-dataresultdummyvalueindextable-datamatrix-datab1columnb2rowe1columne2rowbeginendSciS_subsection(data,begin,end)RGB-dataFITS-dataRGB-datawidthwidthheightheightFITS-datawidthwidthheightheightbeginendSciS_subsectionImage(data,begin,end,width,height)
Determines the rows of a table with certain properties.
SciSnap!DatanumberOrNameless-thanless-than greater-than equal-to different-fromtablencolumn11op1less-thangreater-thanequal-todifferent-from
counts the appearances of the values of a list.
sortedDatacountedValuesvalue1n0item
returns the entropy of a list of data
Copy of corresponding Snap!-library-block: Reports a new list whose items are the same as in the input list, except that if two or more equal items appear in the input list, only the last one is kept in the result.
SciSnap!Datatable
Normalizes a table by dividing it by the specified value.
SciSnap!Datameanmean max number sum median softmaxchoice1 vector0
Reports a compressed version of a vector or matrix.
SciSnap!Data2isMatrixmatrixvector11resulti11iresultcolumnNr11
Pooling operation with matrices, images and vectors.
maxmax meanSciSnap!Data21typeOfPooling1 matrixvectorFITSRGBmatrixFITSRGBSciS_pooling(data,width,height,typeOfPooling,stride,typeOfData)
Reports a sorted list.
Sorts a list or table.
SciSnap!DatanumberOrNametruetrueisTabletableresult1
Determines a group of properties of a table.
meanmin max number sum meannumberOrNameSciSnap!DatanumberOrNametruetablegroupcolumncolumn11valuecolumncolumn11choice1 copytruecolumn0SciS_groupeddata(aTable,compaircolumn,operation,groupcolumn)
Calculates the ranges, the covariance or the correlation between two columns of a table.
rangesranges covariance correlationnumberOrNamenumberOrNameSciSnap!Datatruetablencolumn11mcolumn11copychoice1 1SciS_propertiesoftable(selection,table,x,y)1
Calculates the parameters of a regression line.
SciSnap!DatamatrixsumX0sumY0numerator0denominator0dummymeanXmeanYdummymb
Determines the next k neighbours of a point in data. The class of the point has to be in column 3.
5SciSnap!Datatablepoint2neighbors3truetruetable-data114
Applies a convolution to a table with FITS, RGB, or table values.
tableimage tableSciSnap!Data100100matrixSciS_convolution(kernel,data,width,height,typeOfData,mIndex,kWidth)
Custering of n-dimensional data with k-means-method. Cluster numbers are attached to the data.
3SciSnap!DatamatrixSciS_k-means-clustering(k,data)
Custering of n-dimensional data with k-means-method. A metric has to be delivered as a ringified term. Cluster numbers are attached to the data.
3SciSnap!Dataringified operatormatrixresultadd cluster number 0 to datadimension1minmaxi1calculate min and max for all columnscentersi1choose k random centerscalculate min and max for all columnsanyChangestruen0anyChangesfalsedummycenter1pointbuild clustersadjust centers
Metric for Strtings.
SaturdaySunday
labels of data: -1 not visited, 0 visited, -2 noise, >0 clusternr
SciSnap!Data505matrix2SciS_DBSCAN(data,r,minMembers)-1
reports a ID3 decision tree constructed on the base of labeled data
0empty datasetcountedValuescolumnlasttrue1only one result --> ready11only one attribut left --> readyinformation gainsi111calculate information gains for all attributesinformation gains2falsetruecompareColumn11take attribute with max information gain as compare criterioncountedValuescolumntruelinksitemrecursive construction of ID3 trees for all other attributesnode11
thisSpritethisSprite theStage anotherSprite
Returns the vertexnumber of a vertex near mouse position, if there is one.
thisSpritethisSprite theStage anotherSpriteSciS_vertexnumberAtGraph(vlist,cAttributes,vAttributes,x,y)vertexListcostumePropertiesvertexProperties
returns the class of a dataset using an ID3-decision-tree
1leaf (unambiguous)1nodei1ERROR: no sensefull data to compare found!
Reports a vector, built by the items.
Returns a new vector of dimension n with random elements.
3110
Returns a matrix formed from the input vectors.
length1resultitem
Returns a new nxm-matrix with random elements.
32110i1
Creates the transpose of a vector or a matrix.
valuevalue
Determines a property of a vector.
minmin max minpos maxpos number sum mean median variance standard-deviation softmaxdatatransposed-vector1choice1 softmaxmedianminmaxnumbersummeanminposmaxposvariancestandard-deviationvariancestandard-deviationERROR: unknown option!
Linear operations with scalars, vectors and matrices.
*+ - * X-*ERROR: illegal operation between numbers!vectormatrixERROR: illegal operation with numbers!vectorvector+-*Xmatrixvector matrix operationERROR: illegal operation with vectors!matrixvectormatrix vector operationmatrixmatrix matrix operation-*ERROR: wrong operation!ERROR: illegal operation
Applies a mapping matrix to an object that is given as a matrix of points.
Soves a linear system of max. 50 equations.
some tests for correct data01transposed-vectormatrixcreates matrix with attached column bsolvedtruen50i1dTry to solve matrixr1rowswap rowshelpnormalize row1k11k1k1diagonalizer1
Reports a list of matrix A in triangle form, the rank of A, column change and column positions.
0Aba copy of A is used to let A unchangedrankrow1columchangefalsecolumn positions11i1search downwardsi1search to the rightc0row1row1row-1transform to diagonal form E
Calculates the coefficients of the interpolation polynomial for a 2xn-matrix of points.
212matrixcreate matrix of powers of x and y-valuesolvedtruen50i1j-12dTry to solve matrixr1rowswap rowshelpnormalize row1k11k1k1diagonaizer1
Calculates the value of a polynomial for input x.
polynomial as list of coefficients11result12i3
Applies an affine transformation to a list of points.
SciSnap!DataoktrueP11P22P33Q11Q22Q33S1221221220ERROR: denominator is zero
Reports a complex number in Cartesian style.
23
Reports a complex number in polar style.
230
Reports a complex number in polar style.
Reports a complex number in Cartesian style.
Reports properties of complex numbers.
real-partabsolute-value real-part imaginary-part phase conjugatereal-partimaginary-partphaseconjugateERROR: unknown operator!
Reports arithmetic results of two complex numbers.
++ - * /complex-numbercomplex-number-polar-stylecomplex-number-polar-style+-*/complexNumberCartesianStyle22333223
Creates a new empty costume of the specified size and color and sets local properties
thisSpritethisSprite theStage anotherSprite400300245245245theStagecostumeWidthcostumeHeighttheStagecostume attributes: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for MathPad position on stage 7: upper offset for MathPad position on stage other attributes: 1: line width 2: draw only ponts, not arrows 3: dimension of coordinate system 4: max. value on scales 5: start point of arrows
thisSpritethisSprite theStage anotherSprite
Reads the value of an existing property.
costumePropertiestypeOfConfiguration typeOfData costumeProperties lineProperties dimension maxValue startPointthisSpritethisSprite theStage anotherSpriteresultnot foundname1 hmyProperties
Sets the value of an existing property or inserts it anew.
costumePropertiestypeOfConfiguration typeOfData costumeProperties lineProperties dimension maxValue startPointthisSpritethisSprite theStage anotherSpritename1 donefalsehmyProperties
a simple way to set some costume attributes: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for MathPad position on stage 7: upper offset for MathPad position on stage
40030024524524500thisSpritethisSprite theStage anotherSpritecostumeProperties
a simple way to set some MathPad attributes: 1: line width 2: draw only ponts, not arrows 3: dimension of coordinate system 4: max. value on scales 5: start point of arrows
1false310000thisSpritethisSprite theStage anotherSpriteoldDimensiondimensionoldMaxValuemaxValuelinePropertiesdimensionmaxValuestartPoint
Draws axes on a MathPad in 2 or 3 dimensions.
thisSpritethisSprite theStage anotherSpriteSciS_mathpadaddaxes(cAttributes,type,maxValue,dimension,costume)costumePropertiestypeOfDatamaxValuedimension
Draws a vector, complex number or object of points from the start point stored in the properties.
vectorvector complex-number line-to object-of25500thisSpritethisSprite theStage anotherSpritefalsedataobject-ofdimension1SciS_mathpadplot(costume,data,r,g,b,maxValue,linewidth,dimension,onlypoints,cAttributes,startpoint,choice)maxValue1linePropertiesdimension2linePropertiescostumePropertiesstartPointcomplex-numberdata23dimensionSciS_mathpadplot(costume,data,r,g,b,maxValue,linewidth,dimension,onlypoints,cAttributes,startpoint,choice)maxValue1linePropertiesdimension2linePropertiescostumePropertiesstartPoint
Returns a root of an equation calculated with Newton's method.
ringified term1epsilon0.00001fi110001000
Reports an element of a sequence.
ringified term1
Returns a list of the n first elements of a sequence.
1ringified termresulti1
Returns a list of secant slopes calculated with the given sequence.
ringified term21/nresulti1
Reports the secant slope "nearby" the given point.
ringified term1epsilon0.00001
Returns a finite sum.
10ringified term10result0i
Returns the integral of a term calculated with n trapezoids.
2ringified term11000result0dxx1
Reports either - data Fourier transformed to frequency-space - "raw" FFT (Fast Forier Transformation)data formatted as SciSnap! complex numbers - or iFFT real data
frequency_spectrumfrequency_spectrum complex_FFTdata iFFT_of_FFTdata100iFFT_of_FFTdataSciS_FFTops(data,freq,choice)
Reports coefficient of the binomial distribution b(N,p,k)=(N choose k)*p^k(1-p)^(N-k)
100.12ERROR: wrong parameter!
Reports binomial distribution B(N,p,k).
1100.1ERROR: wrong parameter!
Reports coefficient of the hypergeometric distribution.
10352ERROR: wrong parameter!
Reports hypergeometric distribution.
11035ERROR: wrong parameter!
Reports coefficient of the Poisson distribution.
0.052ERROR: wrong parameter!
Reports Poisson distribution.
20.05ERROR: wrong parameter!
Reports coefficient of the Pareto distribution.
132
Reports coefficient of the normal distribution.
101
The empty set.
The real (computer-) numbers.
Returns a set by listing the elements, predicates, and defined intervals. The sequence is: set isNumerical list of elements list of intervals predicate.
Creation of a set by a predicate. Intervals and elements should be defined by another block. If possible the predicate is translated to a list of intervals. The sequence is: set isNumerical list of elements list of intervals predicate.
ringified predicatepredicateTreeERROR: pure predicate sets are not supported yet.
Returns a set with one numerical interval. The sequence is: set isNumerical list of elements list of intervals predicate.
-Infinity-Infinity≤ <≤ <InfinityInfinitysettrue
Reports whether "element" is element of "set".
elementset43
Reports the intersection, union, difference, or cross product of two sets.
set1∩ ∪ \ Xset2are these two sets?set\set1set24433m14n1m1compare the mth interval with all intervals of set144Xresultset22item_133
Is set1 subset of set2?
set1set2are these two sets?setinterval4element3Compare elementstrue
Are theses two sets equal?
set1set2set
Reports up to n elements of a set. Numers are natural numbers smaller than maxSetValue in SciSnap!-properties.
10setresult340i1maxSetValue should be close to infinity ;-)resultvalueindexlistclean up1
Reports simple types, sets and lists as string.
i1maxSetValue should be close to infinity ;-)elementsvalueindexlist20item18is first elementtrueitem18ERROR: no simple type!
Converts a string to a list of elements.
1,2,[3,4],{6,7,8..12}]10]0]0}10}0}0find lists
Creates a new empty costume of the specified size and color and sets local properties
thisSpritethisSprite theStage anotherSprite400300245245245costumeWidthcostumeHeightStagecostume properties: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for Image position on stage 7: upper offset for Image position on stage line properties: 1: lineWidth 2: line color red 3: line color green 4: lineColor blue data properties: 1: minValue 2: maxValue 3: columns 4: rows image properties: 1: type (RGB,FITS) 2: imageWidth 3: imageHeight grid colors: list of usable colors: 1:black 2:gray 3:white 4: red 5:yellow 6:magenta 7:green 8:cyan 9:blue
thisSpritethisSprite theStage anotherSprite
Reads the value of an existing property.
costumePropertiestypeOfConfiguration typeOfData costumeProperties lineProperties dataProperties imageProperties gridProperties gridColorsthisSpritethisSprite theStage anotherSpriteresultnot foundname1 hmyProperties
Sets the value of an existing property or inserts it anew.
costumePropertiestypeOfConfiguration typeOfData costumeProperties lineProperties dataProperties imageProperties gridProperties gridColorsthisSpritethisSprite theStage anotherSpritename1 donefalsehmyPropertiesmyProperties
a simple way to set some costume attributes: 1: width 2: height 3: back color red 4: back color green 5: back color blue 6: left offset for Image position on stage 7: upper offset for Image position on stage
40030024524524500thisSpritethisSprite theStage anotherSpriteStage
a simple way to set some net attributes: line properties: 1: line style 2: lineWidth 3: line color red 4: line color green 5: lineColor blue 6: fill color red 6: fill color green 8: fill color blue
continuouscontinuous dashed dash-dot dot-dot1000180180180thisSpritethisSprite theStage anotherSpritelineProperties
a simple way to set some grid attributes: 1: number of horizontal cells 2: number of vertical cells 3: cell width 4: cell height grid data are stored in myData
thisSpritethisSprite theStage anotherSprite400400wh1costumePropertiesws2costumeProperties11gridPropertiesmyData2
Imports costume-data or FITS-data to a data list.
costume(RGB)datacostume(RGB)data FITSDatacurrentCostumecurrentCostume filepicker list with dimensions at topthisSpritethisSprite theStage anotherSpritechoice1 filepickerFITSData6typeOfConfigurationImagePadmyPropertiestypeOfDataFITSmyPropertieslineProperties1000myPropertiesdataProperties16myPropertiesimagePropertiesFITSmyPropertiesgridProperties40404040myPropertiesgridColors000black150150150gray255255255white25500red2552550yellow2550255magenta02550green0255255cyan00255bluemyPropertiesheader5011Stagecostume(RGB)dataw1h211costumeDatacostumePropertiesminmin123maxmax123typeOfConfigurationImagePadmyPropertiestypeOfDataRGBmyPropertieslineProperties1000myPropertiesdataProperties1myPropertiesimagePropertiesRGBmyPropertiesgridProperties40404040myPropertiesgridColors000black150150150gray255255255white25500red2552550yellow2550255magenta02550green0255255cyan00255bluemyPropertiesStage
Generates an image from the FITS or RGB data of the DataSprite in gray or false colors
graygray false-color RGBmyData0255falsethisSpritethisSprite theStage anotherSpritecolor1 sourcemyDatamyDatatypeOfDataFITS1costumePropertiestheStage2costumePropertiestheStage1costumeProperties2costumeProperties1costumeProperties2costumeProperties1costumePropertiestheStage2costumePropertiestheStage1costumeProperties2costumeProperties
Draws a grid on an ImagePad.
myDatathisSpritethisSprite theStage anotherSpritetruemyDatamatrix1gridProperties12gridProperties
Draws a line on present costume using line properties. Attention: JS coordinates are used.
1010100100thisSpritethisSprite theStage anotherSprite
Draws a rectangle on present costume using line properties. Attention: JS coordinates are used.
1010100100thisSpritethisSprite theStage anotherSpriteSciS_drawRectangleOnImagepad(costume,x1,y1,width,height,lineAttributes)lineProperties
Fills a rectangle on present costume using surface properties. Attention: JS coordinates are used.
1010100100thisSpritethisSprite theStage anotherSpriteSciS_fillRectangleOnImagepad(costume,x1,y1,width,height,lineAttributes)lineProperties
Draws a circle on present costume using line properties. Attention: JS coordinates are used.
10010020thisSpritethisSprite theStage anotherSpriteSciS_drawCircleOnImagepad(costume,x,y,radius,lineAttributes)lineProperties
Fills a circle on present costume using surface properties. Attention: JS coordinates are used.
10010020thisSpritethisSprite theStage anotherSpriteSciS_fillCircleOnImagepad(costume,x,y,radius,lineAttributes)lineProperties
Draws a text on present costume using line properties. Attention: JS coordinates are used.
my text1005012truethisSpritethisSprite theStage anotherSpriteSciS_drawTextOnImagepad(costume,x,y,text,height,horizontal,lineAttributes)lineProperties
Draws a list of "point" as "balls". Attention: JS-coordinates are used!
myDatacirclescircles squares5thisSpritethisSprite theStage anotherSpritesourcemyDatamatrix012SciS_drawListOfPoints(costume,data,shape,size,lineAttributes)121lastlineProperties
Sets the RGB value at (x|y) on costume. Attention: JS-coordinates are used!
11thisSpritethisSprite theStage anotherSprite255100301costumeProperties2costumeProperties11
Reports the RGB value at the position (x|y) of the costume. JS-code-snippets copied from Snap!-code. Attention: JS-coordinates are used!
11thisSpritethisSprite theStage anotherSprite1costumeProperties2costumeProperties11
Sets the value at (x|y) in myData. Attention: JS-coordinates are used!
11thisSpritethisSprite theStage anotherSpritetypeOfDataRGBtypeOfDataFITS
Reads the data value at the position (x/y) of an image stored in myData. Attention: JS-coordinates are used!
11thisSpritethisSprite theStage anotherSpritetypeOfDataRGBtypeOfDataFITS
Obtaining data with the mouse from an image or grid stored in myData.
image-valueimage-value costume-coordinates slice-data line-data circle-data brightness cell-valuethisSpritethisSprite theStage anotherSpriteselection1 targetCostumetargetCostumeWidthtargetCostumeHeightStagecostume-coordinatescostume coordinates.line-dataokfalseokfalsexold1yold21212Stageline dataimage-value11image valueslice-dataslice datacircle-datacircle dataokfalseokfalsecontinuous32552000180180180112112continuous1255200018018018012Stagebrightnessbrightnesscell-valuevalue of a grid cell
Applies an affine transformation to a costume.
currentCostumeoktrueP11P22P33Q11Q22Q33S1221221220ERROR: denominator is zero
Reports the brightness of a FITS or RGB image around x|y in a circle with radius r. Attention: JS-coordinates are used!
10010010thisSpritethisSprite theStage anotherSpritedatamyDatatypeOfDataFITStypeOfDataRGB
Fills a grid or a part of a grid with one of the specified values.
thisSpritethisSprite theStage anotherSprite1xMax1yMaxgridPropsgridPropertiesxMaxyMaxmyDataSciS_fillOnImagePadGridRandomlyOnImagePad(xMin,xMax,yMin,yMax,numbers,data)myData
sets the value of a grid cell
thisSpritethisSprite theStage anotherSprite1targetCostumetargetCostumeWidthtargetCostumeHeightStage11myDatatrue
Sets the value of a grid cell an shows the result.
thisSpritethisSprite theStage anotherSprite112truegridPropsgridProperties1112
Reports the Moore- or v.-Neumann-neighborhood of a cell. Order: north,east,south,west
MooreMoore vonNeumannfalse11thisSpritethisSprite theStage anotherSpriteSciS_neighborhoodInGridOnImagePad(data,gridProperties,x,y,isTorus,typeOfNeighborhood)myDatagridProperties
Swaps the cell values of a grid randomly.
thisSpritethisSprite theStage anotherSpritetrue111xMax1yMaxgridPropsgridPropertiesxMaxyMaxSciS_swapCellsOfGridOnImagePad(data,gridProperties,n,isTorus,range,xMin,xMax,yMin,yMax)myDatagridProperties
Counts the surrounding values and changes it if necessary.
thisSpritethisSprite theStage anotherSpritetrueany or numberany22greater-thangreater-than equal-to smaller-than different-from41false51xMax1yMaxgridPropsgridPropertiesxMaxyMaxSciS_changeSurroundingValuesOfGridOnImagePag(data,gridProperties,ifValue,elseValue,surrValue,op,n,isTorus,withNoise,noise,xMin,xMax,yMin,yMax,oldValue)myDatagridProperties1 1
Replaces the cell values of a grid depending on the features of the neighbors.
thisSpritethisSprite theStage anotherSpritetruesumsum min max mean1xMax1yMax1gridPropsgridPropertiesxMaxyMaxSciS_replaceValuesOfGridOnImagePad(data,gridProperties,operation,isTorus,xMin,xMax,yMin,yMax,range)myDatagridProperties1
Combines two grids.
1orand or xor not-and not-or not-xor minus212xMax1111yMaxSciS_combineGridsOnImagePad(grid1,grid2,value1,operator,value2,ifValue,elseValue,xMax,yMax)
Applies a Wolfram Cellular Automaton to a grid.
3031SciS_applyWolframAutomatonToAgridOnImagePad(no,grid,color0,color1)
\ No newline at end of file diff --git a/libraries/SciSnapExtensions.js b/libraries/SciSnapExtensions.js index 352822c6..400d6475 100644 --- a/libraries/SciSnapExtensions.js +++ b/libraries/SciSnapExtensions.js @@ -763,44 +763,8 @@ SnapExtensions.primitives.set( SnapExtensions.primitives.set( 'SciS_writetoCSVfile(data,filename)', function (data, filename) { - function toCSV(data) { - var items = data.itemsArray(), rows = []; - - function encodeCell(atomicValue) { - var string = atomicValue.toString(), cell; - if (string.indexOf('\"') === -1 && - (string.indexOf('\n') === -1) && - (string.indexOf('\,') === -1)) { - return string; - } - cell = ['\"']; - string.split('').forEach(function (letter) { - cell.push(letter); - if (letter === '\"') { - cell.push(letter); - } - }); - cell.push('\"'); - return cell.join(''); - } - - if (items.some(function (any) { - return any instanceof List; - })) { - items.forEach(function (item) { - if (item instanceof List) { - rows.push(item.itemsArray().map(encodeCell).join(';')); - } else { - rows.push(encodeCell(item)); - } - }); - return rows.join('\n'); - } - return items.map(encodeCell).join(';'); - } - var ide = this.parent.parent; - ide.saveFileAs(toCSV(data), 'text/csv;charset=utf-8', filename); + ide.saveFileAs(data.asCSV(), 'text/csv;charset=utf-8', filename); } ); @@ -4460,6 +4424,594 @@ SnapExtensions.primitives.set( } ); +SnapExtensions.primitives.set( + 'SciS_addGridToImagePad(costume,gridProperties,colors,withLines,data)', + function (costume, gridProperties, colors, withLines, data) { + var ctx = costume.contents.getContext('2d'), + xMax = Number(gridProperties.at(1)), + yMax = Number(gridProperties.at(2)), + cellWidth = Number(gridProperties.at(3)), + cellHeight = Number(gridProperties.at(4)), + maxColors = colors.length(), + d; + ctx.lineWidth = 1; + ctx.strokeStyle = new Color(0, 0, 0).toString(); + for (var x = 1; x <= xMax; x++) { + for (var y = 1; y <= yMax; y++) { + ctx.beginPath(); + d = data.at(y).at(x); + if (d > maxColors) + d = maxColors; + if (d < 1) + d = 1; + ctx.fillStyle = new Color(colors.at(d).at(1), colors.at(d).at(2), colors.at(d).at(3)).toString(); + ctx.fillRect((x - 1) * cellWidth, (y - 1) * cellHeight, cellWidth, cellHeight); + ctx.closePath(); + ctx.fill(); + } + } + ctx.beginPath(); + ctx.moveTo(0, 0); + ctx.lineTo(xMax * cellWidth, 0); + ctx.lineTo(xMax * cellWidth, yMax * cellHeight); + ctx.lineTo(0, yMax * cellHeight); + ctx.lineTo(0, 0); + ctx.closePath(); + ctx.stroke(); + if (!withLines) + return costume; + ctx.beginPath(); + ctx.lineWidth = 1; + ctx.strokeStyle = new Color(0, 0, 0).toString(); + for (var y = 0; y <= yMax; y++) { + ctx.moveTo(0, cellHeight * y); + ctx.lineTo(cellWidth * xMax, cellHeight * y); + } + for (var x = 0; x <= xMax; x++) { + ctx.moveTo(cellWidth * x, 0); + ctx.lineTo(cellWidth * x, cellHeight * yMax); + } + ctx.closePath(); + ctx.stroke(); + return costume; + } +); + +SnapExtensions.primitives.set( + 'SciS_fillOnImagePadGridRandomlyOnImagePad(xMin,xMax,yMin,yMax,numbers,data)', + function (xMin, xMax, yMin, yMax, numbers, data) { + var result, maxNumber = numbers.length(), h; + + function listCopy(item) { + var theCopy; + if (item instanceof List) { + theCopy = new List(); + for (var i = 1; i <= item.length(); i++) + theCopy.add(listCopy(item.at(i))); + } else + theCopy = item; + return theCopy; + } + + function myRandom(min, max) { + if (max < min) { + var h = max; + max = min; + min = h; + } + return Math.floor(Math.random() * (Number(max) - Number(min)) + Number(min) + 0.5); + } + + result = listCopy(data); + xMin = Math.abs(xMin); + xMax = Math.abs(xMax); + yMin = Math.abs(yMin); + yMax = Math.abs(yMax); + if (xMin > xMax) { + h = xMin; + xMin = xMax; + xMax = h; + } + if (yMin > yMax) { + h = yMin; + yMin = yMax; + yMax = h; + } + for (var y = yMin; y <= yMax; y++) + for (var x = xMin; x <= xMax; x++) + result.at(y).put(numbers.at(myRandom(1, maxNumber)), x); + return result; + } +); + +SnapExtensions.primitives.set( + 'SciS_neighborhoodInGridOnImagePad(data,gridProperties,x,y,isTorus,typeOfNeighborhood)', + function (data, gridProperties, x, y, isTorus, typeOfNeighborhood) { + var xMax = Number(gridProperties.at(1)), + yMax = Number(gridProperties.at(2)), + result = [], xg, yg; + if ((x < 1) || (x > xMax) || (y < 1) || (y > yMax)) + return "ERROR: index out of bounds!"; + for (var xp = x - 1; xp <= x + 1; xp++) { + for (var yp = y - 1; yp <= y + 1; yp++) { + xg = xp; + yg = yp; + if (xp < 1) { + if (isTorus) { + xg = xMax; + } else { + xg = 0; + } + } + if (xp > xMax) { + if (isTorus) { + xg = 1; + } else { + xg = 0; + } + } + if (yp < 1) { + if (isTorus) { + yg = yMax; + } else { + yg = 0; + } + } + if (yp > yMax) { + if (isTorus) { + yg = 1; + } else { + yg = 0; + } + } + if ((xg > 0) && (yg > 0)) { + result.push(data.at(yg).at(xg)); + } else { + result.push(""); + } + } + } + if (typeOfNeighborhood === "Moore") + return new List([result[3], result[6], result[7], result[8], result[5], result[2], result[1], result[0]]); + else + return new List([result[3], result[7], result[5], result[1], ]); + } +); + +SnapExtensions.primitives.set( + 'SciS_swapCellsOfGridOnImagePad(data,gridProperties,n,isTorus,range,xMin,xMax,yMin,yMax)', + function (data, gridProperties, n, isTorus, range, xMin, xMax, yMin, yMax) { + var result, rnd; + + function listCopy(item) { + var theCopy; + if (item instanceof List) { + theCopy = new List(); + for (var i = 1; i <= item.length(); i++) + theCopy.add(listCopy(item.at(i))); + } else + theCopy = item; + return theCopy; + } + + function myRandom(min, max) { + if (max < min) { + var h = max; + max = min; + min = h; + } + return Math.floor(Math.random() * (Number(max) - Number(min)) + Number(min) + 0.5); + } + + function swap(x, y) { + var xNew, yNew; + if (isTorus) { + xNew = x + myRandom(-range, range); + yNew = y + myRandom(-range, range); + if (xNew < 1) + xNew = xMax; + if (xNew > xMax) + xNew = 1; + if (yNew < 1) + yNew = yMax; + if (yNew > yMax) + yNew = 1; + } else { + do { + xNew = x + myRandom(-range, range); + } while ((xNew < 1) || (xNew > xMax)); + do { + yNew = y + myRandom(-range, range); + } while ((yNew < 1) || (yNew > yMax)); + } + result.at(y).put(data.at(yNew).at(xNew), x); + result.at(yNew).put(data.at(y).at(x), xNew); + } + + data = listCopy(data); + result = listCopy(data); + xMin = Math.abs(xMin); + xMax = Math.abs(xMax); + yMin = Math.abs(yMin); + yMax = Math.abs(yMax); + if (xMin > xMax) { + h = xMin; + xMin = xMax; + xMax = h; + } + if (yMin > yMax) { + h = yMin; + yMin = yMax; + yMax = h; + } + + for (i = 1; i <= n; i++) { + rnd = myRandom(1, 8); + if (rnd === 1) { + for (var x = xMin; x <= xMax; x++) + for (var y = yMin; y <= yMax; y++) + swap(x, y); + } + if (rnd === 2) { + for (var x = xMin; x <= xMax; x++) + for (var y = yMax; y >= yMin; y--) + swap(x, y); + } + if (rnd === 3) { + for (var x = xMax; x >= xMin; x--) + for (var y = yMin; y <= yMax; y++) + swap(x, y); + } + if (rnd === 4) { + for (var x = xMax; x >= xMin; x--) + for (var y = yMax; y >= yMin; y--) + swap(x, y); + } + if (rnd === 5) { + for (var y = yMin; y <= yMax; y++) + for (var x = xMin; x <= xMax; x++) + swap(x, y); + } + if (rnd === 6) { + for (var y = yMax; y >= yMin; y--) + for (var x = xMin; x <= xMax; x++) + swap(x, y); + } + if (rnd === 7) { + for (var y = yMin; y <= yMax; y++) + for (var x = xMax; x >= xMin; x--) + swap(x, y); + } + if (rnd === 8) { + for (var y = yMax; y >= yMin; y--) + for (var x = xMax; x >= xMin; x--) + swap(x, y); + } + data = result; + result = listCopy(data); + } + return result; + } +); + +SnapExtensions.primitives.set( + 'SciS_changeSurroundingValuesOfGridOnImagePag(data,gridProperties,ifValue,elseValue,surrValue,op,n,isTorus,withNoise,noise,xMin,xMax,yMin,yMax,oldValue)', + function (data, gridProperties, ifValue, elseValue, surrValue, op, n, isTorus, withNoise, noise, xMin, xMax, yMin, yMax, oldValue) { + var result; + + function listCopy(item) { + var theCopy; + if (item instanceof List) { + theCopy = new List(); + for (var i = 1; i <= item.length(); i++) + theCopy.add(listCopy(item.at(i))); + } else + theCopy = item; + return theCopy; + } + + function myRandom(min, max) { + if (max < min) { + var h = max; + max = min; + min = h; + } + return Math.floor(Math.random() * (Number(max) - Number(min)) + Number(min) + 0.5); + } + + function actWith(x, y) { + var xg, yg, res = 0, ok, val; + if ((oldValue === 0) || (data.at(y).at(x) === oldValue)) { + for (var xp = x - 1; xp <= x + 1; xp++) { + for (var yp = y - 1; yp <= y + 1; yp++) { + xg = xp; + yg = yp; + if (xp < 1) { + if (isTorus) { + xg = xMax; + } else { + xg = 0; + } + } + if (xp > xMax) { + if (isTorus) { + xg = 1; + } else { + xg = 0; + } + } + if (yp < 1) { + if (isTorus) { + yg = yMax; + } else { + yg = 0; + } + } + if (yp > yMax) { + if (isTorus) { + yg = 1; + } else { + yg = 0; + } + } + if ((xg > 0) && (yg > 0) && (data.at(yg).at(xg) === surrValue)) + res++; + } + } + if((oldValue!==0)&&(data.at(y).at(x)===surrValue)) res--; + ok = false; + if ((op === "greater-than") && (res > n)) + ok = true; + if ((op === "equal-to") && (res == n)) + ok = true; + if ((op === "smaller-than") && (res < n)) + ok = true; + if ((op === "different-from") && (res !== n)) + ok = true; + if (ok) + result.at(y).put(ifValue, x); + else + result.at(y).put(elseValue, x); + if (withNoise) { + if (Math.random() * 100 <= noise) + if (Math.random() <= 0.5) + result.at(y).put(ifValue, x); + else + result.at(y).put(elseValue, x); + } + } + } + + result = listCopy(data); + xMin = Math.abs(xMin); + xMax = Math.abs(xMax); + yMin = Math.abs(yMin); + yMax = Math.abs(yMax); + if (xMin > xMax) { + h = xMin; + xMin = xMax; + xMax = h; + } + if (yMin > yMax) { + h = yMin; + yMin = yMax; + yMax = h; + } + if (oldValue === "any") + oldValue = 0; + oldValue = Number(oldValue); + for (var x = xMin; x <= xMax; x++) + for (var y = yMin; y <= yMax; y++) + actWith(x, y); + return result; + } +); + +SnapExtensions.primitives.set( + 'SciS_replaceValuesOfGridOnImagePad(data,gridProperties,operation,isTorus,xMin,xMax,yMin,yMax,range)', + function (data, gridProperties, operation, isTorus, xMin, xMax, yMin, yMax,range) { + var result; + + function listCopy(item) { + var theCopy; + if (item instanceof List) { + theCopy = new List(); + for (var i = 1; i <= item.length(); i++) + theCopy.add(listCopy(item.at(i))); + } else + theCopy = item; + return theCopy; + } + + function actWith(x, y) { + var xg, yg,sum=0, max=-100000, min=100000, n=0, z; + for (var xp = x - range; xp <= x + range; xp++) { + for (var yp = y - range; yp <= y + range; yp++) { + xg = xp; + yg = yp; + if (xp < 1) { + if (isTorus) { + xg = xMax+xp; + } else { + xg = 0; + } + } + if (xp > xMax) { + if (isTorus) { + xg = xp-xMax; + } else { + xg = 0; + } + } + if (yp < 1) { + if (isTorus) { + yg = yMax+yp; + } else { + yg = 0; + } + } + if (yp > yMax) { + if (isTorus) { + yg = yp-yMax; + } else { + yg = 0; + } + } + if ((xg > 0) && (yg > 0)) { + z = data.at(yg).at(xg); + sum = sum + z; + n++; + if (z > max) + max = z; + if (z < min) + min = z; + } + } + } + if (operation === "sum") + result.at(y).put(sum, x); + if (operation === "min") + result.at(y).put(min, x); + if (operation === "max") + result.at(y).put(max, x); + if (operation === "mean") + if (n > 0) + result.at(y).put(1.0 * sum / n, x); + else + result.at(y).put("", x); + } + + + result = listCopy(data); + xMin = Math.abs(xMin); + xMax = Math.abs(xMax); + yMin = Math.abs(yMin); + yMax = Math.abs(yMax); + range=Number(range); + if (xMin > xMax) { + h = xMin; + xMin = xMax; + xMax = h; + } + if (yMin > yMax) { + h = yMin; + yMin = yMax; + yMax = h; + } + for (var x = xMin; x <= xMax; x++) + for (var y = yMin; y <= yMax; y++) + actWith(x, y); + return result; + } +); + +SnapExtensions.primitives.set( + 'SciS_combineGridsOnImagePad(grid1,grid2,value1,operator,value2,ifValue,elseValue,xMax,yMax)', + function (grid1, grid2, value1, operator, value2, ifValue, elseValue, xMax, yMax) { + var result = new List(), row, ok, ok1, ok2; + for (var y = 1; y <= yMax; y++) { + row = new List(); + for (var x = 1; x <= xMax; x++) { + ok1 = grid1.at(y).at(x) === value1; + ok2 = grid2.at(y).at(x) === value2; + ok = false; + if ((operator === "and") && (ok1 && ok2)) + ok = true; + if ((operator === "or") && (ok1 || ok2)) + ok = true; + if ((operator === "xor") && ((ok1 && !ok2) || (!ok1 && ok2))) + ok = true; + if ((operator === "not-and") && (!(ok1 && ok2))) + ok = true; + if ((operator === "not-or") && (!(ok1 || ok2))) + ok = true; + if ((operator === "not-xor") && (!((ok1 && !ok2) || (!ok1 && ok2)))) + ok = true; + if (operator === "minus") + if (ok2) + ok = false; + else + ok = ok1; + if (ok) + row.add(ifValue); + else + row.add(elseValue); + } + result.add(row); + } + return result; + + } +); + +SnapExtensions.primitives.set( + 'SciS_applyWolframAutomatonToAgridOnImagePad(no,grid,color0,color1)', + function (no, grid, color0, color1) { + var WolframData, gridWidth = grid.at(1).length(), lineData = new List(), lineLength, result; + + function numberToBits(n) { + var result = [0, 0, 0, 0, 0, 0, 0, 0], bit; + for (var i = 7; i >= 0; i--) { + bit = Math.floor(1.0 * n / Math.pow(2, i)); + result[i] = bit; + n = n - bit * Math.pow(2, i); + } + return result; + } + + no = Number(no); + color0 = Number(color0); + color1 = Number(color1); + if ((no > 255) || (no < 0)) + return "ERROR: number out of range!"; + WolframData = new List(numberToBits(no)); + for (var i = 1; i <= 3 * gridWidth; i++) + lineData.add(color0); + for (var i = gridWidth + 1; i <= 2 * gridWidth; i++) + lineData.put(grid.at(1).at(i - gridWidth), i); + lineLength = lineData.length(); + for (var y = 1; y < grid.length(); y++) { + result = new List(); + for (var i = 1; i <= lineLength; i++) { + if (i === 1) { + if (lineData.at(1) === color1) + n = 2; + else + n = 0; + if (lineData.at(2) === color1) + n++; + } else if (i === lineLength) { + if (lineData.at(i - 1) === color1) + n = 4; + else + n = 0; + if (lineData.at(i) === color1) + n = n + 2; + } else { + if (lineData.at(i - 1) === color1) + n = 4; + else + n = 0; + if (lineData.at(i) === color1) + n = n + 2; + if (lineData.at(i + 1) === color1) + n++; + } + if (WolframData.at(n + 1) === 1) { + result.add(color1); + if ((i > gridWidth) && (i <= 2 * gridWidth)) + grid.at(y + 1).put(color1, i - gridWidth); + } else { + result.add(color0); + if ((i > gridWidth) && (i <= 2 * gridWidth)) + grid.at(y + 1).put(color0, i - gridWidth); + } + } + lineData = result; + } + return grid; + } +);