Best Testkube code snippet using render.Obj
render_target_windows.go
Source:render_target_windows.go
1package d2d2import (3 "syscall"4 "unsafe"5 "lib/win32"6 "github.com/richardwilkes/win32/com"7)8// RenderTargetGUID holds the GUID for the RenderTarget Class.9var RenderTargetGUID = com.GUID{Data1: 0x2cd90694, Data2: 0x12e2, Data3: 0x11dc, Data4: [8]byte{0x9f, 0xed, 0x00, 0x11, 0x43, 0xa0, 0x55, 0xf9}}10// RenderTarget https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nn-d2d1-id2d1rendertarget11type RenderTarget struct {12 Resource13}14type vmtRenderTarget struct {15 vmtResource16 CreateBitmap uintptr17 CreateBitmapFromWicBitmap uintptr18 CreateSharedBitmap uintptr19 CreateBitmapBrush uintptr20 CreateSolidColorBrush uintptr21 CreateGradientStopCollection uintptr22 CreateLinearGradientBrush uintptr23 CreateRadialGradientBrush uintptr24 CreateCompatibleRenderTarget uintptr25 CreateLayer uintptr26 CreateMesh uintptr27 DrawLine uintptr28 DrawRectangle uintptr29 FillRectangle uintptr30 DrawRoundedRectangle uintptr31 FillRoundedRectangle uintptr32 DrawEllipse uintptr33 FillEllipse uintptr34 DrawGeometry uintptr35 FillGeometry uintptr36 FillMesh uintptr37 FillOpacityMask uintptr38 DrawBitmap uintptr39 DrawText uintptr40 DrawTextLayout uintptr41 DrawGlyphRun uintptr42 SetTransform uintptr43 GetTransform uintptr44 SetAntialiasMode uintptr45 GetAntialiasMode uintptr46 SetTextAntialiasMode uintptr47 GetTextAntialiasMode uintptr48 SetTextRenderingParams uintptr49 GetTextRenderingParams uintptr50 SetTags uintptr51 GetTags uintptr52 PushLayer uintptr53 PopLayer uintptr54 Flush uintptr55 SaveDrawingState uintptr56 RestoreDrawingState uintptr57 PushAxisAlignedClip uintptr58 PopAxisAlignedClip uintptr59 Clear uintptr60 BeginDraw uintptr61 EndDraw uintptr62 GetPixelFormat uintptr63 SetDpi uintptr64 GetDpi uintptr65 GetSize uintptr66 GetPixelSize uintptr67 GetMaximumBitmapSize uintptr68 IsSupported uintptr69}70func (obj *RenderTarget) vmt() *vmtRenderTarget {71 return (*vmtRenderTarget)(obj.UnsafeVirtualMethodTable)72}73// CreateBitmap https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-createbitmap%28d2d1_size_u_constvoid_uint32_constd2d1_bitmap_properties_id2d1bitmap%2974func (obj *RenderTarget) CreateBitmap(size SizeU, srcData unsafe.Pointer, pitch uint32, bitmapProperties *BitmapProperties) *Bitmap {75 var bitmap *Bitmap76 if ret, _, _ := syscall.Syscall6(obj.vmt().CreateBitmap, 6, uintptr(unsafe.Pointer(obj)), uintptr(*(*uint64)(unsafe.Pointer(&size))), uintptr(srcData), uintptr(pitch), uintptr(unsafe.Pointer(bitmapProperties)), uintptr(unsafe.Pointer(&bitmap))); ret != win32.S_OK {77 return nil78 }79 return bitmap80}81// CreateBitmapFromWicBitmap https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-createbitmapfromwicbitmap%28iwicbitmapsource_constd2d1_bitmap_properties_id2d1bitmap%2982func (obj *RenderTarget) CreateBitmapFromWicBitmap(wicBitmapSource *WicBitmapSource, bitmapProperties *BitmapProperties) *Bitmap {83 var bitmap *Bitmap84 if ret, _, _ := syscall.Syscall6(obj.vmt().CreateBitmapFromWicBitmap, 4, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(wicBitmapSource)), uintptr(unsafe.Pointer(bitmapProperties)), uintptr(unsafe.Pointer(&bitmap)), 0, 0); ret != win32.S_OK {85 return nil86 }87 return bitmap88}89// CreateSharedBitmap https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-createsharedbitmap90func (obj *RenderTarget) CreateSharedBitmap(riid *com.GUID, data unsafe.Pointer, bitmapProperties *BitmapProperties) *Bitmap {91 var bitmap *Bitmap92 if ret, _, _ := syscall.Syscall6(obj.vmt().CreateSharedBitmap, 5, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(riid)), uintptr(data), uintptr(unsafe.Pointer(bitmapProperties)), uintptr(unsafe.Pointer(&bitmap)), 0); ret != win32.S_OK {93 return nil94 }95 return bitmap96}97// CreateBitmapBrush https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-createbitmapbrush%28id2d1bitmap_id2d1bitmapbrush%2998func (obj *RenderTarget) CreateBitmapBrush(bitmap *Bitmap, bitmapBrushProperties *BitmapBrushProperties, brushProperties *BrushProperties) *BitmapBrush {99 var bitmapBrush *BitmapBrush100 if ret, _, _ := syscall.Syscall6(obj.vmt().CreateBitmapBrush, 5, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(bitmap)), uintptr(unsafe.Pointer(bitmapBrushProperties)), uintptr(unsafe.Pointer(brushProperties)), uintptr(unsafe.Pointer(&bitmapBrush)), 0); ret != win32.S_OK {101 return nil102 }103 return bitmapBrush104}105// CreateSolidColorBrush https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-createsolidcolorbrush%28constd2d1_color_f_constd2d1_brush_properties_id2d1solidcolorbrush%29106func (obj *RenderTarget) CreateSolidColorBrush(color Color, brushProperties *BrushProperties) *SolidColorBrush {107 var solidColorBrush *SolidColorBrush108 if ret, _, _ := syscall.Syscall6(obj.vmt().CreateSolidColorBrush, 4, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&color)), uintptr(unsafe.Pointer(brushProperties)), uintptr(unsafe.Pointer(&solidColorBrush)), 0, 0); ret != win32.S_OK {109 return nil110 }111 return solidColorBrush112}113// CreateGradientStopCollection https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-creategradientstopcollection(constd2d1_gradient_stop_uint32_d2d1_gamma_d2d1_extend_mode_id2d1gradientstopcollection)114func (obj *RenderTarget) CreateGradientStopCollection(gradientStops []GradientStop, useGamma1 bool, extendMode ExtendMode) *GradientStopCollection {115 var gradientStopCollection *GradientStopCollection116 var colorInterpolationGamma uint32117 if useGamma1 {118 colorInterpolationGamma = 1119 }120 if ret, _, _ := syscall.Syscall6(obj.vmt().CreateGradientStopCollection, 6, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&(gradientStops[0]))), uintptr(len(gradientStops)), uintptr(colorInterpolationGamma), uintptr(extendMode), uintptr(unsafe.Pointer(&gradientStopCollection))); ret != win32.S_OK {121 return nil122 }123 return gradientStopCollection124}125// CreateLinearGradientBrush https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-createlineargradientbrush%28constd2d1_linear_gradient_brush_properties_constd2d1_brush_properties_id2d1gradientstopcollection_id2d1lineargradientbrush%29126func (obj *RenderTarget) CreateLinearGradientBrush(linearGradientBrushProperties *LinearGradientBrushProperties, brushProperties *BrushProperties, gradientStopCollection *GradientStopCollection) *LinearGradientBrush {127 var linearGradientBrush *LinearGradientBrush128 if ret, _, _ := syscall.Syscall6(obj.vmt().CreateLinearGradientBrush, 5, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(linearGradientBrushProperties)), uintptr(unsafe.Pointer(brushProperties)), uintptr(unsafe.Pointer(gradientStopCollection)), uintptr(unsafe.Pointer(&linearGradientBrush)), 0); ret != win32.S_OK {129 return nil130 }131 return linearGradientBrush132}133// CreateRadialGradientBrush https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-createradialgradientbrush%28constd2d1_radial_gradient_brush_properties_constd2d1_brush_properties_id2d1gradientstopcollection_id2d1radialgradientbrush%29134func (obj *RenderTarget) CreateRadialGradientBrush(radialGradientBrushProperties *RadialGradientBrushProperties, brushProperties *BrushProperties, gradientStopCollection *GradientStopCollection) *RadialGradientBrush {135 var radialGradientBrush *RadialGradientBrush136 if ret, _, _ := syscall.Syscall6(obj.vmt().CreateRadialGradientBrush, 5, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(radialGradientBrushProperties)), uintptr(unsafe.Pointer(brushProperties)), uintptr(unsafe.Pointer(gradientStopCollection)), uintptr(unsafe.Pointer(&radialGradientBrush)), 0); ret != win32.S_OK {137 return nil138 }139 return radialGradientBrush140}141// CreateCompatibleRenderTarget https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-createcompatiblerendertarget(d2d1_size_f_d2d1_size_u_d2d1_pixel_format_id2d1bitmaprendertarget)142func (obj *RenderTarget) CreateCompatibleRenderTarget(desiredSize *Size, desiredPixelSize *SizeU, desiredFormat *PixelFormat, GDICompatible bool) *BitmapRenderTarget {143 var bitmapRenderTarget *BitmapRenderTarget144 var options uint32145 if GDICompatible {146 options = 1147 }148 if ret, _, _ := syscall.Syscall6(obj.vmt().CreateCompatibleRenderTarget, 6, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&desiredSize)), uintptr(unsafe.Pointer(desiredPixelSize)), uintptr(unsafe.Pointer(desiredFormat)), uintptr(options), uintptr(unsafe.Pointer(&bitmapRenderTarget))); ret != win32.S_OK {149 return nil150 }151 return bitmapRenderTarget152}153// CreateLayer https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-createlayer(d2d1_size_f_id2d1layer)154func (obj *RenderTarget) CreateLayer(size Size) *Layer {155 var layer *Layer156 if ret, _, _ := syscall.Syscall(obj.vmt().CreateLayer, 3, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&size)), uintptr(unsafe.Pointer(&layer))); ret != win32.S_OK {157 return nil158 }159 return layer160}161// CreateMesh https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-createmesh162func (obj *RenderTarget) CreateMesh() *Mesh {163 var mesh *Mesh164 if ret, _, _ := syscall.Syscall(obj.vmt().CreateMesh, 2, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&mesh)), 0); ret != win32.S_OK {165 return nil166 }167 return mesh168}169// DrawLine https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-drawline170func (obj *RenderTarget) DrawLine(p0 Point, p1 Point, brush *Brush, strokeWidth float32, strokeStyle *StrokeStyle) {171 syscall.Syscall6(obj.vmt().DrawLine, 6, uintptr(unsafe.Pointer(obj)), uintptr(*(*uint64)(unsafe.Pointer(&p0))), uintptr(*(*uint64)(unsafe.Pointer(&p1))), uintptr(unsafe.Pointer(brush)), uintptr(*(*uint32)(unsafe.Pointer(&strokeWidth))), uintptr(unsafe.Pointer(strokeStyle)))172}173// DrawRectangle https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-drawrectangle%28constd2d1_rect_f_id2d1brush_float_id2d1strokestyle%29174func (obj *RenderTarget) DrawRectangle(rect Rect, brush *Brush, strokeWidth float32, strokeStyle *StrokeStyle) {175 syscall.Syscall6(obj.vmt().DrawRectangle, 5, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&rect)), uintptr(unsafe.Pointer(brush)), uintptr(*(*uint32)(unsafe.Pointer(&strokeWidth))), uintptr(unsafe.Pointer(strokeStyle)), 0)176}177// FillRectangle https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-fillrectangle%28constd2d1_rect_f_id2d1brush%29178func (obj *RenderTarget) FillRectangle(rect Rect, brush *Brush) {179 syscall.Syscall(obj.vmt().FillRectangle, 3, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&rect)), uintptr(unsafe.Pointer(brush)))180}181// DrawRoundedRectangle https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-drawroundedrectangle%28constd2d1_rounded_rect__id2d1brush_float_id2d1strokestyle%29182func (obj *RenderTarget) DrawRoundedRectangle(roundedRect RoundedRect, brush *Brush, strokeWidth float32, strokeStyle *StrokeStyle) {183 syscall.Syscall6(obj.vmt().DrawRoundedRectangle, 5, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&roundedRect)), uintptr(unsafe.Pointer(brush)), uintptr(*(*uint32)(unsafe.Pointer(&strokeWidth))), uintptr(unsafe.Pointer(strokeStyle)), 0)184}185// FillRoundedRectangle https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-fillroundedrectangle%28constd2d1_rounded_rect_id2d1brush%29186func (obj *RenderTarget) FillRoundedRectangle(roundedRect RoundedRect, brush *Brush) {187 syscall.Syscall(obj.vmt().FillRoundedRectangle, 3, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&roundedRect)), uintptr(unsafe.Pointer(brush)))188}189// DrawEllipse https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-drawellipse%28constd2d1_ellipse__id2d1brush_float_id2d1strokestyle%29190func (obj *RenderTarget) DrawEllipse(ellipse Ellipse, brush *Brush, strokeWidth float32, strokeStyle *StrokeStyle) {191 syscall.Syscall6(obj.vmt().DrawEllipse, 5, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&ellipse)), uintptr(unsafe.Pointer(brush)), uintptr(*(*uint32)(unsafe.Pointer(&strokeWidth))), uintptr(unsafe.Pointer(strokeStyle)), 0)192}193// FillEllipse https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-fillellipse%28constd2d1_ellipse__id2d1brush%29194func (obj *RenderTarget) FillEllipse(ellipse Ellipse, brush *Brush) {195 syscall.Syscall(obj.vmt().FillEllipse, 3, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&ellipse)), uintptr(unsafe.Pointer(brush)))196}197// DrawGeometry https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-drawgeometry198func (obj *RenderTarget) DrawGeometry(geometry *Geometry, brush *Brush, strokeWidth float32, strokeStyle *StrokeStyle) {199 syscall.Syscall6(obj.vmt().DrawGeometry, 5, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(geometry)), uintptr(unsafe.Pointer(brush)), uintptr(*(*uint32)(unsafe.Pointer(&strokeWidth))), uintptr(unsafe.Pointer(strokeStyle)), 0)200}201// FillGeometry https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-fillgeometry202func (obj *RenderTarget) FillGeometry(geometry *Geometry, brush *Brush, opacityBrush *Brush) {203 syscall.Syscall6(obj.vmt().FillGeometry, 4, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(geometry)), uintptr(unsafe.Pointer(brush)), uintptr(unsafe.Pointer(opacityBrush)), 0, 0)204}205// FillMesh https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-fillmesh206func (obj *RenderTarget) FillMesh(mesh *Mesh, brush *Brush) {207 syscall.Syscall(obj.vmt().FillMesh, 3, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(mesh)), uintptr(unsafe.Pointer(brush)))208}209// FillOpacityMask https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-fillopacitymask%28id2d1bitmap_id2d1brush_d2d1_opacity_mask_content_constd2d1_rect_f__constd2d1_rect_f_%29210func (obj *RenderTarget) FillOpacityMask(opacityMask *Bitmap, brush *Brush, content OpacityMaskContent, destinationRectangle, sourceRectangle Rect) {211 syscall.Syscall6(obj.vmt().FillOpacityMask, 6, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(opacityMask)), uintptr(unsafe.Pointer(brush)), uintptr(content), uintptr(unsafe.Pointer(&destinationRectangle)), uintptr(unsafe.Pointer(&sourceRectangle)))212}213// DrawBitmap https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-drawbitmap(id2d1bitmap_constd2d1_rect_f__float_d2d1_bitmap_interpolation_mode_constd2d1_rect_f_)214func (obj *RenderTarget) DrawBitmap(bitmap *Bitmap, destinationRectangle Rect, opacity float32, useLinearInterpolation bool, sourceRectangle Rect) {215 var interpolationMode uint32216 if useLinearInterpolation {217 interpolationMode = 1218 }219 syscall.Syscall6(obj.vmt().DrawBitmap, 6, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(bitmap)), uintptr(unsafe.Pointer(&destinationRectangle)), uintptr(*(*uint32)(unsafe.Pointer(&opacity))), uintptr(interpolationMode), uintptr(unsafe.Pointer(&sourceRectangle)))220}221// DrawText https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-drawtext%28constwchar_uint32_idwritetextformat_constd2d1_rect_f_id2d1brush_d2d1_draw_text_options_dwrite_measuring_mode%29222func (obj *RenderTarget) DrawText(str string, textFormat *TextFormat, layoutRect Rect, defaultForegroundBrush *Brush, options DrawTextOptions, measuringMode MeasuringMode) {223 s, err := syscall.UTF16FromString(str)224 if err != nil {225 s = []uint16{0}226 }227 syscall.Syscall9(obj.vmt().DrawText, 8, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&(s[0]))), uintptr(len(s)), uintptr(unsafe.Pointer(textFormat)), uintptr(unsafe.Pointer(&layoutRect)), uintptr(unsafe.Pointer(defaultForegroundBrush)), uintptr(options), uintptr(measuringMode), 0)228}229// DrawTextLayout https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-drawtextlayout230func (obj *RenderTarget) DrawTextLayout(origin Point, textLayout *TextLayout, defaultForegroundBrush *Brush, options DrawTextOptions) {231 syscall.Syscall6(obj.vmt().DrawTextLayout, 5, uintptr(unsafe.Pointer(obj)), uintptr(*(*uint64)(unsafe.Pointer(&origin))), uintptr(unsafe.Pointer(textLayout)), uintptr(unsafe.Pointer(defaultForegroundBrush)), uintptr(options), 0)232}233// DrawGlyphRun https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-drawglyphrun234func (obj *RenderTarget) DrawGlyphRun(baselineOrigin Point, glyphRun *GlyphRun, foregroundBrush *Brush, measuringMode MeasuringMode) {235 syscall.Syscall6(obj.vmt().DrawGlyphRun, 5, uintptr(unsafe.Pointer(obj)), uintptr(*(*uint64)(unsafe.Pointer(&baselineOrigin))), uintptr(unsafe.Pointer(glyphRun)), uintptr(unsafe.Pointer(foregroundBrush)), uintptr(measuringMode), 0)236}237// SetTransform https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-settransform%28constd2d1_matrix_3x2_f%29238func (obj *RenderTarget) SetTransform(transform *Matrix3x2) {239 syscall.Syscall(obj.vmt().SetTransform, 2, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(transform)), 0)240}241// Transform https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-gettransform242func (obj *RenderTarget) Transform() *Matrix3x2 {243 var transform Matrix3x2244 syscall.Syscall(obj.vmt().GetTransform, 2, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&transform)), 0)245 return &transform246}247// SetAntialiasMode https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-setantialiasmode248func (obj *RenderTarget) SetAntialiasMode(aliased bool) {249 var antialiasMode uint32250 if aliased {251 antialiasMode = 1252 }253 syscall.Syscall(obj.vmt().SetAntialiasMode, 2, uintptr(unsafe.Pointer(obj)), uintptr(antialiasMode), 0)254}255// IsAntialiasModePerPrimitive https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-getantialiasmode256func (obj *RenderTarget) IsAntialiasModePerPrimitive() bool {257 ret, _, _ := syscall.Syscall(obj.vmt().GetAntialiasMode, 1, uintptr(unsafe.Pointer(obj)), 0, 0)258 return ret == 0259}260// IsAntialiasModeAliased https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-getantialiasmode261func (obj *RenderTarget) IsAntialiasModeAliased() bool {262 ret, _, _ := syscall.Syscall(obj.vmt().GetAntialiasMode, 1, uintptr(unsafe.Pointer(obj)), 0, 0)263 return ret == 1264}265// SetTextAntialiasMode https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-settextantialiasmode266func (obj *RenderTarget) SetTextAntialiasMode(textAntialiasMode TextAntialiasMode) {267 syscall.Syscall(obj.vmt().SetTextAntialiasMode, 2, uintptr(unsafe.Pointer(obj)), uintptr(textAntialiasMode), 0)268}269// TextAntialiasMode https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-gettextantialiasmode270func (obj *RenderTarget) TextAntialiasMode() TextAntialiasMode {271 ret, _, _ := syscall.Syscall(obj.vmt().GetTextAntialiasMode, 1, uintptr(unsafe.Pointer(obj)), 0, 0)272 return TextAntialiasMode(ret)273}274// SetTextRenderingParams https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-settextrenderingparams275func (obj *RenderTarget) SetTextRenderingParams(textRenderingParams *TextRenderingParams) {276 syscall.Syscall(obj.vmt().SetTextRenderingParams, 2, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(textRenderingParams)), 0)277}278// TextRenderingParams https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-gettextrenderingparams279func (obj *RenderTarget) TextRenderingParams() *TextRenderingParams {280 var textRenderingParams *TextRenderingParams281 syscall.Syscall(obj.vmt().GetTextRenderingParams, 2, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&textRenderingParams)), 0)282 return textRenderingParams283}284// SetTags https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-settags285func (obj *RenderTarget) SetTags(tag1, tag2 Tag) {286 syscall.Syscall(obj.vmt().SetTags, 3, uintptr(unsafe.Pointer(obj)), uintptr(tag1), uintptr(tag2))287}288// Tags https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-gettags289func (obj *RenderTarget) Tags() (tag1, tag2 Tag) {290 syscall.Syscall(obj.vmt().GetTags, 3, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&tag1)), uintptr(unsafe.Pointer(&tag2)))291 return292}293// PushLayer https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-pushlayer%28constd2d1_layer_parameters_id2d1layer%29294// Must have a matching PopLayer call.295func (obj *RenderTarget) PushLayer(layerParameters *LayerParameters, layer *Layer) {296 syscall.Syscall(obj.vmt().PushLayer, 3, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(layerParameters)), uintptr(unsafe.Pointer(layer)))297}298// PopLayer https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-poplayer299func (obj *RenderTarget) PopLayer() {300 syscall.Syscall(obj.vmt().PopLayer, 1, uintptr(unsafe.Pointer(obj)), 0, 0)301}302// Flush https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-flush303func (obj *RenderTarget) Flush() (tag1, tag2 Tag) {304 syscall.Syscall(obj.vmt().Flush, 3, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&tag1)), uintptr(unsafe.Pointer(&tag2)))305 return306}307// SaveDrawingState https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-savedrawingstate308func (obj *RenderTarget) SaveDrawingState() *DrawingStateBlock {309 var drawingStateBlock DrawingStateBlock310 syscall.Syscall(obj.vmt().SaveDrawingState, 2, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&drawingStateBlock)), 0)311 return &drawingStateBlock312}313// RestoreDrawingState https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-restoredrawingstate314func (obj *RenderTarget) RestoreDrawingState(drawingStateBlock *DrawingStateBlock) {315 syscall.Syscall(obj.vmt().RestoreDrawingState, 2, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(drawingStateBlock)), 0)316}317// PushAxisAlignedClip https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-pushaxisalignedclip(constd2d1_rect_f__d2d1_antialias_mode)318// Must have a matching PopAxisAlignedClip call.319func (obj *RenderTarget) PushAxisAlignedClip(clipRect Rect, aliased bool) {320 var antialiasMode uint32321 if aliased {322 antialiasMode = 1323 }324 syscall.Syscall(obj.vmt().PushAxisAlignedClip, 3, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&clipRect)), uintptr(antialiasMode))325}326// PopAxisAlignedClip https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-popaxisalignedclip327func (obj *RenderTarget) PopAxisAlignedClip() {328 syscall.Syscall(obj.vmt().PopAxisAlignedClip, 1, uintptr(unsafe.Pointer(obj)), 0, 0)329}330// Clear https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-clear%28constd2d1_color_f_%29331func (obj *RenderTarget) Clear(color Color) {332 syscall.Syscall(obj.vmt().Clear, 2, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&color)), 0)333}334// BeginDraw https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-begindraw335// Must have a matching EndDraw call.336func (obj *RenderTarget) BeginDraw() {337 syscall.Syscall(obj.vmt().BeginDraw, 1, uintptr(unsafe.Pointer(obj)), 0, 0)338}339// EndDraw https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-enddraw340func (obj *RenderTarget) EndDraw() (tag1, tag2 Tag) {341 syscall.Syscall(obj.vmt().EndDraw, 3, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&tag1)), uintptr(unsafe.Pointer(&tag2)))342 return343}344// PixelFormat https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-getpixelformat345func (obj *RenderTarget) PixelFormat() PixelFormat {346 var format PixelFormat347 syscall.Syscall(obj.vmt().GetPixelFormat, 2, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&format)), 0)348 return format349}350// SetDPI https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-setdpi351func (obj *RenderTarget) SetDPI(dpiX, dpiY float32) {352 syscall.Syscall(obj.vmt().SetDpi, 3, uintptr(unsafe.Pointer(obj)), uintptr(*(*uint32)(unsafe.Pointer(&dpiX))), uintptr(*(*uint32)(unsafe.Pointer(&dpiY))))353}354// DPI https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-getdpi355func (obj *RenderTarget) DPI() (dpiX, dpiY float32) {356 syscall.Syscall(obj.vmt().GetDpi, 3, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&dpiX)), uintptr(unsafe.Pointer(&dpiY)))357 return358}359// Size https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-getsize360func (obj *RenderTarget) Size() Size {361 var size Size362 syscall.Syscall(obj.vmt().GetSize, 2, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&size)), 0)363 return size364}365// PixelSize https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-getpixelsize366func (obj *RenderTarget) PixelSize() SizeU {367 var size SizeU368 syscall.Syscall(obj.vmt().GetPixelSize, 2, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(&size)), 0)369 return size370}371// MaximumBitmapSize https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-getmaximumbitmapsize372func (obj *RenderTarget) MaximumBitmapSize() uint32 {373 ret, _, _ := syscall.Syscall(obj.vmt().GetMaximumBitmapSize, 1, uintptr(unsafe.Pointer(obj)), 0, 0)374 return uint32(ret)375}376// IsSupported https://docs.microsoft.com/en-us/windows/win32/api/d2d1/nf-d2d1-id2d1rendertarget-issupported%28constd2d1_render_target_properties%29377func (obj *RenderTarget) IsSupported(renderTargetProperties *RenderTargetProperties) bool {378 ret, _, _ := syscall.Syscall(obj.vmt().IsSupported, 2, uintptr(unsafe.Pointer(obj)), uintptr(unsafe.Pointer(renderTargetProperties)), 0)379 return ret != 0380}...
adminStatsTeam.go
Source:adminStatsTeam.go
...169 if obj == nil {170 render.Render(w, r, ErrNotFound)171 return172 }173 log.Printf("STeamAdminR.ShowView: Obj: %v", obj)174 //render.Status(r, http.StatusOK)175 //render.JSON(w, r, l10n.Unpack(obj))176 render.Status(r, http.StatusOK)177 if err := render.Render(w, r, &StatsTeamAdminResponse{Team: obj}); err != nil {178 render.Render(w, r, ErrRender(err))179 return180 }181}182func (s *StatsTeamAdminResource) EditView(w http.ResponseWriter, r *http.Request) {183 var (184 obj = GetStatsTeamCtx(r)185 )186 tx := db.GetDBFromRequestContext(r)187 if obj == nil {188 render.Render(w, r, ErrNotFound)189 return190 }191 data := StatsTeamAdminRequest{}192 if err := render.Bind(r, &data); err != nil {193 render.Render(w, r, ErrInvalidRequest(err))194 return195 }196 team := data.Team197 log.Printf("STAR.EV: %#v", team)198 if err := tx.Model(team).Where("id = ?", obj.ID).Update(&team).Error; err != nil {199 log.Printf("STAR.EditView failed: %v", err)200 render.Render(w, r, ErrRender(err))201 return202 }203 log.Printf("STeamAdminR.EditView: Obj: %v", obj)204 render.Status(r, http.StatusOK)205 if err := render.Render(w, r, &StatsTeamAdminResponse{Team: team}); err != nil {206 render.Render(w, r, ErrRender(err))207 return208 }209}210func (s *StatsTeamAdminResource) DeleteView(w http.ResponseWriter, r *http.Request) {211 var (212 obj = GetStatsTeamCtx(r)213 )214 tx := db.GetDBFromRequestContext(r)215 if obj == nil {216 render.Render(w, r, ErrNotFound)217 return...
adminBadge.go
Source:adminBadge.go
...74 ctx := context.WithValue(r.Context(), ar.CtxKey, item)75 next.ServeHTTP(w, r.WithContext(ctx))76 })77}78func (ar *BadgeAdminResource) GetObjectFromCtx(r *http.Request) *models.Badge{79 obj, _ := r.Context().Value(ar.CtxKey).(*models.Badge)80 return obj81}82func (ar *BadgeAdminResource) ListView(w http.ResponseWriter, r *http.Request) {83 var (84 items = []models.Badge{}85 tx = db.GetDBFromRequestContext(r)86 )87 if err := tx.Table(ar.TableName).Order("created_at").Find(&items).Error; err != nil {88 e := ErrInternalServerError(err)89 render.Render(w, r, e)90 return91 }92 render.JSON(w, r, items)93 return94}95func (ar *BadgeAdminResource) CreateView(w http.ResponseWriter, r *http.Request) {96 tx := db.GetDBFromRequestContext(r)97 data := &badgeRequest{}98 if err := render.Bind(r, data); err != nil {99 render.Render(w, r, ErrInvalidRequest(err))100 return101 }102 obj := data103 if err := tx.Model(obj).Create(obj).Error; err != nil {104 render.Render(w, r, ErrInvalidRequest(err))105 return106 }107 render.Status(r, http.StatusCreated)108 render.JSON(w, r, obj)109}110func (ar *BadgeAdminResource) ShowView(w http.ResponseWriter, r *http.Request) {111 // positive case112 obj := ar.GetObjectFromCtx(r);113 if obj == nil {114 render.Render(w, r, ErrNotFound)115 return116 }117 if err := render.Render(w, r, &badgeResponse{obj}); err != nil {118 render.Render(w, r, ErrRender(err))119 return120 }121 return122}123func (ar *BadgeAdminResource) EditView(w http.ResponseWriter, r *http.Request) {124}125func (ar *BadgeAdminResource) DeleteView(w http.ResponseWriter, r *http.Request) {126 tx := db.GetDBFromRequestContext(r)127 obj := ar.GetObjectFromCtx(r)128 if obj == nil {129 render.Render(w, r, ErrNotFound)130 return131 }132 if err := tx.Table(ar.TableName).Delete(obj).Error; err != nil {133 render.Render(w, r, ErrRender(err))134 return135 }136 if err := render.Render(w, r, &badgeResponse{obj, }); err != nil {137 render.Render(w, r, ErrRender(err))138 return139 }140}...
Obj
Using AI Code Generation
1func (r *render) Obj(name string, obj interface{}) {2 if r.err != nil {3 }4 if r.w == nil {5 r.err = errors.New("responseWriter is nil")6 }7 if r.status == 0 {8 }9 r.w.WriteHeader(r.status)10 if name == "" {11 r.err = errors.New("template name is empty")12 }13 if obj == nil {14 r.err = errors.New("template object is nil")15 }16 if r.templates == nil {17 r.err = errors.New("templates is nil")18 }19 if r.templates[name] == nil {20 r.err = fmt.Errorf("template %s not found", name)21 }22 r.err = r.templates[name].Execute(r.w, obj)23}24func (r *render) HTML(name string, obj interface{}) {25 if r.err != nil {26 }27 if r.w == nil {28 r.err = errors.New("responseWriter is nil")29 }30 if r.status == 0 {31 }32 r.w.WriteHeader(r.status)33 if name == "" {34 r.err = errors.New("template name is empty")35 }36 if obj == nil {37 r.err = errors.New("template object is nil")38 }39 if r.templates == nil {40 r.err = errors.New("templates is nil")41 }42 if r.templates[name] == nil {43 r.err = fmt.Errorf("template %s not found",
Obj
Using AI Code Generation
1import (2type render struct {3}4func (r *render) Obj(w http.ResponseWriter, name string, data interface{}) {5 err := r.templates.ExecuteTemplate(w, name, data)6 if err != nil {7 log.Fatal(err)8 }9}10func main() {11 tpl := template.Must(template.ParseGlob("templates/*.html"))12 r := render{13 }14 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {15 fmt.Fprintf(w, "Hello, World")16 })17 http.HandleFunc("/home", func(w http.ResponseWriter, r *http.Request) {18 r.Obj(w, "home.html", nil)19 })20 http.HandleFunc("/about", func(w http.ResponseWriter, r *http.Request) {21 r.Obj(w, "about.html", nil)22 })23 http.HandleFunc("/contact", func(w http.ResponseWriter, r *http.Request) {24 r.Obj(w, "contact.html", nil)25 })26 http.ListenAndServe(":8080", nil)27}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!