Image with texture mask

Home Forums Monkey 2 Code Library Image with texture mask

This topic contains 9 replies, has 3 voices, and was last updated by  degac 4 weeks, 1 day ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #10298

    nerobot
    Participant

    Hi. Here is an example of using texture mask.

    We combine image with texture and get result – see sreenshot.

    This time you can create masked image, but can’t change mask on the fly (Image.Shader property is read-only).

    Worked by Image extension, added LoadMasked func.

    Sources: https://www.dropbox.com/s/v4q3mv7rkwy8aik/masked-image.zip?dl=0

    Attachments:
    #11246

    Anatol
    Participant

    Nice. This looks really useful! Thanks for sharing.

    #11248

    nerobot
    Participant

    Since Image.Shader property became writable, we can create Class MaskedImage extends Image with Property Mask:Image and change mask on-the-fly. 😉

    #11249

    Anatol
    Participant

    Oh, awesome! I was wondering about how to get around that limitation.

    #11261

    degac
    Participant

    Quick question

    I (surely) missed this piece of code

    It seems new to me!
    I mean, I know this

    but no the ‘Extension’ thing (seems quite clear what it does… but I would know better!)

    #11262

    nerobot
    Participant

     but no the ‘Extension’ thing (seems quite clear what it does… but I would know better!)

    Extensions are awesome part of language! 🙂

    It’s very useful to everybody learn it.

    You can open monkey2 folder as a project in Ted2Go and right-click on the root and choose Find..., then find by Extension keyword. And see what monkey2 already have.

    Class SomeClassName Extension is familiar for me, but I found something new:

    It looks like a magic. 🙂

    PS. I was surprised c# does not support operators overloading via extensions but monkey2 do that !

    #11264

    nerobot
    Participant

    There is an updated code for MaskedImage:

    Full code is here: https://www.dropbox.com/s/x7uvftczs7ie9pg/masked-image2.zip?dl=0

    Attachments:
    #11268

    degac
    Participant

    Ok, I’ve noticed in the source code the keyword Extension, and I could ‘translate’ it as a ‘bridge’ to other function/field/etc in external libraries.
    But in your first example – maybe I’m wrong – it seems to tell to compiler
    Class Image has ‘new’ function added now.. In this case LoadMasked().
    Is it the right interpretation?

    So, basically, instead to create/extend the base Class (in this case Image) (your last post) it will be possible to ‘extends’ the entire class with this keyword.
    It’s like to write something like Class Image Extends Image ?!?
    Handy!

    Quick question: you could use Class Image Extension many times or there’s a limit to use it ONCE, for all the ‘new features’?
    Honestly I looked (following your hint) at the Monkey2 code, but it seems that this keyword (maybe because is a recent feature?) is not used normally, excluded in the case to ‘use external library’ (ie: Json, Bullet etc)

    #11272

    nerobot
    Participant

    But in your first example – maybe I’m wrong – it seems to tell to compiler
    Class Image has ‘new’ function added now..

    Not quite. Extension members are translated into global functions but allow us to use ‘dot’ to get access to them.

    Quick question: you could use Class Image Extension many times or there’s a limit to use it ONCE, for all the ‘new features’?

    Many times, in different files.

    More info:

    http://monkeycoder.co.nz/forums/topic/possible-to-add-method-to-rect-with-extention/

    http://monkeycoder.co.nz/forums/topic/class-extensions/

    Let’s continue discussion in topics above. 🙂

    #11283

    degac
    Participant

    Thanks!
    September 2016 and I discovered just now!

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.