أداة التحقق من توليد جافا لرجوعك. المحتوى المحدد كما يلي
package com.demo.utils ؛ import java.awt.basicsstroke ؛ استيراد java.awt.color ؛ استيراد java.awt.font ؛ استيراد java.awt.graphics2d ؛ import java.awt.Renderinghints ؛ java.io.fileOutputStream ؛ import java.io.ioException ؛ استيراد java.io.outputstream ؛ استيراد java.util.random ؛ استيراد javax.imageio.imageio ؛/** * replate class class * */ablics acefcant عشوائي عشوائي = جديد عشوائي () ؛ ) font.roman_baseline ، font.truetype_font ، font.type1_font ، font.bold} ؛ السلسلة الثابتة النهائية الخاصة [] font = {"ravie" ، "forte" ، "arial" ، "Courier"} ؛ int static static int [] xarr = {23 ، 24 ، 19 ، 20 ، 21} ؛ int static static int [] yarr = {20 ، 21 ، 22 ، 23 ، 24 ، 25 ، 16 ، 17 ، 18} ؛ int static static int [] font_size = {28 ، 29 ، 30 ، 21 ، 22 ، 23 ، 24 ، 27 ، 26 ، 25} ؛ / ** * ارسم مخطط رمز عشوائي * param out * param عرض * param الارتفاع * throws ioException */ public static void draw (OutputSream Out ، قيمة السلسلة) يلقي ioException {int width = 100 ، height = 40 ؛ BufferedImage BI = جديد BufferEdImage (العرض ، الارتفاع ، bufferedImage.type_int_rgb) ؛ graphics2d g = (Graphics2d) bi.getGraphics () ؛ G.SetRenderingHint (renderinghints.key_antialiasing ، renderinghints.value_antialias_on) ؛ G.SetColor (RandColor (240 ، 255)) ؛ G.FillRect (0 ، 0 ، العرض ، الارتفاع) ؛ G.DrawRect (1 ، 1 ، العرض - 2 ، الارتفاع - 2) ؛ لـ (int i = 0 ؛ i <10 ؛ i ++) {g.setColor (RandColor (150 ، 250)) ؛ G.Drawoval (Random.NextInt (110) ، Random.NextInt (24) ، 5 + Random.NextInt (10) ، 5 + Random.NextInt (10)) ؛ } g.setfont (getFont ()) ؛ G.SetColor (RandColor (Xarr [(int) (Math.Random () * 5)] ، 254)) ؛ لـ (int i = 0 ، len = value.length () ؛ i <len ؛ i ++) {string rand = string.valueof (value.charat (i)) ؛ int درجة = عشوائية. nextint (23) ؛ if (i ٪ 2 == 0) {درجة = درجة * (-1) ؛ } int x = xarr [(int) (math.random () * 5)] * i ، y = yarr [(int) (math.random () * 8)] ؛ G.Rotate (Math.Toradians (درجة) ، X ، Y) ؛ G.SetColor (RandColor (48 ، 254)) ؛ G.DrawString (Rand ، x + 8 ، y + 10) ؛ G.Rotate (-math.toradians (درجة) ، x ، y) ؛ } // الخط الأوسط للصورة G.SetColor (RandColor (0 ، 200)) ؛ // العرض هو عرض الخط ، نوع العائم الأساسية BS = New BasicStroke (2) ؛ G.SetStroke (BS) ؛ // ارسم المنحنى quadcurve2d.double curve = quadcurve2d.double جديد (0d ، عشوائي. G.Draw (منحنى) ؛ // تدمير الصورة g.dispose () ؛ imageio.write (Bi ، "png" ، Out) ؛ } الخط الثابت الخاص getFont () {return new font (font [(int) (Math.Random () * 4)] ، fontstyle [(int) (Math.Random () * 12)] ، font_size [(int) (math.random () * 10)]) ؛ } RandColor color static private (int fc ، int bc) {// احصل على لون عشوائي يعطى نطاقًا إذا (fc> 255) {fc = 255 ؛ } if (bc> 255) {bc = 255 ؛ } int r = fc + random.nextint (bc - fc) ؛ int g = fc + random.nextint (bc - fc) ؛ int b = fc + random.nextint (bc - fc) ؛ إرجاع اللون الجديد (R ، G ، B) ؛ ) 'c' ، 'd' ، 'e' ، 'f' ، 'g' ، 'h' ، 'j' ، 'k' ، 'l' ، 'm' ، 'n' ، 'p' ، 'q' ، 'r' ، 's' ، 't' ، 'u' ، u '' ، 7 '' ، 6 '، 6' ، 6 '،' السلسلة الثابتة العامة getRandom (int size) {StringBuilder SB = new StringBuilder () ؛ لـ (int i = 0 ؛ i <size ؛ i ++) {sb.append (c [math.abs (random.nextint ()) ٪ c.length]) ؛ } return sb.toString () ؛ } static void main (string [] args) يرمي ioException {for (int i = 1 ؛ i <10 ؛ i ++) {fileOtputStream out = new FileOutputStream ("d: // bb"+i+". png") ؛ رسم (خارج ، getRandom (4)) ؛ }}}ما سبق هو كل محتوى هذه المقالة. آمل أن يكون ذلك مفيدًا لتعلم الجميع وآمل أن يدعم الجميع wulin.com أكثر.