How to Create a Java Script Calendar in Photoshop

Written by sarah sammis
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Create a Java Script Calendar in Photoshop
Learn automated calender creation with JavaScript in Photoshop. (Internet dating image by Graham Dance from Fotolia.com)

A script is a series of instructions that tells Photoshop how to perform a series of tasks sequentially. Photoshop CS2 and newer versions support scripts written in AppleScript, JavaScript and VBScript (Virtual Basic). JavaScript can be used to design and build a single page calendar containing all the months of the year. Once the script is written, it's a matter of pushing the play button and letting Photoshop get to work. Adobe offers a free scripting utility, ExtendScript Toolkit but any text editor will work.

Skill level:
Easy

Other People Are Reading

Instructions

  1. 1

    Open the ExtendScript Toolkit and create a new JavaScript (CTRL N or Command N). The Toolkit application resides in the Adobe Utilities folder.

  2. 2

    Define the functions to generate the days of every month.

    Example:

    //DEFINE DAYS OF MONTHS

    function daysOfMonth(month, year {

    return 32 - new Date (year, month, 32).get Date();

    }

    function make Day(d){

    if(d < 10)

    d = "0"+d;

    return d+" ";

    }

  3. 3

    Define the calendar's variables. These variables include the document's width, height, resolution, file name and the year.

    Example:

    //DOC.ATTRIBUTES

    width = 1500;

    height = 2000;

    resolution = 100

    doc Name = "2011Calendar";

    year = 2011;

  4. 4

    Define the calendar's colour scheme. This scheme includes the text colour and the background colour.

    Example:

    //COLOUR SCHEME

    dateColor = new SolidColor();

    dateColor.rgb.hexValue = "f9bc30";

    boxColor = new SolidColor();

    boxColor.rgb.hexValue ="5f1104";

  5. 5

    Define the variables for the days of the week and the months of the year. These variables will control how the text looks and where it is placed on the calendar.

    Example:

    //DEFINE DESIGN OF DAYS AND MONTHS

    week Header = "M T F S S \r\r";

    first Indent = "";

    months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

  6. 6

    Add the lines that will tell the script to create the new document.

    //New FILE

    doc = app.documents.add (width, height, resolution, doc Name, NewDocumentMode.RGB);

    doc.selection.selectAll();

    doc.selection.fill(boxColor);

    doc.selecton.deselect();

  1. 1

    Define the X and Y variables for the placement of each month. The variable "curr" is the current month being manipulated. The for loop will go through the same actions for each month to decide what the X and Y off sets should be.

  2. 2

    for(curr=0; curr<12; curr++){

    x = curr % 3;

    y = Math.floor(curr / 3);

  3. 3

    Create a text layer for the group and set its name to the current month.

    Example:

    month Name = group.artLayers.add();

    monthName.kind = LayerKind.TEXT;

    monthName.name = months[curr];

  4. 4

    Define the text characteristics for the months. Put these lines of code below the text layer code.

    Example:

    monthName.textItem.size = 36;

    monthName.textItem.justification = Justification.RIGHT;

    monthName.textItem.height = 40;

    monthName.textItem.width = 160;

    monthName.textItem.contents = months[curr];

  5. 5

    Rotate the layer -90 degrees and reposition it.

    Example:

    monthName.rotate(-90);

    monthName.textItem.position = new Array(80+(500x), (300+320y));

  6. 6

    Create a text layer for the dates of each month.

    Example:

    days = group.artLayers.add();

    days.kind = LayerKind.TEXT;

    days.name = "Dates";

    days.textItem.Justification = Justification.CENTER;

    days.textItem.color = dateColor

    days.textItem.size = 24;

    days.textItem.position = new Array (120+(500x), 80+320y));

    }

  1. 1

    Create the dates for each month. Remember that numbering starts with 0.

    Example:

    text = week Header;

    start Date = new Date(year, curr, 1);

    n = startDate.getDay()

    for(i=0; i<n-1; i++)

    text + =first Indent;

    }

  2. 2

    Generate all the dates of the month.

    d=1;

    while(d <= daysOfMonth(curr,year)){

    text+=makeDay(d);

    if(i ==6)

    text+= "\r";

    }

    i++

    d++

    if(i==7)

    i=0

    }

    days.textItem.content = text;

    }

  3. 3

    Create the year layer.

    Example:

    year Layer= doc.artLayers.add()

    yearLayer.kind - LayerKind.TEXT;

    yearLayer.name - year;

    yearLayer.textItem.contents = year

    yearLayer.textItem.size = 80

    yearLayer.textItem.position = new Array(1400,1800)

  1. 1

    Select "Adobe Photoshop" from the drop down menu.

  2. 2

    Use "connect with target application" if Photoshop isn't currently running.

  3. 3

    Press the "Play" icon.

Tips and warnings

  • The script doesn't have to be written using Adobe's utility. Any text editor will work. To allow for double clicking to activate Photoshop, use the file type ".jsx" instead of the standard ".js".

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.