Examples of Vector4


Examples of engine.base.Vector4

    return this;
  }
 
 
  public ColorGradient addEntryRGB(float r, float g, float b, float pos) {
    return addEntry(new Vector4(r, g, b, 1.0f), pos);
  }
View Full Code Here

Examples of engine.base.Vector4

  public void setFrom(ColorGradient g) {
    if (g == null) return;
    if (g.getNumEntries() <= 1) return;
    clear();
    for (int i = 0; i < g.getNumEntries(); i++) {
      addEntry(new Vector4(g.getEntryColor(i)), g.getEntryPosition(i));
    }
  }
View Full Code Here

Examples of engine.base.Vector4

    }
  }
 
 
  public Vector4 getColor(float pos) {
    Vector4 ret = new Vector4();
   
    if (pos <= entries.firstElement().position) ret.set(entries.firstElement().color);
    else if (pos >= entries.lastElement().position) ret.set(entries.lastElement().color);
    else {
      for (int i = 0; i < entries.size()-1; i++) {
        if (entries.get(i+1).position > pos) {
          Entry a = entries.get(i);
          Entry b = entries.get(i+1);
         
          float interp = (pos-a.position)/(b.position-a.position);
          //ret.set(interp);
          ret.set(a.color);
          ret.mult_ip(1.0f - interp);
          ret.mult_add_ip(interp, b.color);
          break;
        }
      }
    }
   
View Full Code Here

Examples of engine.base.Vector4

 
  private ColorGradientParam(String name) {
    this.name = name;
    m_Gradient = new ColorGradient();
    // default grayscale gradient
    m_Gradient.addEntry(new Vector4(0.0f, 0.0f, 0.0f, 1.0f), 0.0f);
    m_Gradient.addEntry(new Vector4(1.0f, 1.0f, 1.0f, 1.0f), 1.0f);
  }
View Full Code Here

Examples of engine.base.Vector4

 
  // saves only the value
  public void save(Writer w) throws IOException  {
    w.write(m_Gradient.getNumEntries() + " ");
    for (int i = 0; i < m_Gradient.getNumEntries(); i++) {
      Vector4 v = m_Gradient.getEntryColor(i);
      w.write(v.x+" "+v.y+" "+v.z+" "+v.w+" ");
      w.write(m_Gradient.getEntryPosition(i) + " ");
    }
  }
View Full Code Here

Examples of engine.base.Vector4

    m_Gradient.clear();
    int num = s.nextInt();
    for (int i = 0; i < num; i++) {
      // !!TODO: this is a workaround for a weirded windows s.nextFloat bug;
      //m_Gradient.addEntry(new Vector4(s.nextFloat(), s.nextFloat(), s.nextFloat(), s.nextFloat()), s.nextFloat());
      m_Gradient.addEntry(new Vector4(Float.parseFloat(s.next()),Float.parseFloat(s.next()),Float.parseFloat(s.next()),Float.parseFloat(s.next())),Float.parseFloat(s.next()));
    }
    notifyParamChangeListener();
  }
View Full Code Here

Examples of engine.base.Vector4

          progress.setProgress(y / (float) img.getHeight());
        for (int x = 0; x < img.getWidth(); x++) {
          float u = (float) (x + px * img.getWidth()) / (float) globalXres;
          float v = (float) (y + py * img.getHeight()) / (float) globalYres;

          final Vector4 col;
          if (tce == null) col = c.valueRGBA(u, v);
          else col = tce.sample(x, y);
         
          final Vector3 color = new Vector3();
          int val;
          // !!UGH TODO: optimize this!!
          if (mode == 0) {
            color.set(col.getVector3());
            val = Utils.vector3ToINTColor(color);
          } else if (mode == 1) {
            float bg = ((((x + y) / 8) % 2) != 0) ? 1.0f : 0.75f;
            col.x = col.x * col.w + bg * (1.0f - col.w);
            col.y = col.y * col.w + bg * (1.0f - col.w);
            col.z = col.z * col.w + bg * (1.0f - col.w);
            color.set(col.getVector3());
            val = Utils.vector3ToINTColor(color);
          } else if (mode == 2) {
            color.set(col.w);
            val = Utils.vector3ToINTColor(color);
          } else if (mode == 3) {
            color.set(col.getVector3());
            val = Utils.vector4ToINTColor_ARGB(col);
          } else {
            Logger.logError(null, "Wrong in computeImage");
            val = Utils.vector3ToINTColor(color);
          }
View Full Code Here

Examples of engine.base.Vector4

    if (img == null)
      img = new BufferedImage(xres, yres, BufferedImage.TYPE_INT_RGB);
    for (int y = 0; y < img.getHeight(); y++) {
      for (int x = 0; x < img.getWidth(); x++) {
        float pos = (float) x / (float) img.getWidth();
        Vector4 col = grad.getColor(pos);
        float bg = ((((x + y) / 8) % 2) != 0) ? 1.0f : 0.75f;
        col.x = col.x * col.w + bg * (1.0f - col.w);
        col.y = col.y * col.w + bg * (1.0f - col.w);
        col.z = col.z * col.w + bg * (1.0f - col.w);
        img.setRGB(x, y, Utils.floatRGBToINTColor(col.x, col.y, col.z));
View Full Code Here

Examples of engine.base.Vector4

  public void refreshGradientImage() {
    for (int y = 0; y < gradientImage.getHeight(); y++) {
      for (int x = 0; x < gradientImage.getWidth(); x++) {
        float pos = (float) x / (float) gradientImage.getWidth();

        Vector4 col = m_ActiveGradient.getColor(pos);

        if (y < 8) { // convert to grayscale preview
          float c = (col.x + col.y + col.z) * (1.0f / 3.0f);
          col.x = col.y = col.z = c;
        } else { // if (y < 16) { // color with alpha preview
View Full Code Here

Examples of engine.base.Vector4

    } else if (command.equals("Random")) {
      ms_Presets.get(0).updateGradient(m_ActiveGradient); // remember the old one at the first position
      m_ActiveGradient.clear();
      int num = 4;
      for (int i = 0; i < num; i++) {
        m_ActiveGradient.addEntry(new Vector4(FMath.random(), FMath.random(), FMath.random(), 1.0f), i/(float)(num-1));
      }
      setColorGradient(m_ActiveGradient);
    } else if (command.equals("Darken All")) {
      for (int i = 0; i < m_ActiveGradient.getNumEntries(); i++) {
        m_ActiveGradient.getEntryColor(i).multComp_ip(0.8f,0.8f,0.8f,1.0f);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.