13 #include <emscripten/val.h> 14 #include <emscripten/bind.h> 23 BEGIN_IGRAPHICS_NAMESPACE
26 std::string CanvasColor(
const IColor& color,
float alpha = 1.0);
42 void DrawBitmap(
const IBitmap& bitmap,
const IRECT& bounds,
int srcX,
int srcY,
const IBlend* pBlend)
override;
46 void PathClear()
override;
47 void PathClose()
override;
48 void PathArc(
float cx,
float cy,
float r,
float a1,
float a2, EWinding winding)
override;
49 void PathMoveTo(
float x,
float y)
override;
50 void PathLineTo(
float x,
float y)
override;
51 void PathCubicBezierTo(
float c1x,
float c1y,
float c2x,
float c2y,
float x2,
float y2)
override;
52 void PathQuadraticBezierTo(
float cx,
float cy,
float x2,
float y2)
override;
59 bool BitmapExtSupported(
const char* ext)
override;
62 APIBitmap* LoadAPIBitmap(
const char* fileNameOrResID,
int scale, EResourceLocation location,
const char* ext)
override;
63 APIBitmap* LoadAPIBitmap(
const char* name,
const void* pData,
int dataSize,
int scale)
override;
64 APIBitmap* CreateAPIBitmap(
int width,
int height,
int scale,
double drawScale,
bool cacheable =
false)
override;
66 bool LoadAPIFont(
const char* fontID,
const PlatformFontPtr& font)
override;
68 bool AssetsLoaded()
override;
73 void GetLayerBitmapData(
const ILayerPtr& layer, RawBitmapData& data)
override;
74 void ApplyShadowMask(
ILayerPtr& layer, RawBitmapData& mask,
const IShadow& shadow)
override;
76 float DoMeasureText(
const IText& text,
const char* str,
IRECT& bounds)
const override;
77 void DoDrawText(
const IText& text,
const char* str,
const IRECT& bounds,
const IBlend* pBlend)
override;
80 void PrepareAndMeasureText(
const IText& text,
const char* str,
IRECT& r,
double& x,
double & y)
const;
82 val GetContext()
const 84 val canvas = mLayers.empty() ? val::global(
"document").call<val>(
"getElementById", std::string(
"canvas")) : *(mLayers.top()->GetAPIBitmap()->GetBitmap());
86 return canvas.call<val>(
"getContext", std::string(
"2d"));
89 void GetFontMetrics(
const char* font,
const char* style,
double& ascenderRatio,
double& EMRatio);
90 bool CompareFontMetrics(
const char* style,
const char* font1,
const char* font2);
91 bool FontExists(
const char* font,
const char* style);
93 double XTranslate() {
return mLayers.empty() ? 0 : -mLayers.top()->Bounds().L; }
94 double YTranslate() {
return mLayers.empty() ? 0 : -mLayers.top()->Bounds().T; }
96 void PathTransformSetMatrix(
const IMatrix& m)
override;
97 void SetClipRegion(
const IRECT& r)
override;
99 void SetCanvasSourcePattern(val& context,
const IPattern& pattern,
const IBlend* pBlend =
nullptr);
100 void SetCanvasBlendMode(val& context,
const IBlend* pBlend);
102 std::vector<val> mLoadingFonts;
104 static StaticStorage<Font> sFontCache;
108 END_IGRAPHICS_NAMESPACE
IColor GetPoint(int x, int y) override
Get the color at an X, Y location in the graphics context.
Used to manage a rectangular area, independent of draw class/platform.
Used to manage composite/blend operations, independent of draw class/platform.
User-facing bitmap abstraction that you use to manage bitmap data, independant of draw class/platform...
Used to manage fill behaviour for path based drawing back ends.
int AlphaChannel() const override
Used to manage color data, independent of draw class/platform.
Used to manage stroke behaviour for path based drawing back ends.
The lowest level base class of an IGraphics context.
An editor delegate base class for a SOMETHING that uses IGraphics for it's UI.
IText is used to manage font and text/text entry style for a piece of text on the UI...
The lowest level base class of an IGraphics context.
Used to specify properties of a drop-shadow to a layer.
bool FlippedBitmap() const override
const char * GetDrawingAPIStr() override
void * GetDrawContext() override
Gets a void pointer to underlying drawing context, for the IGraphics backend See draw class implement...
A base class interface for a bitmap abstraction around the different drawing back end bitmap represen...
IGraphics draw class HTML5 canvas.
std::unique_ptr< ILayer > ILayerPtr
ILayerPtr is a managed pointer for transferring the ownership of layers.
Used to store pattern information for gradients.
void DrawResize() override
Used to store transformation matrices.