Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ExpressionJSON #3

Open
TiagoCavalcante opened this issue Jul 6, 2021 · 4 comments
Open

Add support for ExpressionJSON #3

TiagoCavalcante opened this issue Jul 6, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@TiagoCavalcante
Copy link
Collaborator

As @rocky said we should add support to ExpressionJSON.

I just need some examples to see how ExpressionJSON is with Graphics3D, maybe @mmatera could help here?

@TiagoCavalcante TiagoCavalcante self-assigned this Jul 6, 2021
@mmatera
Copy link
Collaborator

mmatera commented Jul 6, 2021

Something like this:

In[4]:= ExportString[Graphics3D[{Sphere[]}],"ExpressionJSON"]
Out[4]= [
	"Graphics3D",
	[
		"List",
		[
			"Sphere",
			[
				"List",
				0,
				0,
				0
			]
		]
	]
]
In[4]:=ExportString[Plot3D[x*y,{x,0,2},{y,0,2}],"ExpressionJSON"]
Out[4]= 
[
	"Graphics3D",
	[
		"GraphicsComplex",
		[
			"List",
			["List",
				1.4285714285714285e-7,
				1.4285714285714285e-7,
				2.040816326530612e-14
			]
			,...

		],
		[
			"List",
			[
				"List",
				[
					"List",
					[
						"EdgeForm"
					],
					[
						"Directive",
						[
							"Specularity",
							[
								"GrayLevel",
								1
							],
							3
						],
						[
							"RGBColor",
							0.880722,
							0.611041,
							0.142051
						],
						[
							"Rule",
							"Lighting",
							[
								"List",
								[
									"List",
									"'Ambient'",
									[
										"RGBColor",
										0.30100577,
										0.22414668499999998,
										9.0484535e-2
									]
								],
								[
									"List",
									"'Directional'",
									[
										"RGBColor",
										0.2642166,
										0.18331229999999998,
										4.261530000000001e-2
									],
									[
										"ImageScaled",
										[
											"List",
											0,
											2,
											2
										]
									]
								],
								[
									"List",
									"'Directional'",
									[
										"RGBColor",
										0.2642166,
										0.18331229999999998,
										4.261530000000001e-2
									],
									[
										"ImageScaled",
										[
											"List",
											2,
											2,
											2
										]
									]
								],
								[
									"List",
									"'Directional'",
									[
										"RGBColor",
										0.2642166,
										0.18331229999999998,
										4.261530000000001e-2
									],
									[
										"ImageScaled",
										[
											"List",
											2,
											0,
											2
										]
									]
								]
							]
						]
					],
					[
						"GraphicsGroup",
						[
							"Annotation",
							[
								"List",
								[
									"Polygon",
									[
										"List",
										["List",
											689,
											17,
											473
										]
										,
										["List",
											561,
											89,
											338
										]
										,...
									]
								],
								[
									"Polygon",
									[
										"List",
										["List",
											831,
											144,
											600,
											1271
										]
										,...
									]
								],
								[
									"Polygon",
									[
										"List",
										["List",
											960,
											570,
											1260,
											794,
											795
										]
										,...
									]
								]
							],
							"'Charting`Private`Tag$855#1'"
						]
					]
				],
				[
					"List"
				],
				[
					"List"
				],
				[
					"List"
				],
				[
					"List"
				]
			],
			[
				"List",
				[
					"List",
					[
						"GrayLevel",
						0
					],
					[
						"Line",
						[
							"List",
							246,
							1,...
							
						]
					]
				],...
			
				[
					"List"
				],
				[
					"List"
				]
			]
		],
		[
			"Rule",
			"VertexNormals",
			[
				"List",
				["List",
					-1.428571428571399e-7,
					-1.428571428571399e-7,
					0.9999999999999796
				]
				, ...
			]
		]
	],
	[
		"List",
		[
			"Rule",
			"DisplayFunction",
			"Identity"
		],
		[
			"Rule",
			"Ticks",
			[
				"List",
				"Automatic",
				"Automatic",
				"Automatic"
			]
		],
		[
			"Rule",
			"FaceGrids",
			"None"
		],
		[
			"Rule",
			"DisplayFunction",
			"Identity"
		],
		[
			"Rule",
			"Axes",
			true
		],
		[
			"Rule",
			"AxesLabel",
			[
				"List",
				"None",
				"None",
				"None"
			]
		],
		[
			"Rule",
			"AxesOrigin",
			[
				"List",
				"Automatic",
				"Automatic",
				"Automatic"
			]
		],
		[
			"Rule",
			"BoxRatios",
			[
				"List",
				1,
				1,
				0.4
			]
		],
		[
			"RuleDelayed",
			"DisplayFunction",
			"Identity"
		],
		[
			"Rule",
			"FaceGridsStyle",
			"Automatic"
		],
		[
			"Rule",
			"Method",
			[
				"List",
				[
					"Rule",
					"'DefaultBoundaryStyle'",
					[
						"Directive",
						[
							"GrayLevel",
							0.3
						]
					]
				],
				[
					"Rule",
					"'RotationControl'",
					"'Globe'"
				]
			]
		],
		[
			"Rule",
			"PlotRange",
			[
				"List",
				[
					"List",
					0,
					2
				],
				[
					"List",
					0,
					2
				],
				[
					"List",
					0.0,
					3.9999994285714493
				]
			]
		],
		[
			"Rule",
			"PlotRangePadding",
			[
				"List",
				[
					"Scaled",
					2.0e-2
				],
				[
					"Scaled",
					2.0e-2
				],
				[
					"Scaled",
					2.0e-2
				]
			]
		],
		[
			"Rule",
			"Ticks",
			[
				"List",
				"Automatic",
				"Automatic",
				"Automatic"
			]
		]
	]
]

@mmatera
Copy link
Collaborator

mmatera commented Jul 6, 2021

Essentially, is just as any ExpressionJSON: first takes the FullForm of the expression, and then builds a javascript nested list.

@TiagoCavalcante
Copy link
Collaborator Author

@mmatera thanks!

Essentially, is just as any ExpressionJSON: first takes the FullForm of the expression, and then builds a javascript nested list.

Yes, it looks like just a list of the element name and its leaves.

@axkr
Copy link

axkr commented Jul 7, 2021

See:

@rocky rocky changed the title Add support to ExpressionJSON Add support for ExpressionJSON Jul 9, 2021
@TiagoCavalcante TiagoCavalcante added the enhancement New feature or request label Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants