How to add orange diamond tool to custom shapes? - mxgraph

I've noticed that some shapes in draw.io/diagrams.net come with a little orange diamond that allows internal shape modification like say rim thickness
Is it possible to add something like this to my own custom shapes?

AFAIK there is no explicit documentation available on this, but you can just use the source code as a reference. The "orange diamond" is called "handle", you need to look for "custom handles", createHandle in the source code. You can take a "basic triangle" as an example.
This one provides a good starting point:
https://github.com/jgraph/drawio/blob/d60ab053c39cf9b9925dd329306536c00c364c84/src/main/webapp/shapes/mxBasic.js#L598

Related

Dynamically change line color dcc.Graph Plotly Dash between annotations

I'm writing a 'template creation' app using the dcc.Graph image annotation features in Plotly Dash.
The user adds multiple rectangles for specific features in the image (an invoice) and my callback captures the coordinates of each rectangle via the relayoutData variable. I want to use a different color for each rectangle, but can't figure out how to do it.
It seems like the only way to change the newshapes fillcolor
property is to replace the whole figure, but then I lose all previous shapes
All and any help appreciated.
Andrew
I have just found the following demo that does exactly what I am trying to do:
https://dash-gallery.plotly.host/dash-image-annotation/
Now to unpack the logic and adapt it to my context ... Happy 2021!
Andrew

How to use Material.fromType in Cesium

I am having trouble using the Cesium.Material.fromType function to create a material using a type and uniforms.
I am referring to the docs here: link
I have the following example I am trying to get to work, however I would like to next use the Dot dynamic type not color. Color seems easier for the moment.
Sandcastle example
This works:
material : Cesium.Color.GREEN
This does not:
material : Cesium.Material.fromType('Color', {
color : new Cesium.Color(1.0, 0.0, 0.0, 1.0)
})
I am getting this error:
Uncaught DeveloperError: Unable to infer material type: [object Object]
It seems like the material property on entities cannot be an object, am I missing a step to convert the material into a primitive type?
So I don't have great news here, but I can at least explain what's wrong. As you know Cesium has two separate API layers, the "Entity" layer (for complex objects like moving vehicles), and the "Primitive" layer (for graphics primitives, like collections of billboards or meshes). What you're doing here is directly constructing a material from the Primitive layer and trying to assign it to an Entity, which will not work.
At the Entity layer, materials are described by a class derived from the abstract base class of MaterialProperty. The derived classes are all Entity-layer classes listed in that doc link, for example there's a ColorMaterialProperty class for solid colors. Being at the entity layer makes these things time-dynamic, so for example your solid color could be blue when the simulation time is at 04:00 and change to red at 06:00, etc. Primitive materials do not have a concept of time baked in and are much lighter-weight as a result.
And now the bad news: There doesn't appear to be a DotMaterialProperty class in Cesium currently. This means the Dot material exists only at the primitive layer API and is not hooked up to the entity layer. The team likes to say "contributions welcome" at this point, and if you were so inclined you could probably get this hooked up by copying either StripeMaterialProperty or GridMaterialProperty and editing it to hook up to Dot.
But in the short term, if you need the Dot material more than you need the Entity layer, you could transition your code over to graphics primitives. You can find sample code for this in the Material Sandcastle Demo under the Procedural Textures drop-down box.

Solidworks hollow/shell a STL Part

I'm pretty new at solidworks!!
But I've been able to create a solid from a stl files. It's a Truncated tetrahedron shape.
Now I wanted this shape to be hollow (for 3D printing and adding threads).
So I've searched for a while and found a tutorial for the shell tool. This didn't work out because it gave me an error. That the faces may offset in adjacent spaces.
So I thought if I had one part and then a the same part but scale it 3mm. Place them on the same spot and then subtract them of some sort. It would give me the same shelled shape I want.
Would this work and does anybody know a way to do this or has a better way to hollow out my solid.
STL & PART upload.
Files Google Drive
If you have SOLIDWORKS Professional or Premium, you can use ScanTo3D to turn the part into a Solid / Surface body. At that point, you can manipulate the geometry as you would anything else in SOLIDWORKS.
Here's a video showing both turning on ScanTo3D and how to use it.
https://youtu.be/ZjzqWCfNfmQ
"So I thought if I had one part and then a the same part but scale it
3mm. Place them on the same spot and then subtract them of some sort.
It would give me the same shelled shape I want."
use the move/copy body command to copy it
use the scale command to scale it
use the combine feature to subject the smaller body from the main body
Alternatively use the check geometry feature to find any faulty faces and ALWAYS run import diagnostics on an imported body. if you can find and fix a faulty face try the shell tool again. If the minimum radius is too small then you will need to manually offset faces using the offset surface command

Triangle edges in CanvasRenderer

I am a newbie regarding three.js and I have a problem with imported geometry (js-file from 3dsmax inclusive all material and textures) and the CanvasRenderer. The CanvasRenderer displays the triangle edges of imported geometry, the WebGLRenderer works well.
Canvas example:
http://der-n.square7.ch/threejs/examples/teapot_canvas.html
WebGL example:
http://der-n.square7.ch/threejs/examples/teapot_webgl.html
In the three.js library I have found the option "overdraw: true" for a material to fix this behaviour but obviously the material+textures are defined by the above mentioned exported 3dsmax js-file.
For the tests I use the "misc_camera_trackball" example with small changes (I have added a JSONLoader, changed some camera and trackball parameters, changed some light colors, added a CanvasRenderer)
Any hints how to solve this?
Thanks for your help.
Best regards
Oggy
In the loader callback, you have all of the loaded materials in an array geometry.materials. You could loop over those materials and set the overdraw property to true for each.
As far as I know, THREE.MeshFaceMaterial is just a pass-through material that indicates "faces have an index that points to a material instance to use from the geometry's materials array", so setting properties for MeshFaceMaterial won't have any effect.

Ways to apply multiple filters in Adobe Pixelbender?

How to apply multiple filters in Adobe Pixelbender in Flash (=limited version)?
For example 3 different kinds of video displacement effects (1 displacement on the left, one on the right and one the top).
I know, it possible to just copy paste the code multiple times, but this wouldn't be very elegant.
It supposes to apply the second filter after the first filter is applied and the third filter after the second filter is applied.
You can apply pixel bender filters as Shader objects. Then just use:
myDisplayObject.filters = [shader1, shader2, shader3, ...etc];
Specifically, you use the ShaderFilter object. You can find a complete code sample in the documentation here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filters/ShaderFilter.html#includeExamplesSummary
You can also see a tutorial from Adobe here: http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS6FCADA8A-C82B-4d55-89AC-63CA9DEFF9C8.html