موقع طلبة جامعة البحرين

يمكنك تصفح الموقع كزائر ولكن ندعوك لتسجيل عضوية خاصة بك لتحصل على كافة الصلاحيات مثل تنزيل ملفات المكتبة وقراءة تعليقات هيئة التدريس وغيرها. يمكنك الحصول على عضوية مجانية بالضغط على زر تسجيل. إذا قمت بالتسجيل مسبقا فيمكنك الضغط على زر دخول.

تسجيل دخول
  • قسم المكتبة الجامعية مغلق مؤقتا بعد الاستهداف التي تعرضت له بعض خدمات أمازون في البحرين، جاري استرجاع الملفات ونقلها إلى سيرفرات جديدة وسيتم بعدها اعادة افتتاح المكتبة

اخر اختراعاتي (برامجي) v2.0

Magnum Opus

Well-Known Member
تاريخ التسجيل
7 سبتمبر 2013
المشاركات
97
المجموعة
ذكر
الدفعة الدراسية
2013
الكلية
كلية تقنية المعلومات
التخصص
Computer Science
أخر مرة سويت موضوع عن برنامج سويته عن الملل يسوي وولبيبر مكون من أرقام و حركات مال أيتي هني:RpS_lol:
قلت بخلي السورس كود و الرنامج كامل إذا خلصته. عاد فرمتت اللابتوب و ضاعوا برامجي كاملهم :tears: فكنسلت السالفة. بعدين شفت كومنتات في الموضوع و تشجعت اسويه من جديد :RpS_love:. و فعلا سويته. بخلي هني البرنامج نفسه للي يبي يجربه و بخلي بعد السورس كود للي مهتم ان يشوف شلون سويته (السورس كود حد حده عفسة ما رتبته ولا سويت ليه documentation يعني ما بينفهم عدل. ‘ذا احد يبي أقدر ارتبه ليه و اضبطه). المهم هذي صور توني مسونها و أنا قاعد أجربه.

1.webp

4.webp

2.webp

و هذي صورة الـ user interface.

UI.webp

في بعض الشغلات ما خليتها في البرنامج لأن لازم أخليها في الإنترفيس و انا ما أطيق اشتغل في الانترفيس :schmoll:. و عادةً انا أسوي الإنترفيس بالـ swing و أكتبه كتابة, بس حصلت plugin خوش كلام يسوي سريع و قوي بعدين يعطيني السورس أعدله ع راحتي :RpS_love: إسمه WindowBuilder و اهو plugin مال eclipse.

البرنامج نفسه موجود في المرفقات ع صيغة .rar .. السورس 2 classes بس خليته واحد للإنترفيس و واحد حق يسوي الصورة :
الإنترفيس :
كود:
package core;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.border.BevelBorder;


public class UserInterface extends JFrame implements ActionListener {
    private static final long serialVersionUID = 1L;
    private static final int MAX_SIZE = 5000, MAX_KERNEL = 100, MAX_RGB = 255, MAX_CHAR_SIZE = 100;
    private JPanel contentPane;
    private JTextField tfWidth, tfHeight, tfRed, tfGreen, tfBlue, tfKernelSize, tfDestination, tfSize;
    private JButton btnBrowse, btnGenerate;
    private JCheckBox chckbxVertical, chckbxHorizontal;
    private JRadioButton rdbtnAlphanumeric, rdbtnNumeric, rdbtnBinary, rdbtnForeground, rdbtnBackground;
    private JRadioButtonGroup bgrpType, bgrpColor;
    private JFileChooser fileChooser;
    private File outFile;
    int[] numsFore = new int[3], numsBack = new int[3];


    boolean debugFill = true;


    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        UserInterface frame = new UserInterface();
        frame.setVisible(true);
    }


    /**
     * Create the frame.
     */
    public UserInterface() {
        setTitle("Salmans Wallpaper Maker");
        setResizable(false);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 450, 300);
        contentPane = new JPanel();
        contentPane.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
        setContentPane(contentPane);
        contentPane.setLayout(null);


        JLabel lblStatus = new JLabel("Status :");
        lblStatus.setBounds(10, 236, 414, 14);
        contentPane.add(lblStatus);


        JPanel panel = new JPanel();
        panel.setBackground(Color.LIGHT_GRAY);
        panel.setBounds(10, 11, 414, 221);
        contentPane.add(panel);


        btnGenerate = new JButton("Generate !");
        btnGenerate.setToolTipText("Make the image and save it");
        btnGenerate.setFont(new Font("Tahoma", Font.PLAIN, 15));
        btnGenerate.setBounds(132, 190, 109, 20);
        btnGenerate.addActionListener(this);
        panel.setLayout(null);
        panel.add(btnGenerate);


        JLabel lblWidth = new JLabel("Width :");
        lblWidth.setBounds(10, 10, 48, 14);
        panel.add(lblWidth);


        JLabel lblHeight = new JLabel("Height :");
        lblHeight.setBounds(10, 29, 48, 14);
        panel.add(lblHeight);


        tfWidth = new JTextField();
        tfWidth.setToolTipText("Enter the desired image width");
        tfWidth.setBounds(64, 6, 55, 20);
        panel.add(tfWidth);
        tfWidth.setColumns(10);


        tfHeight = new JTextField();
        tfHeight.setToolTipText("Enter the desired image height");
        tfHeight.setBounds(64, 26, 55, 20);
        panel.add(tfHeight);
        tfHeight.setColumns(10);


        rdbtnAlphanumeric = new JRadioButton("Alphanumeric");
        rdbtnAlphanumeric.setToolTipText("Numbers and letters in the image");
        rdbtnAlphanumeric.setBackground(Color.LIGHT_GRAY);
        rdbtnAlphanumeric.setBounds(10, 100, 109, 23);
        panel.add(rdbtnAlphanumeric);


        rdbtnNumeric = new JRadioButton("Numeric");
        rdbtnNumeric.setToolTipText("Only numbers in the image");
        rdbtnNumeric.setBackground(Color.LIGHT_GRAY);
        rdbtnNumeric.setBounds(10, 74, 109, 23);
        panel.add(rdbtnNumeric);


        rdbtnBinary = new JRadioButton("Binary");
        rdbtnBinary.setToolTipText("Only 1s and 0s in the image");
        rdbtnBinary.setBackground(Color.LIGHT_GRAY);
        rdbtnBinary.setBounds(10, 126, 109, 23);
        panel.add(rdbtnBinary);


        JPanel panel_1 = new JPanel();
        panel_1.setBackground(Color.DARK_GRAY);
        panel_1.setBounds(292, 35, 112, 114);
        panel.add(panel_1);
        panel_1.setLayout(null);


        tfRed = new JTextField();
        tfRed.setBounds(37, 8, 46, 20);
        panel_1.add(tfRed);
        tfRed.setColumns(10);


        tfGreen = new JTextField();
        tfGreen.setBounds(37, 28, 46, 20);
        panel_1.add(tfGreen);
        tfGreen.setColumns(10);


        tfBlue = new JTextField();
        tfBlue.setBounds(37, 48, 46, 20);
        panel_1.add(tfBlue);
        tfBlue.setColumns(10);


        JLabel lblR = new JLabel("R :");
        lblR.setBounds(10, 10, 46, 14);
        lblR.setToolTipText("Red");
        lblR.setForeground(Color.WHITE);
        panel_1.add(lblR);


        JLabel lblG = new JLabel("G :");
        lblG.setBounds(10, 30, 46, 14);
        lblG.setToolTipText("Green");
        lblG.setForeground(Color.WHITE);
        panel_1.add(lblG);


        JLabel lblB = new JLabel("B :");
        lblB.setBounds(10, 50, 46, 14);
        lblB.setToolTipText("Blue");
        lblB.setForeground(Color.WHITE);
        panel_1.add(lblB);


        rdbtnForeground = new JRadioButton("Foreground");
        rdbtnForeground.setBounds(0, 70, 109, 23);
        rdbtnForeground.setToolTipText("Letters color");
        rdbtnForeground.setForeground(Color.WHITE);
        rdbtnForeground.setBackground(Color.DARK_GRAY);
        panel_1.add(rdbtnForeground);


        rdbtnBackground = new JRadioButton("Background");
        rdbtnBackground.setBounds(0, 90, 109, 23);
        rdbtnBackground.setToolTipText("Background color");
        rdbtnBackground.setForeground(Color.WHITE);
        rdbtnBackground.setBackground(Color.DARK_GRAY);
        panel_1.add(rdbtnBackground);


        JLabel lblColors = new JLabel("Colors");
        lblColors.setBounds(323, 10, 46, 14);
        panel.add(lblColors);


        JPanel panel_2 = new JPanel();
        panel_2.setBackground(Color.DARK_GRAY);
        panel_2.setBounds(148, 34, 112, 89);
        panel.add(panel_2);
        panel_2.setLayout(null);


        chckbxHorizontal = new JCheckBox("Horizontal");
        chckbxHorizontal.setToolTipText("Background will be blurred horizontally");
        chckbxHorizontal.setForeground(Color.WHITE);
        chckbxHorizontal.setFont(new Font("Tahoma", Font.PLAIN, 11));
        chckbxHorizontal.setBackground(Color.DARK_GRAY);
        chckbxHorizontal.setBounds(6, 10, 97, 23);
        panel_2.add(chckbxHorizontal);


        chckbxVertical = new JCheckBox("Vertical");
        chckbxVertical.setFont(new Font("Tahoma", Font.PLAIN, 11));
        chckbxVertical.setToolTipText("Background will be blurred vertically");
        chckbxVertical.setForeground(Color.WHITE);
        chckbxVertical.setBackground(Color.DARK_GRAY);
        chckbxVertical.setBounds(6, 30, 97, 23);
        panel_2.add(chckbxVertical);


        tfKernelSize = new JTextField();
        tfKernelSize.setBounds(41, 62, 46, 20);
        panel_2.add(tfKernelSize);
        tfKernelSize.setColumns(10);


        JLabel lblSize = new JLabel("Size :");
        lblSize.setForeground(Color.WHITE);
        lblSize.setBounds(10, 65, 46, 14);
        panel_2.add(lblSize);


        JLabel lblBlur = new JLabel("Blur");
        lblBlur.setBounds(195, 10, 46, 14);
        panel.add(lblBlur);


        JLabel lblSaveDestination = new JLabel("Save destination :");
        lblSaveDestination.setBounds(10, 164, 109, 14);
        panel.add(lblSaveDestination);


        tfDestination = new JTextField();
        tfDestination.setBounds(114, 161, 178, 20);
        panel.add(tfDestination);
        tfDestination.setColumns(10);


        bgrpType = new JRadioButtonGroup();
        bgrpType.addButton(rdbtnAlphanumeric);
        bgrpType.addButton(rdbtnNumeric);
        bgrpType.addButton(rdbtnBinary);


        bgrpColor = new JRadioButtonGroup();
        bgrpColor.addButton(rdbtnForeground);
        bgrpColor.addButton(rdbtnBackground);
        bgrpColor.setActiveButton(rdbtnForeground);
        bgrpColor.giveAsActionListener(this);


        btnBrowse = new JButton("Browse ...");
        btnBrowse.setBounds(302, 160, 102, 23);
        btnBrowse.addActionListener(this);
        panel.add(btnBrowse);


        lblSize = new JLabel("Size :");
        lblSize.setToolTipText("Character size");
        lblSize.setBounds(10, 46, 46, 14);
        panel.add(lblSize);


        tfSize = new JTextField();
        tfSize.setBounds(64, 47, 55, 20);
        panel.add(tfSize);
        tfSize.setColumns(10);
        bgrpType.setActiveButton(bgrpType.get(0));


        fileChooser = new JFileChooser(System.getProperty("user.home"));


        if (debugFill) {
            setAlwaysOnTop(true);
            tfWidth.setText("500");
            tfHeight.setText("500");
            tfSize.setText("10");
            tfKernelSize.setText("5");
            tfRed.setText("255");
            tfGreen.setText("255");
            tfBlue.setText("255");
            tfDestination.setText("C:\\Users\\Magnum Opus\\Desktop\\salman.png");


        }
    }


    public void actionPerformed(ActionEvent e) {
        Object src = e.getSource();


        if (src == btnGenerate && !inputErrors()) {
            // TODO
            if (rdbtnForeground.isSelected()) {
                rdbtnBackground.doClick();
                rdbtnForeground.doClick();
            } else {
                rdbtnForeground.doClick();
                rdbtnBackground.doClick();
            }


            int width, height, charSize;
            Generator.Type type;
            Color bgColor, fgColor;


            width = Integer.parseInt(tfWidth.getText());
            height = Integer.parseInt(tfHeight.getText());
            charSize = Integer.parseInt(tfSize.getText());


            if (rdbtnAlphanumeric.isSelected())
                type = Generator.Type.ALNM;
            else if (rdbtnNumeric.isSelected())
                type = Generator.Type.NUM;
            else
                type = Generator.Type.BIN;


            bgColor = new Color(numsBack[0], numsBack[1], numsBack[2]);
            fgColor = new Color(numsFore[0], numsFore[1], numsFore[2]);


            outFile = new File(tfDestination.getText());


            saveImage(Generator.generate(width, height, charSize, type, bgColor, fgColor, Integer.parseInt(tfKernelSize.getText()),
                    chckbxVertical.isSelected(), chckbxHorizontal.isSelected()));
        }


        if (src == btnBrowse) {
            if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {


                String path = fileChooser.getSelectedFile().getAbsolutePath();
                if (!path.endsWith(".jpg") || !path.endsWith(".png"))
                    path += ".png";


                tfDestination.setText(path);
                try {
                    outFile.createNewFile();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }


        if (src == rdbtnBackground) {
            String rt = tfRed.getText(), gt = tfGreen.getText(), bt = tfBlue.getText();
            int range = MAX_RGB;


            if (!isNumber(rt) || !isNumber(gt) || !isNumber(bt)) {
                showError("Colors value invalid\nMust Be numerical");
                bgrpColor.setActiveButton(bgrpColor.getByName("ForeGround"));
                return;
            }


            if (!inRange(rt, range) || !inRange(bt, range) || !inRange(gt, range)) {
                showError("Color value invalid\nMust be > 0 and < 256");
                bgrpColor.setActiveButton(bgrpColor.getByName("ForeGround"));
                return;
            }


            numsFore[0] = Integer.parseInt(rt);
            numsFore[1] = Integer.parseInt(gt);
            numsFore[2] = Integer.parseInt(bt);


            tfRed.setText(String.valueOf(numsBack[0]));
            tfGreen.setText(String.valueOf(numsBack[1]));
            tfBlue.setText(String.valueOf(numsBack[2]));
        }


        if (src == rdbtnForeground) {
            String rt = tfRed.getText(), gt = tfGreen.getText(), bt = tfBlue.getText();
            int range = MAX_RGB;


            if (!isNumber(rt) || !isNumber(gt) || !isNumber(bt)) {
                showError("Colors value invalid\nMust Be numerical");
                bgrpColor.setActiveButton(bgrpColor.getByName("BackGround"));
                return;
            }


            if (!inRange(rt, range) || !inRange(bt, range) || !inRange(gt, range)) {
                showError("Color value invalid\nMust be > 0 and < 256");
                bgrpColor.setActiveButton(bgrpColor.getByName("BackGround"));
                return;
            }


            numsBack[0] = Integer.parseInt(rt);
            numsBack[1] = Integer.parseInt(bt);
            numsBack[2] = Integer.parseInt(gt);


            tfRed.setText(String.valueOf(numsFore[0]));
            tfGreen.setText(String.valueOf(numsFore[1]));
            tfBlue.setText(String.valueOf(numsFore[2]));
        }
    }


    private boolean inputErrors() {
        if (!isNumber(tfWidth.getText()) || !inRange(tfWidth.getText(), MAX_SIZE)) {
            showError("Invalid width\nMust be > 0 and < " + MAX_SIZE);
            return true;
        }


        if (!isNumber(tfHeight.getText()) || !inRange(tfWidth.getText(), MAX_SIZE)) {
            showError("Invalid height\nMust be > 0 and < " + MAX_SIZE);
            return true;
        }


        if (!isNumber(tfSize.getText()) || !inRange(tfSize.getText(), MAX_CHAR_SIZE)) {
            showError("Invalid char size\nMust be > 0 and < " + MAX_CHAR_SIZE);
        }


        if (!isNumber(tfKernelSize.getText()) || !inRange(tfKernelSize.getText(), MAX_KERNEL)) {
            showError("Blur size invalid\nMust be > 0 and < " + MAX_KERNEL);
            return true;
        }


        if (!isNumber(tfRed.getText()) || !inRange(tfRed.getText(), MAX_RGB)) {
            showError("Invalid value in \"R\"\nMust be > 0 and < 255");
        }
        if (!isNumber(tfGreen.getText()) || !inRange(tfGreen.getText(), MAX_RGB)) {
            showError("Invalid value in \"G\"\nMust be > 0 and < 255");
        }
        if (!isNumber(tfBlue.getText()) || !inRange(tfBlue.getText(), MAX_RGB)) {
            showError("Invalid value in \"B\"\nMust be > 0 and < 255");
        }


        if (!new File(tfDestination.getText()).exists()) {
            showError("Destination file doesn't exist");
            return true;
        }


        return false;
    }


    private void showError(String error) {
        JOptionPane.showMessageDialog(this, error);
    }


    private boolean isNumber(String s) {
        for (int i = 0; i < s.length(); i++) {
            switch (s.charAt(i)) {
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':
            case '0':
                break;
            default:
                return false;
            }
        }
        return true;
    }


    private boolean inRange(String str, int range) {
        if (str.isEmpty()) {
            return false;
        }


        int num = Integer.parseInt(str);


        if (num < 0 || num > range)
            return false;
        else
            return true;
    }


    public void saveImage(BufferedImage image) {
        try {
            ImageIO.write(image, "png", outFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    private class JRadioButtonGroup implements ActionListener {
        private List<JRadioButton> buttons;
        private JRadioButton active = null;
        ActionListener lsnr;


        JRadioButtonGroup() {
            buttons = new ArrayList<JRadioButton>();
        }


        public JRadioButton getByName(String str) {
            for (JRadioButton b : buttons) {
                if (b.getText().toLowerCase().equals(str.toLowerCase()))
                    return b;
            }
            System.out.println("Can't find JRadioButton \"" + str + "\" in JButtonGroup");
            return null;
        }


        public void giveAsActionListener(ActionListener lsnr) {
            this.lsnr = lsnr;
        }


        public void addButton(JRadioButton button) {
            button.addActionListener(this);
            this.buttons.add(button);
        }


        public void setActiveButton(JRadioButton button) {
            this.active = button;
            for (JRadioButton b : buttons) {
                if (b != active) {
                    b.setSelected(false);
                } else {
                    b.setSelected(true);
                }
            }
        }


        public void actionPerformed(ActionEvent e) {
            setActiveButton((JRadioButton) e.getSource());
            if (lsnr != null) {
                lsnr.actionPerformed(e);
            }
        }


        public JRadioButton get(int index) {
            if (index > buttons.size()) {
                System.err.println("Index out of bounds. int JButtonGroup. index : " + index);
            }
            return buttons.get(index);
        }
    }
}

اللي يسوي الصورة :
كود:
package core;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.util.Random;


public class Generator {
    private static Random rand = new Random();
    static Color COLOR;


    enum Type {
        ALNM, NUM, BIN
    }


    public static BufferedImage generate(int width, int height, int charSize, Type type, Color bgColor, Color fgColor, int kernelSize,
            boolean blurVert, boolean blurHor) {


        COLOR = bgColor;
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2d = (Graphics2D) image.getGraphics();


        g2d.setColor(bgColor);
        g2d.fillRect(0, 0, width, height);
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setColor(fgColor);
        g2d.setFont(new Font("Arial", Font.PLAIN, charSize));


        for (int y = 0; y < height / charSize; y++) {
            String line = "";
            for (int i = 0; i < width / charSize; i++) {
                line += getChar(type);
                g2d.setComposite(AlphaComposite.SrcAtop.derive((float) Math.min(1.0, rand.nextFloat()+0.2)));
                g2d.drawString(line, i * charSize, y * charSize);
                line = "";
            }
        }


        blur(image, kernelSize, blurHor, blurVert);


        return image;
    }


    private static void blur(BufferedImage image, int kernel, boolean hor, boolean vert) {
        if (hor || vert) {
            BufferedImage imageOrig = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
            BufferedImage imageBlur = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
            imageBlur.getGraphics().drawImage(image, 0, 0, null);
            imageOrig.getGraphics().drawImage(image, 0, 0, null);


            if (hor)
                blur(imageBlur, kernel, false);
            if (vert)
                blur(imageBlur, kernel, true);


            Graphics2D g2d = (Graphics2D) image.getGraphics();
            g2d.drawImage(imageBlur, 0, 0, null);
            g2d.setComposite(AlphaComposite.SrcOver.derive(0.5f));
            g2d.drawImage(imageOrig, 0, 0, null);
            return;
        }
    }


    private static void blur(BufferedImage image, int kernel, boolean vertical) {
        int owid = image.getWidth();
        int ohgh = image.getHeight();


        int wid = image.getWidth() + 2 * kernel;
        int hgh = image.getHeight() + 2 * kernel;


        int[][] colors = new int[owid][ohgh];
        for (int y = 0; y < ohgh; y++)
            for (int x = 0; x < owid; x++)
                colors[x][y] = image.getRGB(x, y);


        int[][] colorsCpy = new int[wid][hgh];
        for (int y = 0; y < ohgh; y++)
            for (int x = 0; x < owid; x++)
                colorsCpy[x][y] = COLOR.getRGB();


        for (int y = 0; y < ohgh; y++)
            for (int x = 0; x < owid; x++) {
                colorsCpy[x + kernel][y + kernel] = colors[x][y];
            }


        for (int y = 0; y < ohgh; y++)
            for (int x = 0; x < owid; x++) {
                int color = 0;
                int r = 0, g = 0, b = 0;


                for (int k = -kernel; k < kernel; k++) {
                    if (vertical)
                        color = colorsCpy[x + kernel][y + kernel + k];
                    else
                        color = colorsCpy[x + kernel + k][y + kernel];


                    r += (color >> 16) & 0xff;
                    g += (color >> 8) & 0xff;
                    b += (color >> 0) & 0xff;
                }


                int numAvg = kernel * 2 + 1;


                r /= numAvg;
                g /= numAvg;
                b /= numAvg;


                colors[x][y] = r << 16 | g << 8 | b;
            }


        for (int y = 0; y < ohgh; y++)
            for (int x = 0; x < owid; x++)
                image.setRGB(x, y, colors[x][y]);
    }


    private static char getChar(Type type) {
        if (type == Type.ALNM) {
            if (rand.nextBoolean()) {
                char ch = (char) (rand.nextInt(26) + 'A');
                return rand.nextBoolean() ? ch : (char) (ch - 'A' + 'a');
            } else {
                return getChar(Type.NUM);
            }
        } else if (type == Type.BIN) {
            return rand.nextBoolean() ? '1' : '0';
        } else if (type == Type.NUM) {
            return (char) (rand.nextInt(9) + '0');
        }
        return 1;
    }
}

البرنامج طبعا فيه أغلاط و مو كامل و يبي تعديل بس يعني عن الملل و جذي :RpS_sleep:
ارائكم و انتقاداتكم تهمني :smile2:
 

المرفقات

التعديل الأخير:
  • Like
التفاعلات: Hak
مافهمت شي

ويوم حاولت ان افهم بعد مافهمت p:




ويوم حاولت من جديد مرة ثانية افهم شتقول للأسف بعد مافهمت
على العموم يعطيك العافيه باروح قسمي البزنز :RpS_lol:
 
مافهمت شي

ويوم حاولت ان افهم بعد مافهمت p:




ويوم حاولت من جديد مرة ثانية افهم شتقول للأسف بعد مافهمت
على العموم يعطيك العافيه باروح قسمي البزنز :RpS_lol:

هههههههههه:RpS_lol: ما شفتين الموضوع الأولي لأنش من جدي. بس يلا أهم شي النية :RpS_lol:
 
كود:
        for (int y = 0; y < height / charSize; y++) {
            String line = "";
            for (int i = 0; i < width / charSize; i++) {
                line += getChar(type);
                g2d.setComposite(AlphaComposite.SrcAtop.derive((float) Math.min(1.0, rand.nextFloat()+0.2)));
                g2d.drawString(line, i * charSize, y * charSize);
                line = "";
            }
        }
ملاحظات عشوائية:
ماتحس بأنه اول String line = "" ما منها فايدة؟ كنت تقدر تعرف الفاريبل برع اللوب من بدل ما تكرر العملية x times على فاضي.
في الrand statement جان حددت الRange احسن لك.. ماجوف له داعي تجمع عليه 0.2 و تستعمل الmin function اساساً.
و اقرأ عن الrand seed لانه الكود مالك مب راندوم فعلياً..
NetBeans comes with a GUI builder btw.
مادري عن الDrawString بس مابكون احسن لو حطيته عقب ما يكمل الinner loop؟ بهالحالة لازم line = "" يكون عقب اللوب بعد (الفكرة انك تطبع سطر سطر و مب حرف حرف).

للعلم انا ما استعمل جافا.
 
التعديل الأخير:
ما شا الله ابداع ... صدق يناسبك عدل التخصص :smile2:
 
مافهمت شي

ويوم حاولت ان افهم بعد مافهمت p:




ويوم حاولت من جديد مرة ثانية افهم شتقول للأسف بعد مافهمت
على العموم يعطيك العافيه باروح قسمي البزنز :RpS_lol:

نفس الشي هههه

موفق خوك
​
 
كود:
        for (int y = 0; y < height / charSize; y++) {
            String line = "";
            for (int i = 0; i < width / charSize; i++) {
                line += getChar(type);
                g2d.setComposite(AlphaComposite.SrcAtop.derive((float) Math.min(1.0, rand.nextFloat()+0.2)));
                g2d.drawString(line, i * charSize, y * charSize);
                line = "";
            }
        }
ملاحظات عشوائية:
ماتحس بأنه اول String line = "" ما منها فايدة؟ كنت تقدر تعرف الفاريبل برع اللوب من بدل ما تكرر العملية x times على فاضي.
في الrand statement جان حددت الRange احسن لك.. ماجوف له داعي تجمع عليه 0.2 و تستعمل الmin function اساساً.
و اقرأ عن الrand seed لانه الكود مالك مب راندوم فعلياً..

NetBeans comes with a GUI builder btw.
مادري عن الDrawString بس مابكون احسن لو حطيته عقب ما يكمل الinner loop؟ بهالحالة لازم line = "" يكون عقب اللوب بعد (الفكرة انك تطبع سطر سطر و مب حرف حرف).

للعلم انا استعمل جافا.

دي الجهة بالذات الكود عفسة و كلش مو عاجبني يبي تعديل :RpS_lol:
شغلة ان الـ line خليته في البداية جذي "" أهو لأن بعدين داخل اللوب استخدمت +=. انا كنت بسوي كل char بروحه و بعدين بطبعه. بس مافي drawChar في بس drawChars. ف قلت بخلي سترنق كامل لكل سطر بضيف عليه الـ chars بعدين بطبعه. بس بعدين بسبب اختلاف الخط و الحروف يصير بعض السطور طوال و بعضهم قصار. ف خليت سترنق و قمت ساتعمله نفس الـ char, يعني كلحين اخلي فيه حرف واحد و اطبعه بعدين أمحي كل شي منه عشان اخلي الحرف الثاني (مثل ما قلت مو عاجبتني الطريقة و تبي تعديل).

بالعكس في قصة الستيتمنت اللي فيها الراندوم في شغلة حليوة و ذكية سويتها :blush-anim-cl:. أنا اللي أبيه من الراندوم في هذا السطر هو ان يعطيني Transparency v راندوم, يعني بين ال 1.0f و الـ 0.0f, الـ 1.0 يعني الـ 1.0 يبين كامل و الـ 0.0 يعني ما يبين كلش. بس في الحقيقة أنا أبي يكون كل حرف على الأقل يبين شوي ما أبي أي حرف يكون 0.0. ف ويش سويت, رحت استخدمت Random.nextFloat() اللي ترجع ليي فلوت بين الصفر و الواحد و زيدت عليها 0.2 ( يعني صار على الأقل 0.2 و على الأكثر 1.2). طبعا في الـ opacity ما تقدر تستخدم 1.2 لأن ماليه معنى ف بتحصل إيرور. في هالحالة انا استخدمت Math.min() بين الـ 1.0 و الـ rand.nextFloat()+0.2. كأنه اف ستيتمنت بس بطريقة أحلى :
كود:
float opac;
opac = rand.nextFloat()+0.2;
if(opac > 1.0)
opac = 1.0;
جذي أقدر اضمن ان أي char بيكون يبين ع الأقل بنسبة 20%. و ان ما بيعطيني أي إيرور
:shiny:
و شغلة السيد هذيك مالت الـ C++ هني شغال تمام بدون سيد و بدون أي كلام مثل ما تشوف الراندوم opacity مبينة في الصور (أعتقد أوتوماتيك ياخذ السيد من اللينوكس تايم).

I don't use NetBeans. I use Eclipse.


مثل ما قلت فوق عن شغلة ليش ما سويت سطر سطر :whistling:

أوكي ما يحتاج خط هالكبر :RpS_lol:

و شكرا ع القاء النظرة ع الكود :smile2:
 
للأسف ما فهمت قصدي.. nevermind!

ع فكرة عدلت الرد انا إلى ما استعمل وليس استعمل..

سؤال اخير هل الكود based on someone else's source code؟
 
للأسف ما فهمت قصدي.. nevermind!

ع فكرة عدلت الرد انا إلى ما استعمل وليس استعمل..

سؤال اخير هل الكود based on someone else's source code؟
فاهم قصدك انا و شرحت ليك ليش ما سويت مثل ما قلت مع ان هو جا في بالي اقرا الرد عدل بتفهم. و لا السورس كود كله من عندي مافي الا الـ GUI سويته بالـ WindowBuilder و بعدين ضبطته و عدلته كتابةً. يعني تقريبا كله from scratch :blush-anim-cl:
 
فاهم قصدك انا و شرحت ليك ليش ما سويت مثل ما قلت مع ان هو جا في بالي اقرا الرد عدل بتفهم. و لا السورس كود كله من عندي مافي الا الـ GUI سويته بالـ WindowBuilder و بعدين ضبطته و عدلته كتابةً. يعني تقريبا كله from scratch :blush-anim-cl:
أي أوكي. :rolleyes2:

انزين انا صار خاطري اتعلم جافا، تقدر تقترح لي كتاب؟
 
مافهمت شي

ويوم حاولت ان افهم بعد مافهمت p:




ويوم حاولت من جديد مرة ثانية افهم شتقول للأسف بعد مافهمت
على العموم يعطيك العافيه باروح قسمي البزنز :RpS_lol:



نفس الشي هههه

موفق خوك

عن إذنكم ، خلونا نصطف وياكم ! :RpS_lol:



+
وَيلاهه أنِي هربت من السي اس عقب برنامج الفيجول بيسك في المدرسة صرت ما أحب شي اسمه كودات ،
جان بيصير تخصصي! أحين أجوف هالأشياء المبهمة أقول الحمد لله أشوه شردت :eek:

+
لكن ما عليك منا ، :RpS_tongue: انته واجد زين وشاطر في التخصص وَممتاز فيه ، استمر على هالمنوال والله يوفقك .. :smile2:



​
 
أي أوكي. :rolleyes2:

انزين انا صار خاطري اتعلم جافا، تقدر تقترح لي كتاب؟

انا تعلمت مو من كتب, من النت و التجربة. انت طبعا تعرف سي بلس بلس ف ما بيكون عليك صعب. بس يبي ليك تجرب و تقرا الـ Documentation مال الـ Libraries. هالأيام أقرا كتب ساعات في الجامعة عن الملل بس معظمهم يعيدون نفس المواضيع اللي تقريبا أعرفها. إذا تبي كتاب لكن دور كتاب جديد مال ع الأقل Java 5. لا تروح قديم بعدين تنصم ان معظم الأشياء obsolete :smile2:
 





عن إذنكم ، خلونا نصطف وياكم ! :RpS_lol:



+
وَيلاهه أنِي هربت من السي اس عقب برنامج الفيجول بيسك في المدرسة صرت ما أحب شي اسمه كودات ،
جان بيصير تخصصي! أحين أجوف هالأشياء المبهمة أقول الحمد لله أشوه شردت :eek:

+
لكن ما عليك منا ، :RpS_tongue: انته واجد زين وشاطر في التخصص وَممتاز فيه ، استمر على هالمنوال والله يوفقك .. :smile2:



​

ترا لا تاخذين عليي انا وايد اعقد الأمور:RpS_lol:. الشغلة حليوة وايد ترا :rolleyes2:. بس كل واحد و ميوله بعد يعني ما اتخيل روحي ادرس دراستش أنا أحس بموت :mellow:. و شكرا ع الكلمات اللطيفة :blush-anim-cl:
 
عندي سؤال : قكرت تبرمج باستخدام Qt5 ؟
 
عندي سؤال : قكرت تبرمج باستخدام Qt5 ؟

ما كنت أعرف شنهو الـ Qt. الحين دورت شفته. أول مرة أسمع ابه, بس اللي فهمته أهو API حق الـ opengl.
جربت الـ opengl في الجافا كـ plugin و في السي بلس بلس شوي. فعندي فيه خبرة بسيطة يعني اقدر ارسم فيه بس و جدي. اتوقع أشياء كفاية حق أسوي GUI.
بعد ما أحب استخدم external libraries كلش :schmoll: مادري ليش. إذا فكرت استخدم شي جدي اتوقع بستخدم الأوبن جي ال العادي :smile2:
 
ما كنت أعرف شنهو الـ Qt. الحين دورت شفته. أول مرة أسمع ابه, بس اللي فهمته أهو API حق الـ opengl.
Qt تلفظ كيوت cute عبارة عن إطار عمل Framework يستخدم لبناء برامج رسومية باستخدام C++
يتضمن مكتبات للتعامل مع الوسائط المتعددة و مكتبات للتعامل مع OpenGL و OpenGL ES
ميزته أن تكتب نفس الشفرة البرمجية (الكود code) و تترجم لعدة منصات و أنظمة تشغيل
 
Qt تلفظ كيوت cute عبارة عن إطار عمل Framework يستخدم لبناء برامج رسومية باستخدام C++
يتضمن مكتبات للتعامل مع الوسائط المتعددة و مكتبات للتعامل مع OpenGL و OpenGL ES
ميزته أن تكتب نفس الشفرة البرمجية (الكود code) و تترجم لعدة منصات و أنظمة تشغيل

أحب عموما اتعامل أيا الـ native library. الحالة الوحيدة اللي استخدم فيها اكستيرنال أهي الـopengl لأن مافي مفر في الجافا :RpS_lol:
لكن اذا فكرت استخدم اكستيرنال بخلي اللي قلته في بالي. شكرا ع الأقتراح :smile:
 
انته شكلك داش التخصص خوك و انته تعرف تستخدم نص لغات البرمجة و م شاء الله يعني متطلع و من كلامك ينعرف شطور ,,
غير اذا واحد يدش التخصص و م يدري شنو بيدرس فيه مثلي,,
دشيت السي اس عبالي بيعلموني شنو داخل الكمبيوتر منهارد وير يعني,,
و م اوتعيت اللا التخصص يعلمنا لغات البرمجة و كذا,,
لكن عجبني التخصص واجد,,
الله جابني هني:rolleyes2:

ع العموم مبين علك شطور و موفق ي رب ,,:smile:
 
عودة
أعلى أسفل