Back to Projects <

Projects >

Explore Pixodrip

Project 1

Pixodrip is an art application created using Java that lets users draw on a bitmap canvas using a powerful brush, with the abilities to manipulate the hue, saturation, and brightness of the pixels in its radius.

Skills Used

  • Java
  • Java project management
  • JFrame
  • File saving
  • Converting to JAR

Features

  • Size adjustable brush
  • Starting color and tilesize customization
  • Save canvas and load canvas locally

Code Side-by-side


Feature

Tile Scalability

Frontend

When you start to create a brand new canvas, pixodrip allows you to control the size of each pixel. This can create different feelings as a smaller tilesize can achieve finer blends while a larger tilesize creates abstract canvases.

Code snippet

  public class SetNewPanel extends JPanel {
    final int width = 800;
    final int height = 600;
    Color bgColor = new Color(04, 04, 04);
    boolean tileSizeClicked;
    boolean newCanvasClicked;
    boolean baseHClicked;
    boolean backButtonClicked;

    public SetNewPanel(){
        // Set up panel and boolean variables to check for buttons
        this.setPreferredSize(new Dimension(width, height));
        this.setBackground(bgColor);
        this.setDoubleBuffered(true);
        this.setFocusable(true);
        tileSizeClicked = false;
        newCanvasClicked = false;
        baseHClicked = false; 
        backButtonClicked = false;  
        // Set layout to null so that buttons can be placed at specific locations
        this.setLayout(null);

        // Create buttons
        ImageIcon tileSizeIcon = new ImageIcon("src/Main/Assets/tileSizeButton.png");      
        JButton tileSizeButton = new JButton(tileSizeIcon);
        tileSizeButton.setBounds(250 - tileSizeIcon.getIconWidth()/2, 250, tileSizeIcon.getIconWidth(), tileSizeIcon.getIconHeight());
        tileSizeButton.setContentAreaFilled(false);
        tileSizeButton.setBorderPainted(false);
        tileSizeButton.setFocusPainted(false);

        ImageIcon baseHIcon = new ImageIcon("src/Main/Assets/baseHButton.png");      
        JButton baseHButton = new JButton(baseHIcon);
        baseHButton.setBounds(550 - baseHIcon.getIconWidth()/2, 250, baseHIcon.getIconWidth(), baseHIcon.getIconHeight());
        baseHButton.setContentAreaFilled(false);
        baseHButton.setBorderPainted(false);
        baseHButton.setFocusPainted(false);
        
        ImageIcon createCanvasIcon = new ImageIcon("src/Main/Assets/CreateCanvasButton.png");
        JButton createCanvasButton = new JButton(createCanvasIcon);
        createCanvasButton.setBounds(680 - createCanvasIcon.getIconWidth()/2, 520, createCanvasIcon.getIconWidth(), createCanvasIcon.getIconHeight());
        createCanvasButton.setContentAreaFilled(false);
        createCanvasButton.setBorderPainted(false);
        
        ImageIcon backIcon = new ImageIcon("src/Main/Assets/backButton.png");
        JButton backButton = new JButton(backIcon);
        backButton.setBounds(150 - backIcon.getIconWidth()/2, 520, backIcon.getIconWidth(), backIcon.getIconHeight());
        backButton.setContentAreaFilled(false);
        backButton.setBorderPainted(false);

        // Add action listeners to buttons
        tileSizeButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                tileSizeClicked = true;
            }
        });
        
        baseHButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                baseHClicked = true;
            }
        });
        
        createCanvasButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                newCanvasClicked = true;
            }
        });
        
        backButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                backButtonClicked = true;
            }
        });
        
        // Add mouse animations to buttons
        createCanvasButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                createCanvasButton.setBounds(680 - createCanvasIcon.getIconWidth()/2, 520, createCanvasIcon.getIconWidth() + 20, createCanvasIcon.getIconHeight());
            }
        
            public void mouseExited(java.awt.event.MouseEvent evt) {
                createCanvasButton.setBounds(680 - createCanvasIcon.getIconWidth()/2, 520, createCanvasIcon.getIconWidth(), createCanvasIcon.getIconHeight());
            }
        });
        
        baseHButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                baseHButton.setBounds(550 - baseHIcon.getIconWidth()/2, 250, baseHIcon.getIconWidth() + 5, baseHIcon.getIconHeight() + 5);
            }
        
            public void mouseExited(java.awt.event.MouseEvent evt) {
                baseHButton.setBounds(550 - baseHIcon.getIconWidth()/2, 250, baseHIcon.getIconWidth(), baseHIcon.getIconHeight());
            }
        });
        
        tileSizeButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                tileSizeButton.setBounds(250 - tileSizeIcon.getIconWidth()/2, 250, tileSizeIcon.getIconWidth() + 5, tileSizeIcon.getIconHeight() + 5);
            }
        
            public void mouseExited(java.awt.event.MouseEvent evt) {
                tileSizeButton.setBounds(250 - tileSizeIcon.getIconWidth()/2, 250, tileSizeIcon.getIconWidth(), tileSizeIcon.getIconHeight());
            }
        });
        
        backButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                backButton.setBounds(150 - backIcon.getIconWidth()/2, 520, backIcon.getIconWidth() + 20, backIcon.getIconHeight());
            }
        
            public void mouseExited(java.awt.event.MouseEvent evt) {
                backButton.setBounds(150 - backIcon.getIconWidth()/2, 520, backIcon.getIconWidth(), backIcon.getIconHeight());
            }
        });
    }
}
                    

Feature

Save canvases

Frontend

Because Pixodrip runs locally, it has the ability to save your drawings locally. You can also edit your canvases and save them under the same file location.

Code snippet

  if (savePanel.getSaveClicked() == true){
      
    currentGrid.setName(savePanel.getGridName());
    //save the grid
    if (saveIndex == -1){
        gridList.addGrid(currentGrid);
    } else {
        gridList.replaceGrid(saveIndex, currentGrid);
    }
    try {
        FileOutputStream fileOut = new FileOutputStream("data/gridData.ser");
        ObjectOutputStream out = new ObjectOutputStream(fileOut);
        out.writeObject(gridList);
        out.close();
        fileOut.close();
    } catch (IOException i) {
        i.printStackTrace();
    }  
    
    
    savePanel.resetSaveClicked();
    savePanel.resetBackClicked();
    break;
}
                  

Feature

Brush capabilities

Frontend

There are five options for brushes. Hue wheel, add saturation, remove saturation, add brightness, and remove brightness. The brush radius can also be increased and decreased.

Code snippet

                    
//change the hsb values of the tile that the mouse is on
if (mouseHandler.isPressed){
    for (Coordinate coord: area.getArea()){
        if (coord.checkBounds()){
            int gridx = coord.getX()/tileSize;
            int gridy = coord.getY()/tileSize;
            if (SettingsPanel.brushID == 0){
                grid.getGrid()[gridy][gridx].changeH(0.005f);
            }
            if (SettingsPanel.brushID == 1){
                grid.getGrid()[gridy][gridx].changeS(0.005f);
            }
            if (SettingsPanel.brushID == 2){
                grid.getGrid()[gridy][gridx].changeS(-0.005f);
            }
            if (SettingsPanel.brushID == 3){
                grid.getGrid()[gridy][gridx].changeB(0.005f);
            }
            if (SettingsPanel.brushID == 4){
                grid.getGrid()[gridy][gridx].changeB(-0.005f);
            }
        }
    }                                    
}
                  

You made it to the end! Check out the full project here:

View project code on Github >

OR Take me to another project:

Back to Projects <

Contact

Email

joshualo1247220@gmail.com

Instagram

@joshuajjlo