mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-03 01:09:29 -04:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
47 lines
1.1 KiB
Modula-2
47 lines
1.1 KiB
Modula-2
#include "sbox/graphicsscene.h"
|
|
|
|
native class QGraphicsScene as Native.QGraphicsScene : QObject
|
|
{
|
|
QRectF sceneRect();
|
|
void setSceneRect(QRectF rect);
|
|
|
|
QRectF itemsBoundingRect();
|
|
|
|
void addItem(QGraphicsItem item);
|
|
void removeItem(QGraphicsItem item);
|
|
|
|
inline void setSelectionArea( QGraphicsView pView, QRectF rect )
|
|
{
|
|
QPainterPath selectionPath;
|
|
selectionPath.addPolygon( pView->mapToScene( rect.toRect() ) );
|
|
selectionPath.closeSubpath();
|
|
self->setSelectionArea( selectionPath );
|
|
}
|
|
|
|
inline bool Capture( string path )
|
|
{
|
|
QRectF sceneRect = self->itemsBoundingRect();
|
|
QSize imageSize( sceneRect.width(), sceneRect.height() );
|
|
|
|
QImage image( imageSize, QImage::Format_ARGB32 );
|
|
image.fill( Qt::transparent );
|
|
|
|
QPainter painter( &image );
|
|
painter.setRenderHint( QPainter::Antialiasing, true );
|
|
painter.setRenderHint( QPainter::SmoothPixmapTransform, true );
|
|
self->render( &painter, QRectF(), sceneRect );
|
|
painter.end();
|
|
|
|
return image.save( path, "PNG" );
|
|
}
|
|
}
|
|
|
|
native class ManagedGraphicsScene : QGraphicsScene
|
|
{
|
|
static QGraphicsScene Create( QObject parent, Editor.GraphicsScene obj ); [new]
|
|
}
|
|
|
|
managed class Editor.GraphicsScene
|
|
{
|
|
|
|
} |