Window* create_window_int(Rect frame, bool root) { Window* window = (Window*)kmalloc(sizeof(Window)); memset(window, 0, sizeof(Window)); window->layer = create_layer(frame.size); window->size = frame.size; window->frame = frame; window->border_color = color_make(50, 122, 40); window->border_width = 1; window->subviews = array_m_create(MAX_ELEMENTS); window->title = "Window"; window->animations = array_m_create(16); //root window doesn't have a title view if (!root) { window->title_view = create_title_view(window); } window->content_view = create_content_view(window, root); window->needs_redraw = 1; window->last_draw_timestamp = time(); //if this window was created by a call to xserv_win_create(), //then we're in a syscall handler and getpid() will return the pid of the //proc that ran the syscall //this is how we know when a user proc is connected to a window window->owner_pid = getpid(); return window; }
void create_net(t_net *net, t_info info) { int i; int n_neuron; i = 1; n_neuron = (info.n_in + info.n_out) / 2; net->n_hid = info.n_hid; net->n_tot = info.n_hid + 1; net->layer = ft_memalloc((info.n_hid + 1) * sizeof(t_layer)); create_layer(&net->layer[0], info.n_in, n_neuron, 0); while (i < net->n_hid) { create_layer(&net->layer[i], n_neuron, n_neuron, i); i++; } create_layer(&net->layer[i], n_neuron, info.n_out, i); }
void image_new_blank(image_t *image, gdouble rel_w, gdouble rel_h) { double w, h; get_abs_pos(rel_w, rel_h, &w, &h); image->layer = create_layer(w, h); image->rotation = 0; image->surface = create_surface(w, h); image->pbuf = NULL; add_layer(image->layer); }
View* create_view(Rect frame) { View* view = (View*)kmalloc(sizeof(View)); view->layer = create_layer(frame.size); view->frame = frame; view->superview = NULL; view->background_color = color_make(0, 255, 0); view->subviews = array_m_create(MAX_ELEMENTS); view->labels = array_m_create(MAX_ELEMENTS); view->bmps = array_m_create(MAX_ELEMENTS); view->buttons = array_m_create(MAX_ELEMENTS); view->needs_redraw = 1; return view; }
/*BeginDocumentation Name: topology::CreateLayer - create a spatial layer of nodes Synopsis: dict CreateLayer -> layer Parameters: dict - dictionary with layer specification Description: The Topology module organizes neuronal networks in layers. A layer is a special type of subnet which contains information about the spatial position of its nodes. There are three classes of layers: grid-based layers, in which each element is placed at a location in a regular grid; free layers, in which elements can be placed arbitrarily in space; and random layers, where the elements are distributed randomly throughout a region in space. Which kind of layer this command creates depends on the elements in the supplied specification dictionary. Author: Håkon Enger, Kittel Austvoll */ void TopologyModule::CreateLayer_DFunction::execute( SLIInterpreter* i ) const { i->assert_stack_load( 1 ); DictionaryDatum layer_dict = getValue< DictionaryDatum >( i->OStack.pick( 0 ) ); index layernode = create_layer( layer_dict ); i->OStack.pop( 1 ); i->OStack.push( layernode ); i->EStack.pop(); }
void do_add_layer(GtkWidget *widget, gpointer *data) { Layer *lay; char **sel = gtk_file_selection_get_selections(GTK_FILE_SELECTION(data)); for(int c=0;sel[c];c++) { func("%s : creating %s",__FUNCTION__,sel[c]); lay = create_layer(sel[c]); if(!lay) return; if(lay->init(env)) { env->layers.append(lay); env->layers.sel(0); /* deselect others */ lay->sel(true); } else delete lay; } }
static View* create_title_view(Window* window) { if (!window) return NULL; Rect title_view_frame = rect_make(point_make(0, 0), size_make(window->frame.size.width, WINDOW_TITLE_VIEW_HEIGHT)); View* title_view = create_view(title_view_frame); title_view->background_color = window->border_color; Button* close_button = create_button(rect_make(point_zero(), size_make(CHAR_WIDTH * 2, title_view->frame.size.height)), "X"); close_button->mousedown_handler = (event_handler)&close_button_clicked; add_button(title_view, close_button); Button* minimize_button = create_button(rect_make(point_make(rect_max_x(close_button->frame), 0), size_make(CHAR_WIDTH * 2, title_view->frame.size.height)), "-"); minimize_button->mousedown_handler = (event_handler)&minimize_button_clicked; add_button(title_view, minimize_button); //add title label to title view int label_length = 20 * CHAR_WIDTH; Rect label_frame = rect_make(point_make(rect_max_x(minimize_button->frame) + 15, title_view_frame.size.height / 2 - (CHAR_HEIGHT / 2)), size_make(label_length, CHAR_HEIGHT)); Label* title_label = create_label(label_frame, window->title); title_label->text_color = color_black(); add_sublabel(title_view, title_label); Bmp* dots = create_bmp(title_view_frame, create_layer(title_view_frame.size)); uint8_t* ref = dots->layer->raw; for (int y = 0; y < dots->frame.size.height; y++) { for (int x = 0; x < dots->frame.size.width; x++) { if (!((x + y) % 2)) { *ref++ = 50; *ref++ = 50; *ref++ = 50; } else { *ref++ = 200; *ref++ = 160; *ref++ = 90; } } } add_bmp(title_view, dots); return title_view; }
gboolean image_new(image_t *image, const char *filename) { GError **error = NULL; image->pbuf = gdk_pixbuf_new_from_file(filename, error); if (!image->pbuf) return FALSE; image->layer = create_layer(gdk_pixbuf_get_width(image->pbuf), gdk_pixbuf_get_height(image->pbuf)); image->rotation = 0; image->surface = create_surface(image->layer->width, image->layer->height); cairo_t *cr = cairo_create(image->surface); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); gdk_cairo_set_source_pixbuf(cr, image->pbuf, 0, 0); cairo_paint(cr); cairo_destroy(cr); add_layer(image->layer); return TRUE; }
gboolean load_image(const gchar *filename, gint32 *image_ID, GError **error) { gboolean status = FALSE; gchar *indata = NULL; gsize indatalen; gint width; gint height; WebPMux *mux = NULL; WebPData wp_data; uint32_t flags; uint8_t *outdata = NULL; #ifdef GIMP_2_9 /* Initialize GEGL */ gegl_init(NULL, NULL); #endif do { /* Attempt to read the file contents from disk */ if (g_file_get_contents(filename, &indata, &indatalen, error) == FALSE) { break; } /* Validate WebP data, grabbing the width and height */ if (!WebPGetInfo(indata, indatalen, &width, &height)) { break; } /* Create a WebPMux from the contents of the file */ wp_data.bytes = (uint8_t*)indata; wp_data.size = indatalen; mux = WebPMuxCreate(&wp_data, 1); if (mux == NULL) { break; } /* Retrieve the features present */ if (WebPMuxGetFeatures(mux, &flags) != WEBP_MUX_OK) { break; } /* TODO: decode the image in "chunks" or "tiles" */ /* TODO: check if an alpha channel is present */ /* Create the new image and associated layer */ *image_ID = gimp_image_new(width, height, GIMP_RGB); #ifdef WEBP_0_5 if (flags & ANIMATION_FLAG) { int frames, i; /* Retrieve the number of frames */ WebPMuxNumChunks(mux, WEBP_CHUNK_ANMF, &frames); /* Loop over each of the frames */ for (i = 0; i < frames; ++i) { WebPMuxFrameInfo frame = {0}; /* Retrieve the data for the frame */ if (WebPMuxGetFrame(mux, i, &frame) != WEBP_MUX_OK) { goto error; } /* Decode the frame */ outdata = WebPDecodeRGBA(frame.bitstream.bytes, frame.bitstream.size, &width, &height); /* Free the compressed data */ WebPDataClear(&frame.bitstream); if (!outdata) { goto error; } /* Create a layer for the frame */ char name[255]; snprintf(name, 255, "Frame %d", (i + 1)); if (create_layer(*image_ID, outdata, 0, (gchar*)name, width, height, frame.x_offset, frame.y_offset) == FALSE) { goto error; } } /* If all is well, jump *over* the error label - otherwise leave the loop and begin cleaning things up */ goto success; error: break; success: ; } else { #endif /* Attempt to decode the data as a WebP image */ outdata = WebPDecodeRGBA(indata, indatalen, &width, &height); if (!outdata) { break; } /* Create a single layer */ status = create_layer(*image_ID, outdata, 0, "Background", width, height, 0, 0); #ifdef WEBP_0_5 } #ifdef GIMP_2_9 /* Load a color profile if one was provided */ if (flags & ICCP_FLAG) { WebPData icc_profile; GimpColorProfile *profile; /* Load the ICC profile from the file */ WebPMuxGetChunk(mux, "ICCP", &icc_profile); /* Have Gimp load the color profile */ profile = gimp_color_profile_new_from_icc_profile( icc_profile.bytes, icc_profile.size, NULL); if (profile) { gimp_image_set_color_profile(image_ID, profile); g_object_unref(profile); } } #endif #endif /* Set the filename for the image */ gimp_image_set_filename(*image_ID, filename); } while(0); /* Delete the mux object */ if (mux) { WebPMuxDelete(mux); } /* Free the data read from disk */ if (indata) { g_free(indata); } return status; }
static NATIVECALL(layer_new){ Link link = create_layer(); View v = This->value.vptr; im_append(v->items, link); return link; }