The MindFusion Forums | |
Flow Diagramming Components >> Html Canvas & JavaScript >> How to use 'Pen'
https://mindfusion.eu/Forum/YaBB.pl?num=1528111377 Message started by Kuzya on Jun 4th, 2018 at 11:22am |
Title: How to use 'Pen' Post by Kuzya on Jun 4th, 2018 at 11:22am
In'Windows Forms' there was the possibility to use'Pen' :
System.Drawing.Pen pen = new System.Drawing.Pen(Color.Black); pen.CompoundArray = new float[] { 0, 0.25f, 0.75f, 1 }; pen.Width = 0.3f; pen.DashPattern = new float[] { 5f, 2f }; How to do this in javascript? |
Title: Re: How to use 'Pen' Post by Lyubo on Jun 5th, 2018 at 7:18am
Hi,
You can use the stroke property to set the color, the strokeThickness property to set the width and chose a value from the MindFusion.Drawing.DashStyle enumeration to set the strokeDashStyle property. These properties can be accessed through the various style properties, or directly via the diagram and diagram items. For example: Code (javascript):
Regards, Lyubo |
Title: Re: How to use 'Pen' Post by Kuzya on Jun 6th, 2018 at 8:39am
Hi Lyubo,
Thankyou for the response. I need a pen.CompoundArray = new float[] { 0, 0.25f, 0.75f, 1 }; for double lines How can I use that? Regards, Kuzya |
Title: Re: How to use 'Pen' Post by Lyubo on Jun 6th, 2018 at 1:08pm
Hi,
There's no such behavior supported out-of-the-box in the Canvas API. One thing you can try to do is to draw a wider line, then draw over the middle portion of it, using the 'destination-out' globalCompositeOperation switch on the canvas context. The actual implementation will be different depending on where you need to apply those double lines, but the following example shows how you can override the Line.draw behavior to achieve a similar result: Code (javascript):
Check the attached image with the result of the above code for diagram links. Regards, Lyubo |
Title: Re: How to use 'Pen' Post by Kuzya on Jun 7th, 2018 at 2:11pm
Hi Lyubo,
Thankyou for the response.:) I want to have the frames of the element as double lines. is it possible? (in FlowChart.NET at the ''Start'-element the frames are double-lined ) Regards, Kuzya https://mindfusion.eu/Forum/YaBB.pl?action=downloadfile;file=Dok1.docx ( 98 KB | 95
Downloads )
|
Title: Re: How to use 'Pen' Post by Lyubo on Jun 11th, 2018 at 5:20am
Hi,
To achieve a similar result in javascript, you could use the Shape Designer tool from the jsdiagram package (ShapeDesigner.exe) and create a custom shape with a decoration to simulate the double border. For example, the following xml code defines a custom double-bordered ellipse shape, which you can load via the ShapeLibrary class into jsdiagram: Code (]<?xml version="1.0" encoding="utf-8"?> <shapes version="2"> <shape id="DoubleEllipse" fill-mode="Winding"> <outline> <arc dash-style="Custom" width="-1" x="0" y="0" arc-width="100" arc-height="100" start="0" sweep="360" /> </outline> <decorations> <arc dash-style="Custom" width="-1" x="2" y="2" arc-width="96" arc-height="96" start="0" sweep="360" /> </decorations> <shape-decorations /> <enable-outline>True</enable-outline> </shape> </shapes>[/code):
Regards, Lyubo |
Title: Re: How to use 'Pen' Post by Kuzya on Jun 11th, 2018 at 8:44am
Hi Lyubo,
thanks for pointing that out. At the moment we still use the trail version of Javascript. There doesn't seem to be a ShapeLibrary here. Once an element has been set up in this way, will it be exported directly into XML or will post-processing always be necessary during loading? Regards, Kuzya |
Title: Re: How to use 'Pen' Post by Lyubo on Jun 11th, 2018 at 9:06am
Hi,
Which version of the control are you using? ShapeLibrary was introduced in v.2.5 and is present both in the trial and licensed versions. If you're using the latest version, make sure that the browser is not serving an older cached versions of the script files. In order to use the custom shape, its definition needs to be loaded in advance. You can also not rely on a xml file, but use the Shape class constructor to supply the shape definition. The above shape can be recreated in javascript like this: Code (javascript):
Regards, Lyubo |
Title: Re: How to use 'Pen' Post by Kuzya on Jun 15th, 2018 at 7:07am
Hi Lyubo,
Thanks for the solution :) It's working. Can you tell me which parameters provide the distance between double lines? outline: "M100,50 A50,50,0,1,1,0,50 A50,50,0,1,1,100,50", decoration: "M98,50 A48,48,0,1,1,2,50 A48,48,0,1,1,98,50", Regards, Kuzya |
Title: Re: How to use 'Pen' Post by Lyubo on Jun 18th, 2018 at 4:55am
Hi,
To increase the distance between the lines you need to adjust the decoration element. Moving the initial point "M98,50" closer to the shape's center - i.e. "M96,50" will leave a space of 4% of the shape's width between the lines; and next decrease the size of the decoration arcs to account for the offset - "A46,46" , and finally adjust the end points of the arcs: "4,50" for the fist and "96,50" for the second. decoration: "M96,50 A46,46,0,1,1,4,50 A46,46,0,1,1,96,50" Regards, Lyubo |
Title: Re: How to use 'Pen' Post by Kuzya on Jun 19th, 2018 at 3:43pm
Hi Lyubo,
I'm afraid I can't achieve the desired parallility. :( Regards, Kuzya start_1 -Windows Forms start_2 - javaScript |
Title: Re: How to use 'Pen' Post by Lyubo on Jun 20th, 2018 at 7:37am
Hi,
Another approach you can take, is to scale a copy of the existing outline path in an updateVisuals callback. You may want to adjust the scaling ratios depending on the types of shapes you are using. The following example works well with shapes, which width is longer that their height: Code (javascript):
You will need to alter the code with conditionals for different shapes, depending on your specifications and apply a different scaling for different ratios. Regards, Lyubo |
Title: Re: How to use 'Pen' Post by Kuzya on Aug 20th, 2018 at 11:00am
Hi,
for Shape -> RoundRect does not work. Regards, Kuzya |
Title: Re: How to use 'Pen' Post by Lyubo on Aug 21st, 2018 at 7:47am
Hi,
You can modify the round rectangle shape a bit, so it doesn't apply bigger corner radii, when the size of the node is small. Call this code somewhere in your initialization: Code (javascript):
You can see the result in the attached image. Regards, Lyubo |
The MindFusion Forums » Powered by YaBB 2.6.11! YaBB Forum Software © 2000-2024. All Rights Reserved. |