Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Will this help draw weather fronts with Photoshop and Javascript?

Community Beginner ,
Feb 15, 2018 Feb 15, 2018

I am a meteorologist. I use Photoshop to help annotate maps. One thing I always wanted to do, but couldn't, was draw weather fronts.

Recently I've come across some javascript used by leafletjs to draw fronts. Does any of what I've seen get me closer to being able to draw a front with a path? I know Photoshop understands javascript, but not much more.

This is very esoteric. There are few of you who can help. So thanks in advance.

Leafletjs example with fronts:  Weather Prediction Center

Javascript code defining fronts:  front example.txt - Google Drive

TOPICS
Actions and scripting
3.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Beginner ,
Feb 17, 2018 Feb 17, 2018

I believe this site resizes uploads, so I'm placing them in a Google Drive folder.  maps for GrADS - Google Drive

I am watching this with my jaw totally dropped.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2018 Feb 17, 2018

Had my x and y reversed. x should be lat, so my script was off. Have to see about the map you provided to do a conversion.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2018 Feb 17, 2018

Yea, I made the script to put each front in a separate group.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2018 Feb 25, 2018

Modified the script to draw the paths and shapes, no dots now. I don't know about the high and low zones, those don't look right. Still need to add the symbols.

#target photoshop

//1035 px = 40 long  259 per 10 ----25.875 per 1 deg 12.9375 per 1/2 deg

//628 px = 20 lat  157 per 5------31px per 1 deg

//93px to left 130 long//156 to top 50 long

//left edge is 133.5942

//top edge is 55.0322

//right edge 58.91787

//botton edge  20.41935

var hanDist = .32

var strokeSize = 12

var wFile = new File('/c/AAA DATA/Photos/test/weather.js')

COLD = new Array()

TROF = new Array()

WARM = new Array()

STNRY = new Array()

OCFNT = new Array()

LOWS = new Array()

HIGHS = new Array()

$.evalFile (wFile, 50000)

var leftDeg = 133.5942

var topDeg = 55.0322

var longUnit = 25.875

var latUnit = 31

for(var i=0;i<COLD[0].length;i++){

    for(var j=0;j<COLD[0].length;j++){      

        COLD[0][1]= (leftDeg - Math.abs(COLD[0][1]))*longUnit

        COLD[0][0]= (topDeg- COLD[0][0])*latUnit

        }

    }

for(var i=0;i<TROF[0].length;i++){

    for(var j=0;j<TROF[0].length;j++){      

        TROF[0][1]= (leftDeg - Math.abs(TROF[0][1]))*longUnit

        TROF[0][0]= (topDeg- TROF[0][0])*latUnit

        }

    }

for(var i=0;i<WARM[0].length;i++){

    for(var j=0;j<WARM[0].length;j++){      

        WARM[0][1]= (leftDeg - Math.abs(WARM[0][1]))*longUnit

        WARM[0][0]= (topDeg- WARM[0][0])*latUnit

        }

    }

for(var i=0;i<OCFNT[0].length;i++){

    for(var j=0;j<OCFNT[0].length;j++){      

        OCFNT[0][1]= (leftDeg - Math.abs(OCFNT[0][1]))*longUnit

        OCFNT[0][0]= (topDeg- OCFNT[0][0])*latUnit

        }

    }

for(var i=0;i<STNRY[0].length;i++){

    for(var j=0;j<STNRY[0].length;j++){      

        STNRY[0][1]= (leftDeg - Math.abs(STNRY[0][1]))*longUnit

        STNRY[0][0]= (topDeg- STNRY[0][0])*latUnit

        }

    }

for(var i=0;i<LOWS.length;i++){

    for(var j=0;j<LOWS.length;j++){      

        LOWS[1]= (leftDeg - Math.abs(LOWS[1]))*longUnit

        LOWS[0]= (topDeg- LOWS[0])*latUnit

        }

    }

for(var i=0;i<HIGHS.length;i++){

    for(var j=0;j<HIGHS.length;j++){      

        HIGHS[1]= (leftDeg - Math.abs(HIGHS[1]))*longUnit

        HIGHS[0]= (topDeg- HIGHS[0])*latUnit

        }

    }

var doc = activeDocument;

var base = doc.activeLayer

var gpLayer

runLoop ('TORF', TROF[0],255,0,255);

runLoop ('COLD', COLD[0],0,0,255);

runLoop ('WARM', WARM[0],255,0,0);

runLoop ('STNRY', STNRY[0],255,255,0);

runLoop ('OCFNT', OCFNT[0],0,255,255);

runLoop ('LOWS', LOWS,0,255,0);

runLoop ('HIGHS', HIGHS,0,0,0);

function runLoop(fName,fArray,r,g,b){

    for (var i =0;i<fArray.length;i++){

        doc.activeLayer = base;

        createPath (fArray, fName + '-' +i);

        mkShape (strokeSize, r, g, b)

        doc.activeLayer.name =  fName +'-'+i +'-Shape' ;        

        }//end for loop

    }

//======================================

//Make path section

//======================================

function getSlope(point1,point2){

    var pt1x = point1[0];

    var pt1y = point1[1];

    var pt2x = point2[0];

    var pt2y = point2[1];

   

    slope = (pt1y-pt2y)/(pt1x-pt2x)

    var result = new Array((pt1y-pt2y)/(pt1x-pt2x),pt1y-slope*pt1x)

    return result

   

    yInter = pt1y-slope*pt1x

    }

function startHandle(point1,point2){

    var pt1x = point1[0];

    var pt1y = point1[1];

    var pt2x = point2[0];

    var pt2y = point2[1];

   

    var len = Math.abs(pt1x-pt2x)*hanDist

    var x

    if(pt1x<pt2x){x=pt1x+len}

    else{x = pt1x-len}

    var mb= getSlope (point1, point2)

    var y = mb[0]*x + mb[1]

    return [x,y]

    }

function getAngle(p1,p2){

    return Math.atan2 (p2[1]-p1[1], p2[0]-p1[0])//*180/Math.PI;

    }

function lineLen(p1,p2){

    return Math.abs(Math.sqrt (Math.pow((p2[0]-p1[0]),2)+Math.pow((p2[1]-p1[1]),2)));

    }

function getPts(orig,ang,rad){

    var ptH = new Array();

    ptH[0]= orig[0] + rad * Math.cos (ang);

    ptH[1]= orig[1] + rad * Math.sin (ang);

    return ptH;

    }

function createPath(pA1, pName){

    var pA = new Array();

    for(var i=0;i<pA1.length;i++){//invert pt order otherwise y is first

        pA= new Array(pA1[1],pA1[0])

        }

    var lineA = new Array();

    var srcAng =''

    var refAng= ''

    var refAng2=''

    var lLen=''//length between current point and next point

    var lLen2=''//lenfth between current point and last point

    var ptHold1 = ''//for leading handle on next point

    var ptHold2 = ''//for leading handle on current point

    var ptHold3 = ''//for trailding point

    for(var i=0;i<pA.length;i++){

    //for(var i=0;i<pA.length-1;i++){

        if(i<pA.length-1){

            srcAng = getAngle (pA, pA[i+1]);//get angle between the two main points

            lLen = lineLen (pA, pA[i+1])*hanDist;

            }

        else{

            srcAng = getAngle (pA, pA[i-1]);//get angle between the two main points

            lLen = lineLen (pA, pA[i-1])*hanDist;           

            }

      

        //if(i>0&&i<pA.length-1){//Check to see if not an end point and get the angle of line from the origin to next point

       

        if(i==0 && pA.length>2){

            ptHold1 = getNextHandles (pA, i+1);

           

            refAng = getAngle (pA, ptHold1);

            ptHold2 = getPts (pA, refAng, lLen);

            ptHold3 = pA          

            }

       

        if(i>0 && i<pA.length-1){         

            lLen2 = lineLen (pA, pA[i-1])*hanDist;

            refAng = getAngle (pA[i-1], pA[i+1]);           

            refAng2 = getAngle (pA[i+1], pA[i-1]);

            ptHold2= getPts (pA, refAng, lLen2);

            ptHold3= getPts (pA, refAng2, lLen2);

            }

       

        if(i==pA.length-1){

            refAng = getAngle (pA, lineA[i-1].leftDirection);

            ptHold2 = pA;

            ptHold3 = getPts (pA, refAng, lLen)

            }

        lineA = new PathPointInfo;

        lineA.kind = PointKind.SMOOTHPOINT;

        lineA.anchor = pA;

        //-----Left is the leading handle

        lineA.leftDirection = ptHold2

        lineA.rightDirection = ptHold3              

        }

    var lineSubPathArray = new Array()

    lineSubPathArray[0] = new SubPathInfo()

    //lineSubPathArray[0].operation = ShapeOperation.SHAPEXOR

    lineSubPathArray[0].operation = ShapeOperation.SHAPEADD

    lineSubPathArray[0].closed = false

    lineSubPathArray[0].entireSubPath = lineA   

   

    var myPathItem = doc.pathItems.add(pName, lineSubPathArray)

    }

function getNextHandles(pA,num){

    var ang1 = getAngle (pA[num+1], pA[num-1]);

    var lLen = lineLen (pA[num-1], pA[num])*hanDist;

    var point1 = getPts (pA[num], ang1, lLen);

    return point1

    }

function mkShape(sWidth, red, green, blue){

    var idMk = charIDToTypeID( "Mk  " );

        var desc268 = new ActionDescriptor();

        var idnull = charIDToTypeID( "null" );

            var ref85 = new ActionReference();

            var idcontentLayer = stringIDToTypeID( "contentLayer" );

            ref85.putClass( idcontentLayer );

        desc268.putReference( idnull, ref85 );

        var idUsng = charIDToTypeID( "Usng" );

            var desc269 = new ActionDescriptor();

            var idType = charIDToTypeID( "Type" );

                var desc270 = new ActionDescriptor();

                var idClr = charIDToTypeID( "Clr " );

                    var desc271 = new ActionDescriptor();

                    var idRd = charIDToTypeID( "Rd  " );

                    desc271.putDouble( idRd, red );

                    var idGrn = charIDToTypeID( "Grn " );

                    desc271.putDouble( idGrn, green );

                    var idBl = charIDToTypeID( "Bl  " );

                    desc271.putDouble( idBl, blue );

                var idRGBC = charIDToTypeID( "RGBC" );

                desc270.putObject( idClr, idRGBC, desc271 );

            var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

            desc269.putObject( idType, idsolidColorLayer, desc270 );

            var idShp = charIDToTypeID( "Shp " );

                var desc272 = new ActionDescriptor();

                var idTrgp = charIDToTypeID( "Trgp" );

                var idPthK = charIDToTypeID( "PthK" );

                var idTrgp = charIDToTypeID( "Trgp" );

                desc272.putEnumerated( idTrgp, idPthK, idTrgp );

            var idpathClass = stringIDToTypeID( "pathClass" );

            desc269.putObject( idShp, idpathClass, desc272 );

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

                var desc273 = new ActionDescriptor();

                var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );

                desc273.putInteger( idstrokeStyleVersion, 2 );

                var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );

                desc273.putBoolean( idstrokeEnabled, true );

                var idfillEnabled = stringIDToTypeID( "fillEnabled" );

                desc273.putBoolean( idfillEnabled, false );

                var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc273.putUnitDouble( idstrokeStyleLineWidth, idPxl, sWidth );

                var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );

                var idPnt = charIDToTypeID( "#Pnt" );

                desc273.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 );

                var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );

                desc273.putDouble( idstrokeStyleMiterLimit, 100.000000 );

                var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

                var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

                var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" );

                desc273.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap );

                var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

                var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

                var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );

                desc273.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleAlignInside = stringIDToTypeID( "strokeStyleAlignCenter" );

                desc273.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignInside );

                var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );

                desc273.putBoolean( idstrokeStyleScaleLock, false );

                var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );

                desc273.putBoolean( idstrokeStyleStrokeAdjust, false );

                var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );

                    var list16 = new ActionList();

                desc273.putList( idstrokeStyleLineDashSet, list16 );

                var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );

                var idBlnM = charIDToTypeID( "BlnM" );

                var idNrml = charIDToTypeID( "Nrml" );

                desc273.putEnumerated( idstrokeStyleBlendMode, idBlnM, idNrml );

                var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );

                var idPrc = charIDToTypeID( "#Prc" );

                desc273.putUnitDouble( idstrokeStyleOpacity, idPrc, 100.000000 );

                var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );

                    var desc274 = new ActionDescriptor();

                    var idClr = charIDToTypeID( "Clr " );

                        var desc275 = new ActionDescriptor();

                        var idRd = charIDToTypeID( "Rd  " );

                        desc275.putDouble( idRd, red );

                        var idGrn = charIDToTypeID( "Grn " );

                        desc275.putDouble( idGrn, green );

                        var idBl = charIDToTypeID( "Bl  " );

                        desc275.putDouble( idBl, blue );

                    var idRGBC = charIDToTypeID( "RGBC" );

                    desc274.putObject( idClr, idRGBC, desc275 );

                var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

                desc273.putObject( idstrokeStyleContent, idsolidColorLayer, desc274 );

                var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );

                desc273.putDouble( idstrokeStyleResolution, 72.000000 );

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

            desc269.putObject( idstrokeStyle, idstrokeStyle, desc273 );

        var idcontentLayer = stringIDToTypeID( "contentLayer" );

        desc268.putObject( idUsng, idcontentLayer, desc269 );

        var idLyrI = charIDToTypeID( "LyrI" );

        desc268.putInteger( idLyrI, 18 );

    executeAction( idMk, desc268, DialogModes.NO );

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 26, 2018 Feb 26, 2018

A bit more refinement. Figured out the Highs and lows were not paths, but just letters, so changed that with the appropriate colors. Added a dashed line for the trofs also.

#target photoshop

//1035 px = 40 long  259 per 10 ----25.875 per 1 deg 12.9375 per 1/2 deg

//628 px = 20 lat  157 per 5------31px per 1 deg

//93px to left 130 long//156 to top 50 long

//left edge is 133.5942

//top edge is 55.0322

//right edge 58.91787

//botton edge  20.41935

var hanDist = .32

var strokeSize = 6

var wFile = new File('/c/AAA DATA/Photos/test/weather.js')

COLD = new Array()

TROF = new Array()

WARM = new Array()

STNRY = new Array()

OCFNT = new Array()

LOWS = new Array()

HIGHS = new Array()

$.evalFile (wFile, 50000)

var leftDeg = 133.5942

var topDeg = 55.0322

var longUnit = 25.875

var latUnit = 31

for(var i=0;i<COLD[0].length;i++){

    for(var j=0;j<COLD[0].length;j++){      

        COLD[0][1]= (leftDeg - Math.abs(COLD[0][1]))*longUnit

        COLD[0][0]= (topDeg- COLD[0][0])*latUnit

        }

    }

for(var i=0;i<TROF[0].length;i++){

    for(var j=0;j<TROF[0].length;j++){      

        TROF[0][1]= (leftDeg - Math.abs(TROF[0][1]))*longUnit

        TROF[0][0]= (topDeg- TROF[0][0])*latUnit

        }

    }

for(var i=0;i<WARM[0].length;i++){

    for(var j=0;j<WARM[0].length;j++){      

        WARM[0][1]= (leftDeg - Math.abs(WARM[0][1]))*longUnit

        WARM[0][0]= (topDeg- WARM[0][0])*latUnit

        }

    }

for(var i=0;i<OCFNT[0].length;i++){

    for(var j=0;j<OCFNT[0].length;j++){      

        OCFNT[0][1]= (leftDeg - Math.abs(OCFNT[0][1]))*longUnit

        OCFNT[0][0]= (topDeg- OCFNT[0][0])*latUnit

        }

    }

for(var i=0;i<STNRY[0].length;i++){

    for(var j=0;j<STNRY[0].length;j++){      

        STNRY[0][1]= (leftDeg - Math.abs(STNRY[0][1]))*longUnit

        STNRY[0][0]= (topDeg- STNRY[0][0])*latUnit

        }

    }

for(var i=0;i<LOWS.length;i++){

    for(var j=0;j<LOWS.length;j++){      

        LOWS[1]= (leftDeg - Math.abs(LOWS[1]))*longUnit

        LOWS[0]= (topDeg- LOWS[0])*latUnit

        }

    }

for(var i=0;i<HIGHS.length;i++){

    for(var j=0;j<HIGHS.length;j++){      

        HIGHS[1]= (leftDeg - Math.abs(HIGHS[1]))*longUnit

        HIGHS[0]= (topDeg- HIGHS[0])*latUnit

        }

    }

var doc = activeDocument;

var base = doc.activeLayer

var gpLayer

runLoop ('TROF', TROF[0],204,102,0);

runLoop ('COLD', COLD[0],0,0,255);

runLoop ('WARM', WARM[0],255,0,0);

runLoop ('STNRY', STNRY[0],255,255,0);

runLoop ('OCFNT', OCFNT[0],102,51,204);

mkHiLow ('LOWS', LOWS[0]);

mkHiLow ('HIGHS', HIGHS[0]);

function runLoop(fName,fArray,r,g,b){

    for (var i =0;i<fArray.length;i++){

        doc.activeLayer = base;

        createPath (fArray, fName + '-' +i);

        mkShape (strokeSize, r, g, b)

        if(fName=='TROF'){mkDash ()};

        doc.activeLayer.name =  fName +'-'+i +'-Shape' ;    

        }//end for loop

    }

function mkHiLow (fType, fArray, num){

    var pA = new Array();

    var frontFont = 'Arial-MT'

    var lowFcolor = new SolidColor();

        lowFcolor.rgb.red = 255;

        lowFcolor.rgb.green = 0;

        lowFcolor.rgb.blue = 0;  

       

    var hiFcolor = new SolidColor();

        hiFcolor.rgb.red = 0;

        hiFcolor.rgb.green = 0;

        hiFcolor.rgb.blue = 255;  

    for(var i=0;i<fArray.length;i++){

            var artLayerRef = doc.artLayers.add()

            artLayerRef.kind = LayerKind.TEXT;

            var textItemRef = artLayerRef.textItem;

            textItemRef.justification = Justification.CENTER;

            textItemRef.size = 50

            textItemRef.position = [fArray[1],fArray[0]+textItemRef.size*.3]          

           

            if(fType=='LOWS'){

                textItemRef.color = lowFcolor;

                textItemRef.contents = 'L';

                artLayerRef.name = 'LOWS-' + i;

                }

            else{

                textItemRef.color = hiFcolor;

                textItemRef.contents = 'H';

                artLayerRef.name = 'HIGHS-' + i;

                }   

            }//end loop

    }//end function

//======================================

//Make path section

//======================================

function getSlope(point1,point2){

    var pt1x = point1[0];

    var pt1y = point1[1];

    var pt2x = point2[0];

    var pt2y = point2[1];

   

    slope = (pt1y-pt2y)/(pt1x-pt2x)

    var result = new Array((pt1y-pt2y)/(pt1x-pt2x),pt1y-slope*pt1x)

    return result

   

    yInter = pt1y-slope*pt1x

    }

function startHandle(point1,point2){

    var pt1x = point1[0];

    var pt1y = point1[1];

    var pt2x = point2[0];

    var pt2y = point2[1];

   

    var len = Math.abs(pt1x-pt2x)*hanDist

    var x

    if(pt1x<pt2x){x=pt1x+len}

    else{x = pt1x-len}

    var mb= getSlope (point1, point2)

    var y = mb[0]*x + mb[1]

    return [x,y]

    }

function getAngle(p1,p2){

    return Math.atan2 (p2[1]-p1[1], p2[0]-p1[0])//*180/Math.PI;

    }

function lineLen(p1,p2){

    return Math.abs(Math.sqrt (Math.pow((p2[0]-p1[0]),2)+Math.pow((p2[1]-p1[1]),2)));

    }

function getPts(orig,ang,rad){

    var ptH = new Array();

    ptH[0]= orig[0] + rad * Math.cos (ang);

    ptH[1]= orig[1] + rad * Math.sin (ang);

    return ptH;

    }

function createPath(pA1, pName){

    var pA = new Array();

    for(var i=0;i<pA1.length;i++){//invert pt order otherwise y is first

        pA= new Array(pA1[1],pA1[0])

        }

    var lineA = new Array();

    var srcAng =''

    var refAng= ''

    var refAng2=''

    var lLen=''//length between current point and next point

    var lLen2=''//lenfth between current point and last point

    var ptHold1 = ''//for leading handle on next point

    var ptHold2 = ''//for leading handle on current point

    var ptHold3 = ''//for trailding point

    for(var i=0;i<pA.length;i++){

    //for(var i=0;i<pA.length-1;i++){

        if(i<pA.length-1){

            srcAng = getAngle (pA, pA[i+1]);//get angle between the two main points

            lLen = lineLen (pA, pA[i+1])*hanDist;

            }

        else{

            srcAng = getAngle (pA, pA[i-1]);//get angle between the two main points

            lLen = lineLen (pA, pA[i-1])*hanDist;           

            }

      

        //if(i>0&&i<pA.length-1){//Check to see if not an end point and get the angle of line from the origin to next point

       

        if(i==0 && pA.length>2){

            ptHold1 = getNextHandles (pA, i+1);

           

            refAng = getAngle (pA, ptHold1);

            ptHold2 = getPts (pA, refAng, lLen);

            ptHold3 = pA          

            }

       

        if(i>0 && i<pA.length-1){         

            lLen2 = lineLen (pA, pA[i-1])*hanDist;

            refAng = getAngle (pA[i-1], pA[i+1]);           

            refAng2 = getAngle (pA[i+1], pA[i-1]);

            ptHold2= getPts (pA, refAng, lLen2);

            ptHold3= getPts (pA, refAng2, lLen2);

            }

       

        if(i==pA.length-1){

            refAng = getAngle (pA, lineA[i-1].leftDirection);

            ptHold2 = pA;

            ptHold3 = getPts (pA, refAng, lLen)

            }

        lineA = new PathPointInfo;

        lineA.kind = PointKind.SMOOTHPOINT;

        lineA.anchor = pA;

        //-----Left is the leading handle

        lineA.leftDirection = ptHold2

        lineA.rightDirection = ptHold3              

        }

    var lineSubPathArray = new Array()

    lineSubPathArray[0] = new SubPathInfo()

    //lineSubPathArray[0].operation = ShapeOperation.SHAPEXOR

    lineSubPathArray[0].operation = ShapeOperation.SHAPEADD

    lineSubPathArray[0].closed = false

    lineSubPathArray[0].entireSubPath = lineA   

   

    var myPathItem = doc.pathItems.add(pName, lineSubPathArray)

    }

function getNextHandles(pA,num){

    var ang1 = getAngle (pA[num+1], pA[num-1]);

    var lLen = lineLen (pA[num-1], pA[num])*hanDist;

    var point1 = getPts (pA[num], ang1, lLen);

    return point1

    }

function mkShape(sWidth, red, green, blue){

    var idMk = charIDToTypeID( "Mk  " );

        var desc268 = new ActionDescriptor();

        var idnull = charIDToTypeID( "null" );

            var ref85 = new ActionReference();

            var idcontentLayer = stringIDToTypeID( "contentLayer" );

            ref85.putClass( idcontentLayer );

        desc268.putReference( idnull, ref85 );

        var idUsng = charIDToTypeID( "Usng" );

            var desc269 = new ActionDescriptor();

            var idType = charIDToTypeID( "Type" );

                var desc270 = new ActionDescriptor();

                var idClr = charIDToTypeID( "Clr " );

                    var desc271 = new ActionDescriptor();

                    var idRd = charIDToTypeID( "Rd  " );

                    desc271.putDouble( idRd, red );

                    var idGrn = charIDToTypeID( "Grn " );

                    desc271.putDouble( idGrn, green );

                    var idBl = charIDToTypeID( "Bl  " );

                    desc271.putDouble( idBl, blue );

                var idRGBC = charIDToTypeID( "RGBC" );

                desc270.putObject( idClr, idRGBC, desc271 );

            var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

            desc269.putObject( idType, idsolidColorLayer, desc270 );

            var idShp = charIDToTypeID( "Shp " );

                var desc272 = new ActionDescriptor();

                var idTrgp = charIDToTypeID( "Trgp" );

                var idPthK = charIDToTypeID( "PthK" );

                var idTrgp = charIDToTypeID( "Trgp" );

                desc272.putEnumerated( idTrgp, idPthK, idTrgp );

            var idpathClass = stringIDToTypeID( "pathClass" );

            desc269.putObject( idShp, idpathClass, desc272 );

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

                var desc273 = new ActionDescriptor();

                var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );

                desc273.putInteger( idstrokeStyleVersion, 2 );

                var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );

                desc273.putBoolean( idstrokeEnabled, true );

                var idfillEnabled = stringIDToTypeID( "fillEnabled" );

                desc273.putBoolean( idfillEnabled, false );

                var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );

                var idPxl = charIDToTypeID( "#Pxl" );

                desc273.putUnitDouble( idstrokeStyleLineWidth, idPxl, sWidth );

                var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );

                var idPnt = charIDToTypeID( "#Pnt" );

                desc273.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 );

                var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );

                desc273.putDouble( idstrokeStyleMiterLimit, 100.000000 );

                var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

                var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

                var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" );

                desc273.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap );

                var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

                var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

                var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );

                desc273.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleAlignInside = stringIDToTypeID( "strokeStyleAlignCenter" );

                desc273.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignInside );

                var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );

                desc273.putBoolean( idstrokeStyleScaleLock, false );

                var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );

                desc273.putBoolean( idstrokeStyleStrokeAdjust, false );

                var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );

                    var list16 = new ActionList();

                desc273.putList( idstrokeStyleLineDashSet, list16 );

                var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );

                var idBlnM = charIDToTypeID( "BlnM" );

                var idNrml = charIDToTypeID( "Nrml" );

                desc273.putEnumerated( idstrokeStyleBlendMode, idBlnM, idNrml );

                var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );

                var idPrc = charIDToTypeID( "#Prc" );

                desc273.putUnitDouble( idstrokeStyleOpacity, idPrc, 100.000000 );

                var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );

                    var desc274 = new ActionDescriptor();

                    var idClr = charIDToTypeID( "Clr " );

                        var desc275 = new ActionDescriptor();

                        var idRd = charIDToTypeID( "Rd  " );

                        desc275.putDouble( idRd, red );

                        var idGrn = charIDToTypeID( "Grn " );

                        desc275.putDouble( idGrn, green );

                        var idBl = charIDToTypeID( "Bl  " );

                        desc275.putDouble( idBl, blue );

                    var idRGBC = charIDToTypeID( "RGBC" );

                    desc274.putObject( idClr, idRGBC, desc275 );

                var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

                desc273.putObject( idstrokeStyleContent, idsolidColorLayer, desc274 );

                var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );

                desc273.putDouble( idstrokeStyleResolution, 72.000000 );

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

            desc269.putObject( idstrokeStyle, idstrokeStyle, desc273 );

        var idcontentLayer = stringIDToTypeID( "contentLayer" );

        desc268.putObject( idUsng, idcontentLayer, desc269 );

        var idLyrI = charIDToTypeID( "LyrI" );

        desc268.putInteger( idLyrI, 18 );

    executeAction( idMk, desc268, DialogModes.NO );

    }

function mkDash(){

       var idsetd = charIDToTypeID( "setd" );

        var desc4 = new ActionDescriptor();

        var idnull = charIDToTypeID( "null" );

            var ref1 = new ActionReference();

            var idcontentLayer = stringIDToTypeID( "contentLayer" );

            var idOrdn = charIDToTypeID( "Ordn" );

            var idTrgt = charIDToTypeID( "Trgt" );

            ref1.putEnumerated( idcontentLayer, idOrdn, idTrgt );

        desc4.putReference( idnull, ref1 );

        var idT = charIDToTypeID( "T   " );

            var desc5 = new ActionDescriptor();

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

                var desc6 = new ActionDescriptor();

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

                var idstrokeStyleAlignCenter = stringIDToTypeID( "strokeStyleAlignCenter" );

                desc6.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignCenter );

                var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );

                    var list1 = new ActionList();

                    var idNne = charIDToTypeID( "#Nne" );

                    list1.putUnitDouble( idNne, 6.000000 );

                    var idNne = charIDToTypeID( "#Nne" );

                    list1.putUnitDouble( idNne, 2.000000 );

                desc6.putList( idstrokeStyleLineDashSet, list1 );

                var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );

                desc6.putInteger( idstrokeStyleVersion, 2 );

                var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );

                desc6.putBoolean( idstrokeEnabled, true );

            var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

            desc5.putObject( idstrokeStyle, idstrokeStyle, desc6 );

        var idshapeStyle = stringIDToTypeID( "shapeStyle" );

        desc4.putObject( idT, idshapeStyle, desc5 );

    executeAction( idsetd, desc4, DialogModes.NO );

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 13, 2019 Jul 13, 2019
LATEST

Hey guys,

I have made AI brush set with common types of fronts (pattern brushes), download link below for anyone who could use it. Cheers, Snímek obrazovky 2019-07-13 v 13.50.32.png

JANEK

AI Brushes file:

https://drive.google.com/open?id=1T9XgkeaQE72rOiidFXrxOsGbXDskmuG4

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines