Beatmup
Beatmup::Scene::ShapedBitmapLayer Class Reference

Layer containing a bitmap and a parametric mask (shape) More...

#include <scene.h>

Inheritance diagram for Beatmup::Scene::ShapedBitmapLayer:
Beatmup::Scene::CustomMaskedBitmapLayer Beatmup::Scene::BitmapLayer Beatmup::Scene::Layer Beatmup::Object

Public Member Functions

float getBorderWidth () const
 
void setBorderWidth (float borderWidth)
 
float getSlopeWidth () const
 
void setSlopeWidth (float slopeWidth)
 
float getCornerRadius () const
 
void setCornerRadius (float cornerRadius)
 
bool getInPixels () const
 
void setInPixels (bool inPixels)
 
bool testPoint (float x, float y) const
 Tests if a given point falls in the layer. More...
 
- Public Member Functions inherited from Beatmup::Scene::CustomMaskedBitmapLayer
AffineMappinggetMaskMapping ()
 
const AffineMappinggetMaskMapping () const
 
void setMaskMapping (const AffineMapping &mapping)
 
color4i getBackgroundColor () const
 
void setBackgroundColor (color4i color)
 
- Public Member Functions inherited from Beatmup::Scene::BitmapLayer
const AbstractBitmapgetBitmap () const
 
void setBitmap (AbstractBitmap *bitmap)
 
AffineMappinggetBitmapMapping ()
 
const AffineMappinggetBitmapMapping () const
 
void setBitmapMapping (const AffineMapping &mapping)
 
color4i getModulationColor () const
 
void setModulationColor (color4i color)
 
- Public Member Functions inherited from Beatmup::Scene::Layer
Type getType () const
 
const std::string & getName () const
 
void setName (const char *name)
 
AffineMappinggetMapping ()
 
const AffineMappinggetMapping () const
 
void setMapping (const AffineMapping &mapping)
 
virtual LayergetChild (float x, float y, unsigned int recursionDepth=0) const
 Picks a child layer at given point, if any. More...
 
bool isVisible () const
 Returns layer visibility flag. More...
 
bool isPhantom () const
 Returns true if the layer is ignored when searching a layer by point. More...
 
void setVisible (bool visible)
 Sets layer visibility. More...
 
void setPhantom (bool phantom)
 Makes/unmakes the layer "phantom". More...
 
template<class LayerType >
LayerType & castTo () const
 
- Public Member Functions inherited from Beatmup::Object
virtual ~Object ()
 

Protected Member Functions

 ShapedBitmapLayer ()
 
void render (RenderingContext &context)
 
- Protected Member Functions inherited from Beatmup::Scene::CustomMaskedBitmapLayer
 CustomMaskedBitmapLayer (Type type)
 
void configure (RenderingContext &context, GL::TextureHandler *content)
 
- Protected Member Functions inherited from Beatmup::Scene::BitmapLayer
 BitmapLayer ()
 
 BitmapLayer (Type type)
 
GL::TextureHandlerresolveContent (RenderingContext &context)
 
void configure (RenderingContext &context, GL::TextureHandler *content)
 Configures current rendering program to render this layer. More...
 
- Protected Member Functions inherited from Beatmup::Scene::Layer
 Layer (Type type)
 

Private Attributes

float borderWidth
 constant border thickness More...
 
float slopeWidth
 thickness of the smoothed line between border and image More...
 
float cornerRadius
 border corner radius More...
 
bool inPixels
 if true, the widths and radius are set in pixels More...
 

Friends

class Scene
 
class SceneRenderer
 

Additional Inherited Members

- Public Types inherited from Beatmup::Scene::Layer
enum class  Type {
  SceneLayer = 0 , BitmapLayer , MaskedBitmapLayer , ShapedBitmapLayer ,
  ShadedBitmapLayer
}
 
- Protected Attributes inherited from Beatmup::Scene::CustomMaskedBitmapLayer
AffineMapping maskMapping
 mask mapping w.r.t. the layer mapping More...
 
color4i bgColor
 color to fill mask areas where the bitmap is not present More...
 
- Protected Attributes inherited from Beatmup::Scene::BitmapLayer
float invAr
 inverse aspect ratio of what is rendered (set by SceneRenderer) More...
 
AbstractBitmapbitmap
 content to display, used if the image source is set to BITMAP More...
 
AffineMapping bitmapMapping
 bitmap mapping w.r.t. the layer mapping More...
 
color4i modulation
 modulation color More...
 
- Protected Attributes inherited from Beatmup::Scene::Layer
AffineMapping mapping
 layer mapping More...
 
bool visible
 layer visibility More...
 
bool phantom
 if true, layer is ignored by selection by point More...
 

Detailed Description

Layer containing a bitmap and a parametric mask (shape)

Definition at line 235 of file scene.h.

Constructor & Destructor Documentation

◆ ShapedBitmapLayer()

Scene::ShapedBitmapLayer::ShapedBitmapLayer ( )
protected

Definition at line 393 of file scene.cpp.

393  :
395  borderWidth(0), slopeWidth(0), cornerRadius(0), inPixels(true)
396 {}
@ ShapedBitmapLayer
layer displaying a bitmap within a shape
float slopeWidth
thickness of the smoothed line between border and image
Definition: scene.h:240
bool inPixels
if true, the widths and radius are set in pixels
Definition: scene.h:242
float cornerRadius
border corner radius
Definition: scene.h:241
float borderWidth
constant border thickness
Definition: scene.h:239

Member Function Documentation

◆ render()

void Scene::ShapedBitmapLayer::render ( RenderingContext context)
protectedvirtual

Reimplemented from Beatmup::Scene::BitmapLayer.

Definition at line 399 of file scene.cpp.

399  {
401 
402  if (content) {
403  // program selection
404  switch (content->getTextureFormat()) {
405  case GL::TextureHandler::TextureFormat::OES_Ext:
407  break;
408  default:
410  break;
411  }
412 
414 
415  // computing border profile in pixels
416  AffineMapping arMaskMapping(maskMapping);
417  arMaskMapping.matrix.scale(1.0f, invAr);
418 
419  Matrix2 mat = context.getMapping().matrix * arMaskMapping.matrix;
420  mat.prescale(1.0f, context.getOutputResolution().getInvAspectRatio());
421 
422  const float scale = inPixels ? context.getOutputWidth() : 1;
423  const Point borderProfile(scale * mat.getScalingX(), scale * mat.getScalingY());
424  context.getProgram().setVector2("borderProfile", borderProfile.x, borderProfile.y);
425  context.getProgram().setFloat("cornerRadius", cornerRadius + borderWidth);
426  context.getProgram().setFloat("slope", slopeWidth);
427  context.getProgram().setFloat("border", borderWidth);
428 
429  context.blend();
430  }
431 }
2x3 affine mapping containing a 2x2 matrix and a 2D point
Definition: geometry.h:639
void setFloat(const std::string &name, const float value, bool safe=false)
Assigns a value to a specific floating point variable in the program.
Definition: program.cpp:347
void setVector2(const std::string &name, const float x, const float y)
Definition: program.cpp:362
@ SHAPED_BLEND_EXT
shaping an image (texture extension)
void blend()
Initiates the rendering operation.
const float getOutputWidth() const
const AffineMapping & getMapping() const
const ImageResolution & getOutputResolution() const
void enableProgram(GL::RenderingPrograms::Operation operation)
GL::TextureHandler * resolveContent(RenderingContext &context)
Definition: scene.cpp:273
float invAr
inverse aspect ratio of what is rendered (set by SceneRenderer)
Definition: scene.h:173
void configure(RenderingContext &context, GL::TextureHandler *content)
Definition: scene.cpp:326
AffineMapping maskMapping
mask mapping w.r.t. the layer mapping
Definition: scene.h:202
JNIEnv jlong jint jint jint jint jfloat scale
std::string content
* mat

◆ getBorderWidth()

float Beatmup::Scene::ShapedBitmapLayer::getBorderWidth ( ) const
inline

Definition at line 249 of file scene.h.

249 { return borderWidth; }

◆ setBorderWidth()

void Beatmup::Scene::ShapedBitmapLayer::setBorderWidth ( float  borderWidth)
inline

Definition at line 250 of file scene.h.

250 { this->borderWidth = borderWidth; }

◆ getSlopeWidth()

float Beatmup::Scene::ShapedBitmapLayer::getSlopeWidth ( ) const
inline

Definition at line 252 of file scene.h.

252 { return slopeWidth; }

◆ setSlopeWidth()

void Beatmup::Scene::ShapedBitmapLayer::setSlopeWidth ( float  slopeWidth)
inline

Definition at line 253 of file scene.h.

253 { this->slopeWidth = slopeWidth; }

◆ getCornerRadius()

float Beatmup::Scene::ShapedBitmapLayer::getCornerRadius ( ) const
inline

Definition at line 255 of file scene.h.

255 { return cornerRadius; }

◆ setCornerRadius()

void Beatmup::Scene::ShapedBitmapLayer::setCornerRadius ( float  cornerRadius)
inline

Definition at line 256 of file scene.h.

256 { this->cornerRadius = cornerRadius; }

◆ getInPixels()

bool Beatmup::Scene::ShapedBitmapLayer::getInPixels ( ) const
inline

Definition at line 258 of file scene.h.

258 { return inPixels; }

◆ setInPixels()

void Beatmup::Scene::ShapedBitmapLayer::setInPixels ( bool  inPixels)
inline

Definition at line 259 of file scene.h.

259 { this->inPixels = inPixels; }

◆ testPoint()

bool Scene::ShapedBitmapLayer::testPoint ( float  x,
float  y 
) const
virtual

Tests if a given point falls in the layer.

Reimplemented from Beatmup::Scene::BitmapLayer.

Definition at line 434 of file scene.cpp.

434  {
435  // no bitmap - no deal (if the source is set to bitmap)
436  if (!bitmap)
437  return false;
438  return (mapping * maskMapping).isPointInside(x, y, 1, invAr) && BitmapLayer::testPoint(x, y);
439 }
AbstractBitmap * bitmap
content to display, used if the image source is set to BITMAP
Definition: scene.h:174
bool testPoint(float x, float y) const
Tests if a given point falls in the layer.
Definition: scene.cpp:314
AffineMapping mapping
layer mapping
Definition: scene.h:80
jobject jlong jint jint y
jobject jlong jint x

Friends And Related Function Documentation

◆ Scene

friend class Scene
friend

Definition at line 236 of file scene.h.

◆ SceneRenderer

friend class SceneRenderer
friend

Definition at line 237 of file scene.h.

Member Data Documentation

◆ borderWidth

float Beatmup::Scene::ShapedBitmapLayer::borderWidth
private

constant border thickness

Definition at line 239 of file scene.h.

◆ slopeWidth

float Beatmup::Scene::ShapedBitmapLayer::slopeWidth
private

thickness of the smoothed line between border and image

Definition at line 240 of file scene.h.

◆ cornerRadius

float Beatmup::Scene::ShapedBitmapLayer::cornerRadius
private

border corner radius

Definition at line 241 of file scene.h.

◆ inPixels

bool Beatmup::Scene::ShapedBitmapLayer::inPixels
private

if true, the widths and radius are set in pixels

Definition at line 242 of file scene.h.


The documentation for this class was generated from the following files: