func patternSetSubtypeID(p *C.cairo_pattern_t, s subtypeID) { if fontType(C.cairo_pattern_get_type(p)) != PatternTypeRasterSource { panic("pattern is not a raster pattern") } if C.cairo_pattern_get_user_data(p, stkey) != nil { panic("pattern already has subtype set") } C.cairo_pattern_set_user_data(p, stkey, s.c(), free) }
func patternGetSubtypeID(p *C.cairo_pattern_t) subtypeID { if fontType(C.cairo_pattern_get_type(p)) != PatternTypeRasterSource { panic("pattern is not a raster pattern") } ptr := C.cairo_pattern_get_user_data(p, stkey) if ptr == nil { panic("no subtype set: pattern not registered") } return subtypeID(ctoint(ptr)) }