本文整理汇总了Golang中C.gfloat函数的典型用法代码示例。如果您正苦于以下问题:Golang gfloat函数的具体用法?Golang gfloat怎么用?Golang gfloat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gfloat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AlignmentNew
// AlignmentNew is a wrapper around gtk_alignment_new().
func AlignmentNew(xalign, yalign, xscale, yscale float32) (*Alignment, error) {
c := C.gtk_alignment_new(C.gfloat(xalign), C.gfloat(yalign), C.gfloat(xscale),
C.gfloat(yscale))
if c == nil {
return nil, nilPtrErr
}
obj := wrapObject(unsafe.Pointer(c))
return wrapAlignment(obj), nil
}
示例2: Set
func (v *GObject) Set(name string, value interface{}) {
ptr := C.CString(name)
defer C.free_string(ptr)
if _, ok := value.(WrappedObject); ok {
value = value.(WrappedObject).GetInternalValue()
}
if _, ok := value.(GObject); ok {
value = value.(GObject).Object
}
if _, ok := value.(GValue); ok {
value = value.(GValue).Value
}
switch value.(type) {
case bool:
bval := gbool(value.(bool))
C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&bval))
case byte:
bval := C.gchar(value.(byte))
C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&bval))
//C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.ValueOf(C.gchar(value.(byte))).UnsafeAddr()))
case int:
ival := C.int(value.(int))
C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&ival))
case uint:
uval := C.guint(value.(uint))
C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&uval))
//C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.ValueOf(C.guint(value.(uint))).UnsafeAddr()))
case float32:
f32val := C.gfloat(value.(float32))
C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&f32val))
//C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.ValueOf(C.gfloat(value.(float64))).UnsafeAddr()))
case float64:
f64val := C.gfloat(value.(float64))
C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&f64val))
//C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.ValueOf(C.gfloat(value.(float64))).UnsafeAddr()))
case string:
pval := C.CString(value.(string))
defer C.free_string(pval)
C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&pval))
default:
if pv, ok := value.(*[0]uint8); ok {
C._g_object_set_ptr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(pv))
} else {
av := reflect.ValueOf(value)
if av.Kind() == reflect.Ptr {
C._g_object_set_ptr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(av.Pointer()))
} else if av.CanAddr() {
C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(av.UnsafeAddr()))
} else {
C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&value))
}
}
}
}
示例3: SaturateAndPixelate
/*
Modifies saturation and optionally pixelates @src, placing the result in
@dest. @src and @dest may be the same pixbuf with no ill effects. If
@saturation is 1.0 then saturation is not changed. If it's less than 1.0,
saturation is reduced (the image turns toward grayscale); if greater than
1.0, saturation is increased (the image gets more vivid colors). If @pixelate
is %TRUE, then pixels are faded in a checkerboard pattern to create a
pixelated image. @src and @dest must have the same image format, size, and
rowstride.
*/
func (self *TraitPixbuf) SaturateAndPixelate(dest IsPixbuf, saturation float32, pixelate bool) {
__cgo__pixelate := C.gboolean(0)
if pixelate {
__cgo__pixelate = C.gboolean(1)
}
C.gdk_pixbuf_saturate_and_pixelate(self.CPointer, dest.GetPixbufPointer(), C.gfloat(saturation), __cgo__pixelate)
return
}
示例4: PixbufSimpleAnimNew
/*
Creates a new, empty animation.
*/
func PixbufSimpleAnimNew(width int, height int, rate float32) (return__ *PixbufSimpleAnim) {
var __cgo__return__ interface{}
__cgo__return__ = C.gdk_pixbuf_simple_anim_new(C.gint(width), C.gint(height), C.gfloat(rate))
if __cgo__return__ != nil {
return__ = NewPixbufSimpleAnimFromCPointer(unsafe.Pointer(reflect.ValueOf(__cgo__return__).Pointer()))
}
return
}
示例5: Set
// Set value to i
func (v *Value) Set(i interface{}) {
if vg, ok := i.(ValueGetter); ok {
vg.Value().Copy(v)
return
}
// Other types
r := reflect.ValueOf(i)
switch r.Kind() {
case reflect.Invalid:
C.g_value_reset(v.g())
case reflect.Bool:
C.g_value_set_boolean(v.g(), gBoolean(r.Bool()))
case reflect.Int:
C.g_value_set_long(v.g(), C.glong(i.(int)))
case reflect.Int8:
C.g_value_set_schar(v.g(), C.gint8(i.(int8)))
case reflect.Int32:
C.g_value_set_int(v.g(), C.gint(i.(int32)))
case reflect.Int64:
C.g_value_set_int64(v.g(), C.gint64(i.(int64)))
case reflect.Uint:
C.g_value_set_ulong(v.g(), C.gulong(i.(uint)))
case reflect.Uint8:
C.g_value_set_uchar(v.g(), C.guchar(i.(uint8)))
case reflect.Uint32:
C.g_value_set_uint(v.g(), C.guint(i.(uint32)))
case reflect.Uint64:
C.g_value_set_uint64(v.g(), C.guint64(i.(uint64)))
case reflect.Float32:
C.g_value_set_float(v.g(), C.gfloat(i.(float32)))
case reflect.Float64:
C.g_value_set_double(v.g(), C.gdouble(i.(float64)))
case reflect.Ptr:
C.g_value_set_pointer(v.g(), C.gpointer(r.Pointer()))
case reflect.String:
C.g_value_set_static_string(v.g(), (*C.gchar)(C.CString(r.String())))
default:
panic("Can't represent Go value in Glib type system.")
}
}
示例6: SetAlignment
func (self *Button) SetAlignment(xalign, yalign float32) {
C.gtk_button_set_alignment(self.object, C.gfloat(xalign), C.gfloat(yalign))
}
示例7: pointerVal
// pointerVal attempts to return an unsafe.Pointer for value.
// Not all types are understood, in which case a nil Pointer
// is returned.
func pointerVal(value interface{}) unsafe.Pointer {
var p unsafe.Pointer
switch v := value.(type) {
case bool:
c := gbool(v)
p = unsafe.Pointer(&c)
case int8:
c := C.gint8(v)
p = unsafe.Pointer(&c)
case int16:
c := C.gint16(v)
p = unsafe.Pointer(&c)
case int32:
c := C.gint32(v)
p = unsafe.Pointer(&c)
case int64:
c := C.gint64(v)
p = unsafe.Pointer(&c)
case int:
c := C.gint(v)
p = unsafe.Pointer(&c)
case uint8:
c := C.guchar(v)
p = unsafe.Pointer(&c)
case uint16:
c := C.guint16(v)
p = unsafe.Pointer(&c)
case uint32:
c := C.guint32(v)
p = unsafe.Pointer(&c)
case uint64:
c := C.guint64(v)
p = unsafe.Pointer(&c)
case uint:
c := C.guint(v)
p = unsafe.Pointer(&c)
case uintptr:
p = unsafe.Pointer(C.gpointer(v))
case float32:
c := C.gfloat(v)
p = unsafe.Pointer(&c)
case float64:
c := C.gdouble(v)
p = unsafe.Pointer(&c)
case string:
cstr := C.CString(v)
defer C.free(unsafe.Pointer(cstr))
p = unsafe.Pointer(cstr)
default:
if pv, ok := value.(unsafe.Pointer); ok {
p = pv
} else {
val := reflect.ValueOf(value)
switch val.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16,
reflect.Int32, reflect.Int64:
c := C.int(val.Int())
p = unsafe.Pointer(&c)
case reflect.Uintptr, reflect.Ptr, reflect.UnsafePointer:
p = unsafe.Pointer(C.gpointer(val.Pointer()))
}
}
}
return p
}
示例8: SetFloat
// SetFloat is a wrapper around g_value_set_float().
func (v *Value) SetFloat(val float32) {
C.g_value_set_float(v.native(), C.gfloat(val))
}
示例9: gtk_misc_set_alignment
func gtk_misc_set_alignment(widget *C.GtkWidget, x float64, y float64) {
C.gtk_misc_set_alignment((*C.GtkMisc)(unsafe.Pointer(widget)), C.gfloat(x), C.gfloat(y))
}
示例10: GFloat
func GFloat(val interface{}) *GValue {
fl := val.(float32)
gf := C.gfloat(fl)
return CreateCGValue(G_TYPE_FLOAT, unsafe.Pointer(&gf))
}
示例11: SetAlignment
// SetAlignment is a wrapper around gtk_misc_set_alignment().
func (v *Misc) SetAlignment(xAlign, yAlign float32) {
C.gtk_misc_set_alignment(v.native(), C.gfloat(xAlign), C.gfloat(yAlign))
}
示例12: Set
func (v *GObject) Set(name string, value interface{}) {
ptr := C.CString(name)
defer C.free_string(ptr)
if _, ok := value.(WrappedObject); ok {
value = value.(WrappedObject).GetInternalValue()
}
if _, ok := value.(GObject); ok {
value = value.(GObject).Object
}
if _, ok := value.(GValue); ok {
value = value.(GValue).Value
}
switch value.(type) {
case bool:
C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.NewValue(bool2gboolean(value.(bool))).Addr()))
break
case byte:
C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.NewValue(C.gchar(value.(byte))).Addr()))
break
case int:
C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.NewValue(C.gint(value.(int))).Addr()))
break
case uint:
C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.NewValue(C.guint(value.(uint))).Addr()))
break
case float:
C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.NewValue(C.gfloat(value.(float))).Addr()))
break
case string:
{
pval := C.CString(value.(string))
defer C.free_string(pval)
C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.NewValue(pval).Addr()))
}
break
default:
C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.NewValue(value).Addr()))
break
}
}
示例13: FromLua
func FromLua(code string) map[string]unsafe.Pointer {
lua := lgo.NewLua()
bindings := make(map[string]unsafe.Pointer)
processActorArgs := func(actor *C.ClutterActor, args map[interface{}]interface{}) unsafe.Pointer {
pointer := unsafe.Pointer(actor)
var minFilter, magFilter *C.ClutterScalingFilter
var scaleX C.gdouble = 1.0
var scaleY C.gdouble = 1.0
var translationX, translationY, translationZ C.gfloat
for k, v := range args {
switch key := k.(type) {
case string:
switch key {
case "id":
bindings[v.(string)] = pointer
case "bgcolor", "background_color":
C.clutter_actor_set_background_color(actor, NewColorFromString(v.(string)))
case "clip_rect":
clip := (*C.ClutterRect)(v.(unsafe.Pointer))
C.clutter_actor_set_clip(actor,
C.gfloat(clip.origin.x),
C.gfloat(clip.origin.y),
C.gfloat(clip.size.width),
C.gfloat(clip.size.height))
case "content":
C.clutter_actor_set_content(actor, (*C.ClutterContent)(v.(unsafe.Pointer)))
case "content_gravity":
switch v.(string) {
case "top-left":
C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_TOP_LEFT)
case "top":
C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_TOP)
case "top-right":
C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_TOP_RIGHT)
case "left":
C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_LEFT)
case "center":
C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_CENTER)
case "right":
C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_RIGHT)
case "bottom-left":
C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_BOTTOM_LEFT)
case "bottom":
C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_BOTTOM)
case "bottom-right":
C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_BOTTOM_RIGHT)
case "resize-fill":
C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_RESIZE_FILL)
case "resize-aspect":
C.clutter_actor_set_content_gravity(actor, C.CLUTTER_CONTENT_GRAVITY_RESIZE_ASPECT)
default:
log.Fatalf("unknown content gravity: %s", v.(string))
}
case "content_repeat":
switch v.(string) {
case "none":
C.clutter_actor_set_content_repeat(actor, C.CLUTTER_REPEAT_NONE)
case "x", "x-axis":
C.clutter_actor_set_content_repeat(actor, C.CLUTTER_REPEAT_X_AXIS)
case "y", "y-axis":
C.clutter_actor_set_content_repeat(actor, C.CLUTTER_REPEAT_Y_AXIS)
case "both":
C.clutter_actor_set_content_repeat(actor, C.CLUTTER_REPEAT_BOTH)
default:
log.Fatalf("unknown content repeat: %s", v.(string))
}
case "x", "fixed_x":
C.clutter_actor_set_x(actor, C.gfloat(v.(float64)))
case "y", "fixed_y":
C.clutter_actor_set_y(actor, C.gfloat(v.(float64)))
case "height":
C.clutter_actor_set_height(actor, C.gfloat(v.(float64)))
case "layout", "layout_manager":
C.clutter_actor_set_layout_manager(actor, (*C.ClutterLayoutManager)(v.(unsafe.Pointer)))
case "mag_filter", "magnification_filter":
magFilter = (*C.ClutterScalingFilter)(v.(unsafe.Pointer))
C.clutter_actor_set_content_scaling_filters(actor, *minFilter, *magFilter)
case "margin_bottom":
C.clutter_actor_set_margin_bottom(actor, C.gfloat(v.(float64)))
case "margin_left":
C.clutter_actor_set_margin_left(actor, C.gfloat(v.(float64)))
case "margin_right":
C.clutter_actor_set_margin_right(actor, C.gfloat(v.(float64)))
case "margin_top":
C.clutter_actor_set_margin_top(actor, C.gfloat(v.(float64)))
//TODO min height
//TODO min width
case "min_filter", "minification_filter":
minFilter = (*C.ClutterScalingFilter)(v.(unsafe.Pointer))
C.clutter_actor_set_content_scaling_filters(actor, *minFilter, *magFilter)
case "name":
C.clutter_actor_set_name(actor, toGStr(v.(string)))
//TODO natural height
//TODO natural width
case "offscreen_redirect":
switch v.(string) {
case "auto", "automatic-for-opacity":
C.clutter_actor_set_offscreen_redirect(actor, C.CLUTTER_OFFSCREEN_REDIRECT_AUTOMATIC_FOR_OPACITY)
case "always":
//.........这里部分代码省略.........
示例14: Set
// Set() is a wrapper around g_object_set(). However, unlike
// g_object_set(), this function only sets one name value pair. Make
// multiple calls to this function to set multiple properties.
func (v *Object) Set(name string, value interface{}) error {
cstr := C.CString(name)
defer C.free(unsafe.Pointer(cstr))
if _, ok := value.(Object); ok {
value = value.(Object).GObject
}
var p unsafe.Pointer = nil
switch value.(type) {
case bool:
c := gbool(value.(bool))
p = unsafe.Pointer(&c)
case int8:
c := C.gint8(value.(int8))
p = unsafe.Pointer(&c)
case int16:
c := C.gint16(value.(int16))
p = unsafe.Pointer(&c)
case int32:
c := C.gint32(value.(int32))
p = unsafe.Pointer(&c)
case int64:
c := C.gint64(value.(int64))
p = unsafe.Pointer(&c)
case int:
c := C.gint(value.(int))
p = unsafe.Pointer(&c)
case uint8:
c := C.guchar(value.(uint8))
p = unsafe.Pointer(&c)
case uint16:
c := C.guint16(value.(uint16))
p = unsafe.Pointer(&c)
case uint32:
c := C.guint32(value.(uint32))
p = unsafe.Pointer(&c)
case uint64:
c := C.guint64(value.(uint64))
p = unsafe.Pointer(&c)
case uint:
c := C.guint(value.(uint))
p = unsafe.Pointer(&c)
case uintptr:
p = unsafe.Pointer(C.gpointer(value.(uintptr)))
case float32:
c := C.gfloat(value.(float32))
p = unsafe.Pointer(&c)
case float64:
c := C.gdouble(value.(float64))
p = unsafe.Pointer(&c)
case string:
cstr := C.CString(value.(string))
defer C.free(unsafe.Pointer(cstr))
p = unsafe.Pointer(cstr)
default:
if pv, ok := value.(unsafe.Pointer); ok {
p = pv
} else {
// Constants with separate types are not type asserted
// above, so do a runtime check here instead.
val := reflect.ValueOf(value)
switch val.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16,
reflect.Int32, reflect.Int64:
c := C.int(val.Int())
p = unsafe.Pointer(&c)
case reflect.Uintptr:
p = unsafe.Pointer(C.gpointer(val.Pointer()))
}
}
}
// Can't call g_object_set() as it uses a variable arg list, use a
// wrapper instead
if p != nil {
C._g_object_set_one(C.gpointer(v.GObject), (*C.gchar)(cstr), p)
return nil
} else {
return errors.New("Unable to perform type conversion")
}
}
示例15: GlibFloat
func GlibFloat(f float32) C.gfloat {
return C.gfloat(f)
}