BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: Question for method BLENDING  (Read 40 times)

Prog_11

  • Newbie
  • *
  • Posts: 2
    • View Profile
Question for method BLENDING
« on: December 03, 2019, 10:46:37 AM »

Hello,

I use the EVE Screen Editor v3.1.2 with a FT801 device, and I can not solve the following problem:
I want to paint an image on the screen, which has basically two "layers". On the first, rear (in the background) layer there should be a gradient. On the second, front Layer I want to paint a half transparent (alpha = 128) white surface so that the gradient shines through that surface. That surface should be interrupted by a wide contour of a circle, so that you see the rear layer with the gradient along that contour. All edges should be painted with antialias.
I have tried so many solving approaches and combinations of the standard commands like CLEAR, CMD_GRADIENT, COLOR_MASK, COLOR_A, ALPHA_FUNC, VERTEX2II, ... but dont get it.

Who can help me???


Logged

BRT Community

  • Administrator
  • Full Member
  • *****
  • Posts: 113
    • View Profile
Re: Question for method BLENDING
« Reply #1 on: December 03, 2019, 02:09:50 PM »

Hello,

You may find this book of graphics techniques to be useful. This module uses an EVE device and so the same co-processor commands as all our examples, just via a different library.
http://excamera.com/files/gd2book_v0.pdf

I believe the following scissor, stencil and alpha examples should get you on your way to creating the image you desire.


For scissors, the idea is to define an area of the screen which will be updated. You define the top-left coordinate (xy) of a virtual box and then the size in x and y of the box, thereby defining an area of the screen. When you perform a graphics operation, only the area of the screen in the box is affected. To go back to adding items over the full screen, you set the scissor xy back to (0,0) and scissor size to be the full screen. Below, the red rectangle (as dimensioned by the two cursors shown) only paints within a 100x100 box which has coordinate (100,100) at the top left due to the scissors.

** see scissors.png **
 
Code: [Select]
CLEAR_COLOR_RGB(128, 255, 158)
CLEAR(1, 1, 1)
SCISSOR_XY(100, 100)
SCISSOR_SIZE(100, 100)
COLOR_RGB(255, 0, 0)
BEGIN(RECTS)
VERTEX2II(64, 50, 0, 0)
VERTEX2II(365, 203, 0, 0)
END()


For Stencil, we use three steps below to draw the polygon. There are many ways to do this and one may be more efficient for a particular situation but here is the general principle:

 ** see stencil.png **

First, we use a stencil operation to define how the stencil buffer is affected by writes to the screen. By setting it to INCR, INCR, then each time we place an item, the stencil buffer is incremented for each pixel drawn. We mask off the colours so that nothing is visible and then draw the shapes, taking care that they overlap such that the pixels we want for the final shape are incremented twice. The first pair of vertices draw the left image and the second pair draw the right image. The desired area is therefore only drawn over once. All other parts of the screen are either not touched or drawn twice.
 
Code: [Select]
CLEAR(1, 1, 1)
COLOR_RGB(255, 0, 0)
STENCIL_OP(INCR,INCR)
COLOR_MASK(0,0,0,0) //mask all the colors
BEGIN(EDGE_STRIP_L)
VERTEX2II(300,100,0,0)
VERTEX2II(200,200,0,0)
VERTEX2II(400,200,0,0)
VERTEX2II(300,100,0,0)
END()

Then we re-enable the colours and draw another edge strip. The stencil func causes only areas with 1 in the stencil buffer to be rendered.

Code: [Select]
COLOR_MASK(1,1,1,1) //enable all the colors
STENCIL_FUNC(EQUAL,1,255)
BEGIN(EDGE_STRIP_L)
VERTEX2II(480,0)
VERTEX2II(480,272)
END()

Finally, we can draw an outline using a line strip. The stencil is set back to ‘always draw’ so that we can draw anywhere on the screen.

Code: [Select]
STENCIL_FUNC(ALWAYS,0,255)
LINE_WIDTH(16)
COLOR_RGB(255, 255, 255)
BEGIN(LINE_STRIP)
VERTEX2II(300,100,0,0)
VERTEX2II(200,200,0,0)
VERTEX2II(400,200,0,0)
VERTEX2II(300,100,0,0)
VERTEX2II(300,100,0,0)
END()
DISPLAY()


The Alpha value will specify the transparency of an item drawn on the screen. If the alpha value was set to 255 before an item is drawn, the item will be drawn as a solid colour. If the alpha is reduced toward 0, the item will become more transparent and any items underneath will be visible.

** see alpha.png **

Code: [Select]
CLEAR_COLOR_RGB(0, 0, 0)
CLEAR(1, 1, 1)
POINT_SIZE(1600)
BEGIN(POINTS)

COLOR_RGB(255, 0, 0)
COLOR_A(255)
VERTEX2II(120, 146, 0, 0)

COLOR_RGB(0, 255, 0)
COLOR_A(128)
VERTEX2II(256, 153, 0, 0)

COLOR_RGB(0, 0, 255)
COLOR_A(128)
VERTEX2II(186, 104, 0, 0)

END()

Best Regards,
BRT Community
Logged

Prog_11

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Question for method BLENDING
« Reply #2 on: December 03, 2019, 02:36:13 PM »

Hi,

thank you for your answer. But unfortunately it doesn't help me. The gf2book (The Gameduino 2) I already know very well, but it doesn't help me, too. I already programmed complex blending operations, but this problem which I described does not want to be solved... scissor and stencil are not helpful in my case.
I would be very grateful for a principal code for the problem.

In the attachments you can see a screenshot of my principal purpose. But as you can see
- there are alias effects,
- the gradient in the inner circle is not the same like outside the circle
Logged