Full Version: Moi + Affinity : Moi for 2D workflows

From: mkdm [#41]
 23 Oct
To: ALL

Hi STEFAN.

Thanks a lot for sharing!

Very interesting for Mac users.

If you want to remain within Moi without using any external tool you can use the great Max's "HeightMap" commands!

It generates curves (or point) from an input b&w or greyscale image.

Although the resulting curves needs to be a tweaked a little bit with the "rebuild" command to make them "lighter" ,
before export them to PDF, for importing into Affinity Designer or any other vector graphic software.

You can get the Max's command here : http://take.ms/e2vSN
N.B. In windows you need to run Moi in Administrator mode in order to make HeightMap works.

This is a brief video I made : http://take.ms/fVOE0




Ciao!

Reply


From: futagoza (STEFAN) [#42]
 23 Oct
To: ALL

Hi Marco,

Max's Script, in this case, is IMHO not good, because it gives you jaggies!

I use for this task the super cool free Zsurf4 in combination with Photoshop,
which runs also under Wine, for OS X users :-)

Best regards
Stefan

Image Attachments:
ZSURF4.jpg 

Reply


From: mkdm [#43]
 23 Oct
To: ALL

Hi STEFAN.

Oh yeah...ZSurf is very useful and in many cases is the right choice!

I have used it sometimes in the past with good results.

Thanks.

But because here I'm trying always to find "old and new" workflows for Moi and Affinity I'm more interested in playing with curves rather than surfaces.

Anyway, you're right. In many cases ZSurf generates surfaces with a good smoothness, and the Iso curves that I can extract are better than those
generated from "HeightMap" script.

Ciao!

Stay tuned for new stuff involving Moi and Affinity :)

Reply


From: futagoza (STEFAN) [#44]
 31 Oct
To: ALL

Hi Marco and all,

just took your tiger drawing into Art Text 3. I really like what one can do with it. :-)



P.S. i added also one Penrose tiling image, done with MoI and Art Text 3, to the MoI Gallery.

Best regards
Stefan

Image Attachments:
tiger.png 

Reply


From: mkdm [#45]
 31 Oct
To: ALL

Hi Stefan!

Very nice!


@You "...your tiger drawing..."

As I said in my original post the tiger is not mine. I get it in Freepik.com
(https://www.freepik.com/free-vector/animals-tribal-tattoo-collection_1168322.htm#term=tiger&page=1&position=5)

Thanks for sharing!

Stay tuned...I hope to upgrade soon my scripts for 2D Workflows. (bug fixing)

Ciao!

Reply


From: mkdm [#46]
 31 Oct
To: ALL

P.S. I only tweaked the tiger a little bit with Affinity Designer to make some cleanup, then I exported it in PNG and then I have used the png for
my 2D Workflow tutorial (original post : http://moi3d.com/forum/index.php?webtag=MOI&msg=8629.39)

Ciao!

Reply


From: futagoza (STEFAN) [#47]
 31 Oct
To: ALL

Thanks for the info Marco!

I overlooked that the original image was from there...

Best regards
Stefan

Reply


From: mkdm [#48]
 4 Nov
To: ALL

Hi Michael.

I'm pretty sure that you already answered me a long time ago, about this question, but I don't remember where is your answer.
I've searched trough the forum by I didn't find what I'm looking for.

The question is this :

If we simply take into account the "speed of execution" factor, can we state that the code executed inside a the "hmtl" page of a command
or inside a script placed into the "scripts" folder, is faster (and many times faster) the the execution of "js code" present in the "js" counterpart of command's html ?

I ask you this because I have in mind to turn the next version of my "script for 2D workflow" from "script" into "command" just in order to
handle more easily the various working mode of that scripts.

For what I've experienced and learned I've seen that the "js" code executed inside the Hml file of command is much more faster that the counterpart executed into the "js" file of the command :

For example consider the "ScaleIndividual" commands that Max wrote times ago :

1) the original version of Max Smirnov :
get it at https://drive.google.com/open?id=1waO3TgOQSUl2ZIBJ8adixPz5Qes_ja21

2) A version that I have modified and that do the main task into the "js" code inside the Html file of the command :
get it at https://drive.google.com/open?id=1N6qWe_lzyJA-aTOrmESLRPhzky_XHhoB


Why the 2nd version, is much more faster than the first (to make a good test you have to select many objects, I tested with hundreds) ?


This is the code of the original version of ScaleIndividual.js and ScaleIndividual.htm :

code:
#include "GetObjects.js"
#include "WaitForDialogDone.js"

function ScaleObject( obj, factor )
{
	var center = obj.getBoundingBox().center;
	var list = moi.geometryDatabase.createObjectList();
	list.addObject( obj );

	var factory = moi.command.createFactory( 'scale' );
	factory.setInput( 0, list );
	factory.setInput( 1, center );
	factory.setInput( 2, factor );
	factory.commit();
}

function DoIndividualScale()
{
	var objectpicker = moi.ui.createObjectPicker();
	if ( !GetObjects( objectpicker ) )
		return;
		
	var objects = objectpicker.objects;
		
	moi.ui.beginUIUpdate();
	moi.ui.hideUI( 'SelectPrompt' );
	moi.ui.showUI( 'OptionsPrompt' );
	moi.ui.showUI( 'options' );
	moi.ui.endUIUpdate();
	
	if ( !WaitForDialogDone() )
		return;
		
	var scalefactor = moi.ui.commandUI.factor.value;
		
	for ( var i = 0; i < objects.length; ++i )
	{
		var obj = objects.item(i);
		ScaleObject( obj, scalefactor );
	}
}

DoIndividualScale();


code:
<html>
	<body class="commandbody">
		<div class="commandheader">
			<div id="SelectPrompt" class="commandprompt">Select objects to scale</div>
			<div id="OptionsPrompt" class="hiddencommandprompt">Scale options</div>
		</div>
		
		<div id="options" class="hiddencommandoptions">
			<table>
				<tr>
					<td>Scale factor:</td>
					<td><moi:NumericInput id="factor"/></td>
				</tr>		
			</table>
		</div>

		<moi:CommandDoneCancel />
	</body>
</html>



And this is the code of my modified version of ScaleIndividualMainThread.js and ScaleIndividualMainThread.htm :

code:
#include "GetObjects.js"
#include "WaitForDialogDone.js"

function DoIndividualScaleInit() {
	var objectpicker = moi.ui.createObjectPicker();
	if ( !GetObjects( objectpicker ) )
		return;
		
	var objects = objectpicker.objects;
		
	moi.ui.beginUIUpdate();
	moi.ui.hideUI( 'SelectPrompt' );
	moi.ui.showUI( 'OptionsPrompt' );
	moi.ui.showUI( 'options' );
	moi.ui.endUIUpdate();
	
	if ( !WaitForDialogDone() )
		return;
	
	moi.ui.commandUI.DoIndividualScale(objects);
}

DoIndividualScaleInit();


code:
<html>
	<head>
		<script>		
			function ScaleObject( obj, factor ) {
				var center = obj.getBoundingBox().center;
				var list = moi.geometryDatabase.createObjectList();
				list.addObject( obj );

				var factory = moi.command.createFactory( 'scale' );
				factory.setInput( 0, list );
				factory.setInput( 1, center );
				factory.setInput( 2, factor );
				factory.commit();
			}

			function DoIndividualScale(objects) {
				var scalefactor = moi.ui.commandUI.factor.value;
					
				for ( var i = 0; i < objects.length; ++i ) {
					var obj = objects.item(i);
					ScaleObject( obj, scalefactor );
				}
			}
		</script>
	</head>
	<body class="commandbody">
		<div class="commandheader">
			<div id="SelectPrompt" class="commandprompt">Select objects to scale</div>
			<div id="OptionsPrompt" class="hiddencommandprompt">Scale options</div>
		</div>
		
		<div id="options" class="hiddencommandoptions">
			<table>
				<tr>
					<td>Scale factor:</td>
					<td><moi:NumericInput id="factor"/></td>
				</tr>		
			</table>
		</div>

		<moi:CommandDoneCancel />
	</body>
</html>



Thanks a lot for the support :)

Have a nice day.

Ciao!

Marco (mkdm)

Reply


From: mkdm [#49]
 4 Nov
To: ALL

P.S. Michael, I will read your answer in five-six hours because now I have to go :)

Thanks.

Reply


From: Michael Gibson [#50]
 4 Nov
To: ALL

Hi Marco,

> If we simply take into account the "speed of execution" factor, can we state that the code
> executed inside a the "hmtl" page of a command or inside a script placed into the "scripts"
> folder, is faster (and many times faster) the the execution of "js code" present in the "js"
> counterpart of command's html ?

For V3 yes that's true - the .js code is run in a separate process and uses inter-process communication on every MoI API call. The reason for this is it makes it impossible for the script to freeze MoI if it runs in an endless loop or something like that, the worker process can be torn down independently from the script's cooperation.

But the inter-process communication has a performance penalty. The regular default commands in MoI never use script to do heavy calculations in loops or things like that, and so are ok with that.

Code in the HTML side runs in the main process thread and so it doesn't have that same overhead.

For V4 this will be different though, in V4 the .js script will be run on the main thread and not on a worker thread anymore and so in v4 there won't be any difference for which file the code is contained in.

- Michael

Reply


From: mkdm [#51]
 4 Nov
To: ALL

Thank you very much Michael for reminding me this behaviour.

Ciao :)

Reply


Show messages:  1-20  21-40  41-51

Reply to All

Back to thread list | Login

© 2017 Project Beehive Forum