【问题标题】:Icon calendar generator图标日历生成器
【发布时间】:2016-07-14 03:43:09
【问题描述】:

是否有任何日历 Photoshop/illustrator 脚本可以自动生成类似于此日历图标图像的日期编号?

我需要带有日期 (1,2,3..31) 和每个月名称的类似图标,但格式为 .png。我不能使用 html/css3 和 jquery 来创建图标。

感谢您的回答和帮助

【问题讨论】:

  • 使用背景图片并在上面写上月份和日期...

标签: image generator photoshop adobe-illustrator photoshop-script


【解决方案1】:

是的,这是可能的。我喜欢挑战:)

首先打开模板图片 其次创建一个文件夹文件夹C:\temp\calendar(或在脚本中更改目标路径)

运行下面的脚本,它将生成使用 sdate 和 eDate(开始和结束日期)定义的日期 - 当前为 11 月 30 日至 12 月 01 日

// Load in background image before running script

// call the source document
var srcDoc = app.activeDocument;

var sDate = new Date("November, 30, 2016 00:00:00");
var eDate = new Date("January,  01, 2017 00:00:00");

var myPath = "c:\\temp\\calendar"

printDate(sDate, eDate, myPath, srcDoc);

//-----------------------------
function printDate(start, end, apath, sauce)
{
  if (start == undefined) return;
  if (end == undefined) return;

  // set long month names
  var monthNames = ["January", "February", "March", "April", "May", "June",
    "July", "August", "September", "October", "November", "December"
  ];

  str = "";

  // main loop here
  while(start <= end)
  {

    // Display the month, day, and year.
    // getMonth() returns a 0-based number.
    var monthNum = start.getMonth()+1;
    var month = monthNames[monthNum-1].toUpperCase();
    var day   = start.getDate();
    var year  = start.getFullYear();

    // alert(month + " " + day + " " + year);

    // num padding
    if (monthNum < 10) monthNum = "0" + monthNum;
    if (day < 10) day = "0" + day;

    var theDate = "cal_" + monthNum + "_" + day + "_" + year;

    duplicateIt(theDate);

    var day = start.getDate();
    str = (day);         

    var newDate = start.setDate(start.getDate() + 1);

    // fontface, size, R,G,B, text, X, Y
    // print bigmonth
    createText("Arial-BoldMT", 38.0,255, 255, 255, month, 582, 460);

    // print big day
    createText("Arial-BoldMT", 176.0, 0, 0, 0, day, 582, 1144);

    var f  = apath + "\\" + theDate + ".png";

    // alert(f)
    saveAsPNG(f, 10);

    // close that saved png
    app.activeDocument.close();

    // get the original source doc
    app.activeDocument = sauce;

    // reset start
    start = new Date(newDate);
  }
}

// function DUPLICATE IT (str)
// --------------------------------------------------------
function duplicateIt(str)
{
  // duplicate image into new document
  if (arguments.length == 0) str = "temp";

  var id428 = charIDToTypeID( "Dplc" );
  var desc92 = new ActionDescriptor();
  var id429 = charIDToTypeID( "null" );
  var ref27 = new ActionReference();
  var id430 = charIDToTypeID( "Dcmn" );
  var id431 = charIDToTypeID( "Ordn" );
  var id432 = charIDToTypeID( "Frst" );
  ref27.putEnumerated( id430, id431, id432 );
  desc92.putReference( id429, ref27 );
  var id433 = charIDToTypeID( "Nm  " );
  desc92.putString( id433, str ); // name
  executeAction( id428, desc92, DialogModes.NO );
}

// function SAVE JPEG(file name & path)
// --------------------------------------------------------
function saveAsPNG(afilePath)
{
  // flatten it
  activeDocument.flatten();

  // save as a png
  var pngFile = new File(afilePath);
  pngSaveOptions = new PNGSaveOptions();
  pngSaveOptions.embedColorProfile = true;
  pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
  pngSaveOptions.matte = MatteType.NONE; pngSaveOptions.quality = 1;

  activeDocument.saveAs(pngFile, pngSaveOptions, false, Extension.LOWERCASE);
}

// function CREATE TEXT(typeface, size, R, G, B, content, Xpos, Ypos, justify)
// --------------------------------------------------------
function createText(fface, size, colR, colG, colB, content, X, Y)
{

  // Add a new layer in the new document
  var artLayerRef = app.activeDocument.artLayers.add()

  // Specify that the layer is a text layer
  artLayerRef.kind = LayerKind.TEXT;
  artLayerRef.name = content;

  //This section defines the color of the text
  textColor = new SolidColor();
  textColor.rgb.red = colR;
  textColor.rgb.green = colG;
  textColor.rgb.blue = colB;

  //Get a reference to the text item so
  // that we can add the text and format it a bit
  textItemRef = artLayerRef.textItem
  textItemRef.font = fface;
  textItemRef.contents = content;
  textItemRef.color = textColor;
  textItemRef.size = size;
  //pixels from the left, pixels from the top
  textItemRef.position = new Array(X, Y)

  just = Justification.CENTER;

  activeDocument.activeLayer.textItem.justification = just;
}

它将它们保存为以日期命名的 .PNG 文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-14
    • 1970-01-01
    • 1970-01-01
    • 2020-03-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多