独行之狼
3 years ago
11 changed files with 429 additions and 44 deletions
Binary file not shown.
Binary file not shown.
@ -0,0 +1,85 @@
|
||||
package com.fr.plugin.cool.cartnoon; |
||||
|
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.plugin.cool.cartnoon.utils.AnimatedGifEncoder; |
||||
import com.fr.plugin.cool.cartnoon.web.ImageViewer; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.script.AbstractFunction; |
||||
import com.fr.stable.Primitive; |
||||
import com.fr.stable.fun.Authorize; |
||||
import com.jhlabs.image.BlockFilter; |
||||
import com.jhlabs.image.GaussianFilter; |
||||
|
||||
import java.awt.*; |
||||
import java.awt.image.BufferedImage; |
||||
import java.io.ByteArrayOutputStream; |
||||
import java.io.IOException; |
||||
|
||||
@EnableMetrics |
||||
@Authorize(callSignKey = FunConstants.PLUGIN_ID) |
||||
public class FRBlurText extends AbstractFunction { |
||||
@Override |
||||
@Focus(id = FunConstants.PLUGIN_ID, text = "Plugin-Function_FRBlurText", source = Original.PLUGIN) |
||||
public Object run(Object[] args) { |
||||
if(!FunConstants.Author()){ |
||||
return FunConstants.AUTHOR_ERROR; |
||||
} |
||||
if(!FunConstants.CheckArgs(args,6)){ |
||||
return Primitive.ERROR_VALUE; |
||||
} |
||||
final String text = args[0].toString(); |
||||
|
||||
int width= Integer.parseInt(args[1].toString()); |
||||
int height= Integer.parseInt(args[2].toString()); |
||||
int fontSize= Integer.parseInt(args[3].toString()); |
||||
int rate= Integer.parseInt(args[4].toString()); |
||||
final Color color = FunConstants.TextToColor(args[5].toString()); |
||||
|
||||
final String id=FunConstants.GetCellId(this); |
||||
final String url="/webroot/decision/url/img?id="+id; |
||||
try { |
||||
CreateMasaicText(id,text,fontSize,rate,color); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return "<img src=\""+url+"\" width=\""+width+"\" height=\""+height+"\" />"; |
||||
|
||||
} |
||||
|
||||
|
||||
private void CreateMasaicText(String id, String text, int fontSize, int rate, Color color) throws IOException { |
||||
|
||||
// 读数据
|
||||
AnimatedGifEncoder e = new AnimatedGifEncoder(); |
||||
|
||||
ByteArrayOutputStream out=new ByteArrayOutputStream(); |
||||
e.start(out); |
||||
|
||||
//图片之间间隔时间
|
||||
e.setDelay(rate); // 1 frame per sec
|
||||
//重复次数 0表示无限重复 默认不重复
|
||||
e.setRepeat(0); |
||||
//添加图片
|
||||
final BufferedImage image = FunConstants.ImageFromMultiText(text, fontSize, color); |
||||
for (int o=100; o>0; o--) { |
||||
e.addFrame(setFilter(image,o)); |
||||
} |
||||
for (int i = 0; i < 30; i++) { |
||||
e.addFrame(image); |
||||
} |
||||
e.finish(); |
||||
|
||||
byte[] data = out.toByteArray(); |
||||
ImageViewer.gifData.put(id,data); |
||||
} |
||||
//图像上执行高斯模糊
|
||||
private BufferedImage setFilter(BufferedImage src,float radius) { |
||||
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR); |
||||
GaussianFilter gaussianFilter = new GaussianFilter(); |
||||
gaussianFilter.setRadius(radius); |
||||
gaussianFilter.filter(src, result); |
||||
return result; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,111 @@
|
||||
package com.fr.plugin.cool.cartnoon; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.plugin.cool.cartnoon.utils.AnimatedGifEncoder; |
||||
import com.fr.plugin.cool.cartnoon.web.ImageViewer; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.script.AbstractFunction; |
||||
import com.fr.stable.Primitive; |
||||
import com.fr.stable.fun.Authorize; |
||||
import net.coobird.thumbnailator.Thumbnails; |
||||
|
||||
import java.awt.*; |
||||
import java.awt.image.BufferedImage; |
||||
import java.io.ByteArrayOutputStream; |
||||
import java.io.IOException; |
||||
|
||||
@EnableMetrics |
||||
@Authorize(callSignKey = FunConstants.PLUGIN_ID) |
||||
public class FRClockTime extends AbstractFunction { |
||||
@Override |
||||
@Focus(id = FunConstants.PLUGIN_ID, text = "Plugin-Function_FRClockTime", source = Original.PLUGIN) |
||||
public Object run(Object[] args) { |
||||
if(!FunConstants.Author()){ |
||||
return FunConstants.AUTHOR_ERROR; |
||||
} |
||||
if(!FunConstants.CheckArgs(args,4)){ |
||||
return Primitive.ERROR_VALUE; |
||||
} |
||||
final String time = args[0].toString(); |
||||
if(time.split(":").length!=2){ |
||||
return Primitive.ERROR_VALUE; |
||||
} |
||||
int htime=Integer.parseInt(time.split(":")[0]); |
||||
if(htime>12){ |
||||
htime=htime%12; |
||||
} |
||||
int mtime=Integer.parseInt(time.split(":")[1]); |
||||
int width= Integer.parseInt(args[1].toString()); |
||||
int height= Integer.parseInt(args[2].toString()); |
||||
int rate= Integer.parseInt(args[3].toString()); |
||||
|
||||
final String id=FunConstants.GetCellId(this); |
||||
final String url="/webroot/decision/url/img?id="+id; |
||||
try { |
||||
CreateClockTime(id,htime,mtime,width,rate); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return "<img src=\""+url+"\" width=\""+width+"\" height=\""+height+"\" />"; |
||||
|
||||
} |
||||
|
||||
|
||||
private void CreateClockTime(String id, int htime,int mtime, int width, int rate) throws IOException { |
||||
|
||||
BufferedImage bufferColck = BaseUtils.readImage("com/fr/plugin/cool/cartnoon/web/resource/images/clock.png"); |
||||
final BufferedImage bufferHour = BaseUtils.readImage("com/fr/plugin/cool/cartnoon/web/resource/images/hour.png"); |
||||
final BufferedImage bufferMinute = BaseUtils.readImage("com/fr/plugin/cool/cartnoon/web/resource/images/minute.png"); |
||||
|
||||
bufferColck=setSize(bufferColck,width,width); |
||||
AnimatedGifEncoder encoder = new AnimatedGifEncoder(); |
||||
ByteArrayOutputStream out=new ByteArrayOutputStream(); |
||||
encoder.start(out); |
||||
encoder.setTransparent(Color.WHITE); |
||||
encoder.setRepeat(0); |
||||
encoder.setDelay(rate); |
||||
Graphics2D g2d = bufferColck.createGraphics(); |
||||
|
||||
int x1=bufferColck.getWidth()/2; |
||||
int y1=bufferColck.getHeight()/2; |
||||
int hrr=htime*360/12; |
||||
int hrm=mtime*30/60; |
||||
int mr=mtime*360/60; |
||||
|
||||
int o=36; |
||||
for (int i=0; i<=o; i++) { |
||||
g2d.setColor(Color.WHITE); |
||||
BufferedImage hImage1=setFilter(bufferHour,1,hrr+i*hrm/o); |
||||
BufferedImage hImage2=setSize(hImage1,bufferColck.getWidth(),bufferColck.getHeight()); |
||||
g2d.fillRect(x1/2,y1/2,x1,y1); |
||||
g2d.drawImage(hImage2,null,0,0); |
||||
|
||||
BufferedImage mImage1=setFilter(bufferMinute,1,i*mr/o); |
||||
BufferedImage mImage2=setSize(mImage1,bufferColck.getWidth(),bufferColck.getHeight()); |
||||
g2d.drawImage(mImage2,null,0,0); |
||||
encoder.addFrame(bufferColck); |
||||
|
||||
} |
||||
for (int i = 0; i <10 ; i++) { |
||||
encoder.addFrame(bufferColck); |
||||
} |
||||
|
||||
|
||||
g2d.dispose(); |
||||
encoder.finish(); |
||||
byte[] data = out.toByteArray(); |
||||
ImageViewer.gifData.put(id,data); |
||||
} |
||||
//设置图像旋转缩放
|
||||
private static BufferedImage setFilter(BufferedImage src, float scale, float rotate) throws IOException { |
||||
BufferedImage result = Thumbnails.of(src).scale(scale).rotate(rotate).asBufferedImage(); |
||||
return result; |
||||
} |
||||
private static BufferedImage setSize(BufferedImage src, int width, int height) throws IOException { |
||||
BufferedImage result = Thumbnails.of(src).size(width,height).asBufferedImage(); |
||||
return result; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,75 @@
|
||||
package com.fr.plugin.cool.cartnoon; |
||||
|
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.plugin.cool.cartnoon.utils.AnimatedGifEncoder; |
||||
import com.fr.plugin.cool.cartnoon.web.ImageViewer; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.script.AbstractFunction; |
||||
import com.fr.stable.Primitive; |
||||
import com.fr.stable.fun.Authorize; |
||||
import com.jhlabs.image.GaussianFilter; |
||||
import net.coobird.thumbnailator.Thumbnails; |
||||
|
||||
import java.awt.*; |
||||
import java.awt.image.BufferedImage; |
||||
import java.io.ByteArrayOutputStream; |
||||
import java.io.IOException; |
||||
|
||||
@EnableMetrics |
||||
@Authorize(callSignKey = FunConstants.PLUGIN_ID) |
||||
public class FRCustomAnimation extends AbstractFunction { |
||||
@Override |
||||
@Focus(id = FunConstants.PLUGIN_ID, text = "Plugin-Function_FRCustomAnimation", source = Original.PLUGIN) |
||||
public Object run(Object[] args) { |
||||
if(!FunConstants.Author()){ |
||||
return FunConstants.AUTHOR_ERROR; |
||||
} |
||||
if(!FunConstants.CheckArgs(args,4)){ |
||||
return Primitive.ERROR_VALUE; |
||||
} |
||||
String[] arrSrcImg=FunConstants.GetSrcImgFromArgs(args[0]); |
||||
int rate= Integer.parseInt(args[1].toString()); |
||||
int width= Integer.parseInt(args[2].toString()); |
||||
int height= Integer.parseInt(args[3].toString()); |
||||
|
||||
final String id=FunConstants.GetCellId(this); |
||||
final String url="/webroot/decision/url/img?id="+id; |
||||
try { |
||||
Create(id,arrSrcImg,rate,width,height); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return "<img src=\""+url+"\" width=\""+width+"\" height=\""+height+"\" />"; |
||||
|
||||
} |
||||
|
||||
|
||||
private void Create(String id, String[] srcImage, int rate,int width,int height) throws IOException { |
||||
|
||||
// 读数据
|
||||
AnimatedGifEncoder e = new AnimatedGifEncoder(); |
||||
|
||||
ByteArrayOutputStream out=new ByteArrayOutputStream(); |
||||
e.start(out); |
||||
|
||||
//图片之间间隔时间
|
||||
e.setDelay(rate); // 1 frame per sec
|
||||
//重复次数 0表示无限重复 默认不重复
|
||||
e.setRepeat(0); |
||||
//添加图片
|
||||
int imgLen=srcImage.length; |
||||
for (int i = 0; i < imgLen; i++) { |
||||
e.addFrame(setSize(FunConstants.readImage(srcImage[i]),width,height)); |
||||
} |
||||
e.finish(); |
||||
|
||||
byte[] data = out.toByteArray(); |
||||
ImageViewer.gifData.put(id,data); |
||||
} |
||||
|
||||
private BufferedImage setSize(BufferedImage src, int width, int height) throws IOException { |
||||
BufferedImage result = Thumbnails.of(src).size(width,height).asBufferedImage(); |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,84 @@
|
||||
package com.fr.plugin.cool.cartnoon; |
||||
|
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.plugin.cool.cartnoon.utils.AnimatedGifEncoder; |
||||
import com.fr.plugin.cool.cartnoon.web.ImageViewer; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.script.AbstractFunction; |
||||
import com.fr.stable.Primitive; |
||||
import com.fr.stable.fun.Authorize; |
||||
import com.jhlabs.image.BlockFilter; |
||||
|
||||
import java.awt.*; |
||||
import java.awt.image.BufferedImage; |
||||
import java.io.ByteArrayOutputStream; |
||||
import java.io.IOException; |
||||
|
||||
@EnableMetrics |
||||
@Authorize(callSignKey = FunConstants.PLUGIN_ID) |
||||
public class FRMasaicText extends AbstractFunction { |
||||
@Override |
||||
@Focus(id = FunConstants.PLUGIN_ID, text = "Plugin-Function_FRMasaicText", source = Original.PLUGIN) |
||||
public Object run(Object[] args) { |
||||
if(!FunConstants.Author()){ |
||||
return FunConstants.AUTHOR_ERROR; |
||||
} |
||||
if(!FunConstants.CheckArgs(args,6)){ |
||||
return Primitive.ERROR_VALUE; |
||||
} |
||||
final String text = args[0].toString(); |
||||
|
||||
int width= Integer.parseInt(args[1].toString()); |
||||
int height= Integer.parseInt(args[2].toString()); |
||||
int fontSize= Integer.parseInt(args[3].toString()); |
||||
int rate= Integer.parseInt(args[4].toString()); |
||||
final Color color = FunConstants.TextToColor(args[5].toString()); |
||||
|
||||
final String id=FunConstants.GetCellId(this); |
||||
final String url="/webroot/decision/url/img?id="+id; |
||||
try { |
||||
CreateMasaicText(id,text,fontSize,rate,color); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return "<img src=\""+url+"\" width=\""+width+"\" height=\""+height+"\" />"; |
||||
|
||||
} |
||||
|
||||
|
||||
private void CreateMasaicText(String id, String text, int fontSize, int rate, Color color) throws IOException { |
||||
|
||||
// 读数据
|
||||
AnimatedGifEncoder e = new AnimatedGifEncoder(); |
||||
|
||||
ByteArrayOutputStream out=new ByteArrayOutputStream(); |
||||
e.start(out); |
||||
|
||||
//图片之间间隔时间
|
||||
e.setDelay(rate); // 1 frame per sec
|
||||
//重复次数 0表示无限重复 默认不重复
|
||||
e.setRepeat(0); |
||||
//添加图片
|
||||
final BufferedImage image = FunConstants.ImageFromMultiText(text, fontSize, color); |
||||
for (int o=36; o>0; o--) { |
||||
e.addFrame(setFilter(image,o)); |
||||
} |
||||
for (int i = 0; i < 30; i++) { |
||||
e.addFrame(image); |
||||
} |
||||
e.finish(); |
||||
|
||||
byte[] data = out.toByteArray(); |
||||
ImageViewer.gifData.put(id,data); |
||||
} |
||||
//设置图像马赛克
|
||||
private BufferedImage setFilter(BufferedImage src, int blockSize) { |
||||
BufferedImage result = new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_4BYTE_ABGR); |
||||
BlockFilter blockFilter = new BlockFilter(); |
||||
blockFilter.setBlockSize(blockSize); |
||||
blockFilter.filter(src, result); |
||||
return result; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue