Sg2.9
object raster / minimum size...
Recent RSS
object raster / minimum size object
From:  laurent
Date:  29. July 2011, 11:22

bonjour,

I tried to make a grid with the script "object raster.js" from an image and a graphic object (cross shape). the final use is to lasercut a sheet of metal with this vectorised rastered image.

the script work fine but I need to fix the minimum size of the given graphic objet (here a cross shape object), because the laser can't cut an object under 2 or 3mm.

how I can do that?
is somebody can explain me how to modify the script to specify the minimum size?
or does it exist an another script?

thanks a lot
have a nice day
laurent

Re: object raster / minimum size object
From:  ken frederick
Date:  30. July 2011, 21:29

something like this should achieve what you're looking for.

include('Raster.js');

var mmMin = 3; //minimum size in mm
var mmToPt = 2.83464567; //convert mm to points (points are the default unit in scriptographer)
var myMin = mmMin*mmToPt;

function createDot(x, y, dot, radius) {
if (radius > 0.1) {
if( radius < mmMin*mmToPt ) radius = myMin; //checks to make sure the radius is never less than the minimum

var item = dot.clone();
item.position += new Point(x, y) * values.size;
item.scale(radius * values.scale);
return item;
}
}

if (initRaster()) {
var components = {
size: { value: myMin, min: myMin, label: 'Grid Size'}, //min: myMin makes it so you can't have a size less than your minimum
scale: { value: 100, label: 'Object Scale (%)'}
};
var values = Dialog.prompt('Enter Raster Values:', components);
if (values) {
values.scale /= 100;
executeRaster(createDot);
}
}

Re: object raster / minimum size object
From:  laurent
Date:  5. August 2011, 13:24

dear ken,

thank you so much for your prompt answer.

as I know nothing in Javascript, I did that:

  • copy your lines from "include.." to the end
  • paste it in notepad software
  • save it with the extension .js here: c:\Program Files (x86)\Adobe\Adobe Illustrator CS5\Plug-ins\Scriptographer\Scripts\Examples\Rasters\

after that I tried to use it as I used the "object raster.js" script, but I got a grid of graphic object 10 times bigger than the original one with no variations of the size. so the grid is totally black.
so it doesn't work for my needs.

thanks a lot
have a nice day
laurent

Re: object raster / minimum size object
From:  laurent
Date:  13. September 2011, 09:59

bonjour,

I'm still looking to an answer to modify the script "object raster.js" to specify the minimum size.

how I can do that?
is somebody can help me?

bonne journée
laurent

Re: object raster / minimum size object
From:  pqbd
Date:  14. September 2011, 00:04

This problem is better solved with Photoshop than javascript. As the attached image shows, any pixel that is lighter than a certain value will result in a cross that is too small. By using the Output Levels option of the Levels tool in Photoshop, you can set the maximum value of the pixel's brightness to whatever suits your need.

Re: object raster / minimum size object
From:  laurent
Date:  14. September 2011, 17:18

Ca marche!!!

thanks a lot, it works perfectly

have a nice day
laurent

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
RandomTools 21.08.08