none
Transparent Shapes RRS feed

  • Question

  • Is there any way to do a transparent shape?  I'm thinking of a game that you could see the shape but you could also see the background behind the shape.  So, when the shape moves you can see through it and see the background as the shape moves through it.

    JR
    Monday, April 20, 2009 1:50 PM
    Answerer

Answers

  • I think JRiceStk want RGBA colors, not really fully transparent shapes. In fact it's currently not possible.
    Maybe you can modify the "GetColorFromString" method to support a format like #RrGgBbAa in addition to the normal #RrGgBb ?

    And then, you will need to add a method to create such a string with the R,G,B and A parameters...
    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
    Found the solution by anaysing the code in Reflector :
    GraphicsWindow.BrushColor="#aa334455" ' aa in [00>ff] = transparency (00 = non-visibile; ff = visible)

    ' The overlapped zone will be darker than the two non-overlapped zone
    GraphicsWindow.FillRectangle(0,0,10,25)
    GraphicsWindow.FillRectangle(0,10,10,25)
    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
    Monday, April 20, 2009 5:22 PM

All replies

  • You can use "Transparent" as your background color to get the see-through effect.

    Sample program published as: FSN657
    Monday, April 20, 2009 3:49 PM
    Moderator
  • I think JRiceStk want RGBA colors, not really fully transparent shapes. In fact it's currently not possible.
    Maybe you can modify the "GetColorFromString" method to support a format like #RrGgBbAa in addition to the normal #RrGgBb ?

    And then, you will need to add a method to create such a string with the R,G,B and A parameters...
    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
    Monday, April 20, 2009 4:14 PM
  • I think JRiceStk want RGBA colors, not really fully transparent shapes. In fact it's currently not possible.
    Maybe you can modify the "GetColorFromString" method to support a format like #RrGgBbAa in addition to the normal #RrGgBb ?

    And then, you will need to add a method to create such a string with the R,G,B and A parameters...
    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
    Found the solution by anaysing the code in Reflector :
    GraphicsWindow.BrushColor="#aa334455" ' aa in [00>ff] = transparency (00 = non-visibile; ff = visible)

    ' The overlapped zone will be darker than the two non-overlapped zone
    GraphicsWindow.FillRectangle(0,0,10,25)
    GraphicsWindow.FillRectangle(0,10,10,25)
    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
    Monday, April 20, 2009 5:22 PM
  • FremyCompany and Vijaye,

    Thanks for both of your answers.  I think FremyCompany's answer will do what I want it to do.  Look's like he was able to find a feature that isn't documented.  At least I hadn't seen it in any of the documentation before.

    Thanks,

    JR

    Monday, April 20, 2009 6:07 PM
    Answerer
  • It's in fact undocumented. I think that even SmallBasic's developers ignored it was possible. I needed to decompile some hidden Microsoft's namespace in the PresentationCore assembly to find the revelant part of code (they are a lot of wrappage between Small Basic and the "MS.Internal.Parsers.ParseHexColor(trimmedColor As String) As Color" method).

    But if it works, it's the principal, no ?
    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
    Monday, April 20, 2009 6:48 PM
  • It's the principal, YES!

    Thanks again, and by the way thank you for all of the work that you have did on your extension and the help
    documentation that you have put together for it and small basic itself.  It's really great, and you have did an
    outstanding job!

    JR
    Monday, April 20, 2009 11:48 PM
    Answerer