• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Alpha in Sketcup::Color

Scheduled Pinned Locked Moved Developers' Forum
6 Posts 5 Posters 589 Views 5 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    Al Hart
    last edited by 19 Sept 2010, 23:09

    One of the things that messed up our ruby script in SketchUp 8.0 was the addition alpha to the class Sketchup::Color.

    Try this line in the ruby console:

    printf("%#x\n", Sketchup::Color.new('white'))

    in SU 7 it displays: 0xffffff

    in SU 8 it displays: 0xffffffff

    We fixed our applications, but does anyone know anything good that the new alpha channel is used for?

    Al Hart

    http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
    IRender nXt from Render Plus

    1 Reply Last reply Reply Quote 0
    • A Offline
      Al Hart
      last edited by 19 Sept 2010, 23:12

      I see the documentation says:

      @unknownuser said:

      NOTE: Assigning an alpha does not actually work.

      color = Sketchup::Color.new "AliceBlue"
      alpha = color.alpha = 255

      Al Hart

      http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
      IRender nXt from Render Plus

      1 Reply Last reply Reply Quote 0
      • H Offline
        honoluludesktop
        last edited by 20 Sept 2010, 02:49

        This , or not?

        1 Reply Last reply Reply Quote 0
        • C Offline
          Chris Fullmer
          last edited by 20 Sept 2010, 03:44

          My guess was that it is transparency, like you can control the transparency of a material inside of SketchUp in the materials browser. Maybe they finally made it work via Ruby?

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • T Offline
            thomthom
            last edited by 20 Sept 2010, 08:46

            It's a mysterious property - as you have to use material.alpha to set a material's transparency. I never got any explanation to the alpha property of Color - I did request it could be made use of for when you draw on to the viewport with the GL methods, but still not seen anything of it.

            It is odd that they made some changes in SU8 in regard to this property - would be interesting to know why. Because the release notes doesn't say nothing.

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • T Offline
              TIG Moderator
              last edited by 20 Sept 2010, 10:26

              The 'draw' colors are OpenGL standard colors only and seem unconnected to the model.materials - so transparency is not available to them anyway. I think that making the color 'red' say [0,0,0] in the model doesn't affect the color 'red' used in the 'draw' methods.

              A 'color' has always has an 'alpha' value [but it was never used!].
              I think that the 'A' transparency in color [R,G,B,A] is a hangover from a much earlier SUp version where it was planned that you applied a 'color' to a face - so you would then need aplha 'A' for its transparency... BUT when 'materials' [allowing texture-images etc] were introduced they contained the transparency property and thereafter the 'color' only needed to be in RGB. So if you add a value for alpha 'A' to a color it is just ignored in its rendering but remembered in its values: but if you add no value it defaults to 255.
              The API notes say, "color.alpha=i - NOTE: Though documented historically in the Ruby API, this method has never been implemented."

              Here's the rub...

              v7.
              Sketchup::Color.new('white')
              Color(255, 255, 255, 255)
              printf("%#x\n", Sketchup::Color.new('white'))
              0xffffff
              Sketchup::Color.new('white').to_a
              [255, 255, 255, 255]
              Sketchup::Color.new('white')**.to_i**
              16777215 <<<<<<<<<<<<<<<<<<<<< NOTE
              Sketchup::Color.new(255, 255, 255)
              Color(255, 255, 255, 255)
              Sketchup::Color.new(255, 255, 255, 255)
              Color(255, 255, 255, 255)
              Sketchup::Color.new(255, 255, 255, 123)
              Color(255, 255, 255, 123)
              printf("%#x\n", **16777215**) <<<<<<<<<<<<<<<<<<<<< NOTE
              0xffffff
              printf("%#x\n", Sketchup::Color.new(255, 255, 255)) <<<<<<<<<<< NOTE
              0xffffff
              printf("%#x\n", Sketchup::Color.new(255, 255, 255, 255))
              0xffffff
              printf("%#x\n", Sketchup::Color.new(255, 255, 255, **123**))
              0xffffff
              Sketchup::Color.new(255, 255, 255, 123).to_i
              16777215 <<<<<<<<<<<<<<<<<<<<< NOTE

              [the unused alpha is ignored in the i/hex value]

              v8.
              Sketchup::Color.new('white')
              Color(255, 255, 255, 255)
              printf("%#x\n", Sketchup::Color.new('white'))
              0xffffffff
              Sketchup::Color.new('white').to_a
              [255, 255, 255, 255]
              Sketchup::Color.new('white')**.to_i**
              4294967295 <<<<<<<<<<<<<<<<<<<<< NOTE
              Sketchup::Color.new(255, 255, 255)
              Color(255, 255, 255, 255)
              Sketchup::Color.new(255, 255, 255, 123)
              Color(255, 255, 255, 123)
              printf("%#x\n", **4294967295**) <<<<<<<<<<<<<<<<<<<<< NOTE
              0xffffffff
              printf("%#x\n", Sketchup::Color.new(255, 255, 255)) <<<<<<<<<< NOTE
              0xffffffff
              printf("%#x\n", Sketchup::Color.new(255, 255, 255, 255))
              0xffffffff
              printf("%#x\n", Sketchup::Color.new(255, 255, 255, **123**))
              0xffffffff
              Sketchup::Color.new(255, 255, 255, 123).to_i
              4294967295 <<<<<<<<<<<<<<<<<<<<< NOTE

              [AGAIN the unused alpha is ignored in the i/hex value]

              The 'integer value' of the color is being returned as a different value between v7 and v8 BUT the alpha is actually ignored in BOTH versions - so the alpha issue is therefore a red-herring.

              In v8 it is now a Bignum so face.material=0xffffffff fails - whereas in v7 it's a [ruby:3hoxppyu]Fixnum[/ruby:3hoxppyu] so [ruby:3hoxppyu]face.material=0xffffff[/ruby:3hoxppyu] works !

              Somebody broke 'Color'...

              I'll lodge a v8 bug-report... 😒

              TIG

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              1 / 1
              • First post
                1/6
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement