Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

40
LINES

< > BotCompany Repo | #660 // vsplit v1

JavaX source code - run with: x30.jar

!636

!629 // standard functions
!658 // image classes

import java.awt.*;
import java.awt.image.*;
import java.util.List;

public class main {
  public static void main(String[] args) {
    JFrame frame = new JFrame("A JavaX Frame");
    
    RGBImage image = new RGBImage(100, 100, Color.white);
    double splitPoint = random();
    RGB col1 = new RGB(Color.green), col2 = new RGB(Color.blue);
    vsplit(image, splitPoint, col1, col2);
    ImageSurface panel = new ImageSurface(image);
    
    frame.add(panel);
    frame.setBounds(100, 100, 500, 400);
    frame.setVisible(true);
    exitOnFrameClose(frame);
  }
  
  static Random _random = new Random();
  static double random() {
    return _random.nextInt(50001)/50000.0;
  }
  
  static void vsplit(RGBImage img, double splitPoint, RGB col1, RGB col2) {
    int w = img.getWidth(), h = img.getHeight();
    for (int yy = 0; yy < h; yy++)
      for (int xx = 0; xx < w; xx++) {
        double x = ((double) xx)/(w-1);
        double y = ((double) yy)/(h-1);
        RGB col = y <= splitPoint ? col1 : col2;
        img.setPixel(xx, yy, col);
      }
  }
}

Author comment

Began life as a copy of #659

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, qbtsjoyahagl, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
889 #1000604 (pitcher) 2015-08-20 15:28:24
888 #1000610 (pitcher) 2015-08-18 00:07:07

add comment

Snippet ID: #660
Snippet name: vsplit v1
Eternal ID of this version: #660/1
Text MD5: e594f21134cc57e5d35c1692987e1d15
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-07-13 04:49:44
Source code size: 1155 bytes / 40 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 1028 / 929
Referenced in: [show references]