void DrawSilk (int side, const BoxType * drawn_area) { #if 0 /* This code is used when you want to mask silk to avoid exposed pins and pads. We decided it was a bad idea to do this unconditionally, but the code remains. */ #endif #if 0 if (gui->poly_before) { gui->graphics->use_mask (HID_MASK_BEFORE); #endif DrawLayer (LAYER_PTR (max_copper_layer + side), drawn_area); /* draw package */ r_search (PCB->Data->element_tree, drawn_area, NULL, element_callback, &side); r_search (PCB->Data->name_tree[NAME_INDEX (PCB)], drawn_area, NULL, name_callback, &side); #if 0 } gui->graphics->use_mask (HID_MASK_CLEAR); r_search (PCB->Data->pin_tree, drawn_area, NULL, clearPin_callback, NULL); r_search (PCB->Data->via_tree, drawn_area, NULL, clearPin_callback, NULL); r_search (PCB->Data->pad_tree, drawn_area, NULL, clearPad_callback, &side); if (gui->poly_after) { gui->graphics->use_mask (HID_MASK_AFTER); DrawLayer (LAYER_PTR (max_copper_layer + layer), drawn_area); /* draw package */ r_search (PCB->Data->element_tree, drawn_area, NULL, element_callback, &side); r_search (PCB->Data->name_tree[NAME_INDEX (PCB)], drawn_area, NULL, name_callback, &side); } gui->graphics->use_mask (HID_MASK_OFF); #endif }
void DrawMaze() { if (cur_layer){ M.PreviousLayer(); DrawWalls(cur_layer - 1); DrawFloor(cur_layer - 1); M.NextLayer(); } if (cur_layer < layers - 1){ M.NextLayer(); DrawWalls(cur_layer + 1); DrawCeiling(cur_layer + 1); M.PreviousLayer(); } DrawLayer(cur_layer); }
void DrawLayer(StageLayer* layer){ Sprite* sp = LoadSprite(layer->layerpath,layer->w,layer->h, 1); DrawSprite(sp,screen,layer->x-layer->offx,layer->y-layer->offy,0); if(layer->next!=NULL) DrawLayer(layer->next); }
/* --------------------------------------------------------------------------- * initializes some identifiers for a new zoom factor and redraws whole screen */ static void DrawEverything (const BoxType *drawn_area) { int i, ngroups, side; int component, solder; /* This is the list of layer groups we will draw. */ int do_group[MAX_LAYER]; /* This is the reverse of the order in which we draw them. */ int drawn_groups[MAX_LAYER]; int plated, unplated; bool paste_empty; PCB->Data->SILKLAYER.Color = PCB->ElementColor; PCB->Data->BACKSILKLAYER.Color = PCB->InvisibleObjectsColor; memset (do_group, 0, sizeof (do_group)); for (ngroups = 0, i = 0; i < max_copper_layer; i++) { LayerType *l = LAYER_ON_STACK (i); int group = GetLayerGroupNumberByNumber (LayerStack[i]); if (l->On && !do_group[group]) { do_group[group] = 1; drawn_groups[ngroups++] = group; } } component = GetLayerGroupNumberByNumber (component_silk_layer); solder = GetLayerGroupNumberByNumber (solder_silk_layer); /* * first draw all 'invisible' stuff */ if (!TEST_FLAG (CHECKPLANESFLAG, PCB) && gui->set_layer ("invisible", SL (INVISIBLE, 0), 0)) { side = SWAP_IDENT ? COMPONENT_LAYER : SOLDER_LAYER; if (PCB->ElementOn) { r_search (PCB->Data->element_tree, drawn_area, NULL, element_callback, &side); r_search (PCB->Data->name_tree[NAME_INDEX (PCB)], drawn_area, NULL, name_callback, &side); DrawLayer (&(PCB->Data->Layer[max_copper_layer + side]), drawn_area); } r_search (PCB->Data->pad_tree, drawn_area, NULL, pad_callback, &side); gui->end_layer (); } /* draw all layers in layerstack order */ for (i = ngroups - 1; i >= 0; i--) { int group = drawn_groups[i]; if (gui->set_layer (0, group, 0)) { DrawLayerGroup (group, drawn_area); gui->end_layer (); } } if (TEST_FLAG (CHECKPLANESFLAG, PCB) && gui->gui) return; /* Draw pins, pads, vias below silk */ if (gui->gui) DrawPPV (SWAP_IDENT ? solder : component, drawn_area); else { CountHoles (&plated, &unplated, drawn_area); if (plated && gui->set_layer ("plated-drill", SL (PDRILL, 0), 0)) { DrawHoles (true, false, drawn_area); gui->end_layer (); } if (unplated && gui->set_layer ("unplated-drill", SL (UDRILL, 0), 0)) { DrawHoles (false, true, drawn_area); gui->end_layer (); } } /* Draw the solder mask if turned on */ if (gui->set_layer ("componentmask", SL (MASK, TOP), 0)) { DrawMask (COMPONENT_LAYER, drawn_area); gui->end_layer (); } if (gui->set_layer ("soldermask", SL (MASK, BOTTOM), 0)) { DrawMask (SOLDER_LAYER, drawn_area); gui->end_layer (); } if (gui->set_layer ("topsilk", SL (SILK, TOP), 0)) { DrawSilk (COMPONENT_LAYER, drawn_area); gui->end_layer (); } if (gui->set_layer ("bottomsilk", SL (SILK, BOTTOM), 0)) { DrawSilk (SOLDER_LAYER, drawn_area); gui->end_layer (); } if (gui->gui) { /* Draw element Marks */ if (PCB->PinOn) r_search (PCB->Data->element_tree, drawn_area, NULL, EMark_callback, NULL); /* Draw rat lines on top */ if (gui->set_layer ("rats", SL (RATS, 0), 0)) { DrawRats(drawn_area); gui->end_layer (); } } paste_empty = IsPasteEmpty (COMPONENT_LAYER); if (gui->set_layer ("toppaste", SL (PASTE, TOP), paste_empty)) { DrawPaste (COMPONENT_LAYER, drawn_area); gui->end_layer (); } paste_empty = IsPasteEmpty (SOLDER_LAYER); if (gui->set_layer ("bottompaste", SL (PASTE, BOTTOM), paste_empty)) { DrawPaste (SOLDER_LAYER, drawn_area); gui->end_layer (); } if (gui->set_layer ("topassembly", SL (ASSY, TOP), 0)) { PrintAssembly (COMPONENT_LAYER, drawn_area); gui->end_layer (); } if (gui->set_layer ("bottomassembly", SL (ASSY, BOTTOM), 0)) { PrintAssembly (SOLDER_LAYER, drawn_area); gui->end_layer (); } if (gui->set_layer ("fab", SL (FAB, 0), 0)) { PrintFab (Output.fgGC); gui->end_layer (); } }
void Map::DrawFG() { DrawLayer(FGtMap); }
void Map::DrawBG() { DrawLayer(BGtMap); }
void C4MapCreator::Create(CSurface8 *sfcMap, C4SLandscape &rLScape, C4TextureMap &rTexMap, BOOL fLayers, int32_t iPlayerNum) { double fullperiod = 20.0 * pi; BYTE ccol; int32_t cx, cy; // Safeties if (!sfcMap) return; iPlayerNum = BoundBy<int32_t>(iPlayerNum, 1, C4S_MaxPlayer); // Set creator variables MapBuf = sfcMap; MapWdt = MapBuf->Wdt; MapHgt = MapBuf->Hgt; // Reset map (0 is sky) MapBuf->ClearBox8Only(0, 0, MapBuf->Wdt, MapBuf->Hgt); // Surface ccol = rTexMap.GetIndexMatTex(rLScape.Material, "Smooth") + MapIFT; float amplitude = (float)rLScape.Amplitude.Evaluate(); float phase = (float)rLScape.Phase.Evaluate(); float period = (float)rLScape.Period.Evaluate(); if (rLScape.MapPlayerExtend) period *= Min(iPlayerNum, C4S_MaxMapPlayerExtend); float natural = (float)rLScape.Random.Evaluate(); int32_t level0 = Min(MapWdt, MapHgt) / 2; int32_t maxrange = level0 * 3 / 4; double cy_curve, cy_natural; // -1.0 - +1.0 ! double rnd_cy, rnd_tend; // -1.0 - +1.0 ! rnd_cy = (double)(Random(2000 + 1) - 1000) / 1000.0; rnd_tend = (double)(Random(200 + 1) - 100) / 20000.0; for (cx = 0; cx < MapWdt; cx++) { rnd_cy += rnd_tend; rnd_tend += (double)(Random(100 + 1) - 50) / 10000; if (rnd_tend > +0.05) rnd_tend = +0.05; if (rnd_tend < -0.05) rnd_tend = -0.05; if (rnd_cy < -0.5) rnd_tend += 0.01; if (rnd_cy > +0.5) rnd_tend -= 0.01; cy_natural = rnd_cy * natural / 100.0; cy_curve = sin(fullperiod * period / 100.0 * (float)cx / (float)MapWdt + 2.0 * pi * phase / 100.0) * amplitude / 100.0; cy = level0 + BoundBy((int32_t)((float)maxrange * (cy_curve + cy_natural)), -maxrange, +maxrange); SetPix(cx, cy, ccol); } // Raise bottom to surface for (cx = 0; cx < MapWdt; cx++) for (cy = MapHgt - 1; (cy >= 0) && !GetPix(cx, cy); cy--) SetPix(cx, cy, ccol); // Raise liquid level Exclusive = 0; ccol = rTexMap.GetIndexMatTex(rLScape.Liquid, "Smooth"); int32_t wtr_level = rLScape.LiquidLevel.Evaluate(); for (cx = 0; cx < MapWdt; cx++) for (cy = MapHgt * (100 - wtr_level) / 100; cy < MapHgt; cy++) SetPix(cx, cy, ccol); Exclusive = -1; // Layers if (fLayers) { // Base material Exclusive = rTexMap.GetIndexMatTex(rLScape.Material, "Smooth") + MapIFT; int32_t cnt, clayer, layer_num, sptx, spty; // Process layer name list for (clayer = 0; clayer < C4MaxNameList; clayer++) if (rLScape.Layers.Name[clayer][0]) { // Draw layers ccol = rTexMap.GetIndexMatTex(rLScape.Layers.Name[clayer], "Rough") + MapIFT; layer_num = rLScape.Layers.Count[clayer]; layer_num = layer_num * MapWdt * MapHgt / 15000; for (cnt = 0; cnt < layer_num; cnt++) { // Place layer sptx = Random(MapWdt); for (spty = 0; (spty < MapHgt) && (GetPix(sptx, spty) != Exclusive); spty++) ; spty += 5 + Random((MapHgt - spty) - 10); DrawLayer(sptx, spty, Random(15), ccol); } } Exclusive = -1; } }
static int gerber_set_layer (const char *name, int group, int empty) { int want_outline; char *cp; int idx = (group >= 0 && group < max_group) ? PCB->LayerGroups.Entries[group][0] : group; if (name == NULL) name = PCB->Data->Layer[idx].Name; if (idx >= 0 && idx < max_copper_layer && !print_layer[idx]) return 0; if (strcmp (name, "invisible") == 0) return 0; if (SL_TYPE (idx) == SL_ASSY) return 0; flash_drills = 0; if (strcmp (name, "outline") == 0 || strcmp (name, "route") == 0) flash_drills = 1; if (is_drill && n_pending_drills) { int i; /* dump pending drills in sequence */ qsort (pending_drills, n_pending_drills, sizeof (pending_drills[0]), drill_sort); for (i = 0; i < n_pending_drills; i++) { if (i == 0 || pending_drills[i].diam != pending_drills[i - 1].diam) { Aperture *ap = findAperture (curr_aptr_list, pending_drills[i].diam, ROUND); fprintf (f, "T%02d\r\n", ap->dCode); } /* Notice the last zeroes are literal zeroes here, a x10 scale factor. * * v v */ pcb_fprintf (f, metric ? "X%06.0muY%06.0mu\r\n" : "X%06.0ml0Y%06.0ml0\r\n", gerberDrX (PCB, pending_drills[i].x), gerberDrY (PCB, pending_drills[i].y)); } free (pending_drills); n_pending_drills = max_pending_drills = 0; pending_drills = NULL; } is_drill = (SL_TYPE (idx) == SL_PDRILL || SL_TYPE (idx) == SL_UDRILL); is_mask = (SL_TYPE (idx) == SL_MASK); current_mask = 0; #if 0 printf ("Layer %s group %d drill %d mask %d\n", name, group, is_drill, is_mask); #endif if (group < 0 || group != lastgroup) { time_t currenttime; char utcTime[64]; #ifdef HAVE_GETPWUID struct passwd *pwentry; #endif ApertureList *aptr_list; Aperture *search; lastgroup = group; lastX = -1; lastY = -1; linewidth = -1; lastcap = -1; aptr_list = setLayerApertureList (layer_list_idx++); if (finding_apertures) goto emit_outline; if (aptr_list->count == 0 && !all_layers) return 0; maybe_close_f (f); f = NULL; pagecount++; assign_file_suffix (filesuff, idx); f = fopen (filename, "wb"); /* Binary needed to force CR-LF */ if (f == NULL) { Message ( "Error: Could not open %s for writing.\n", filename); return 1; } was_drill = is_drill; if (verbose) { int c = aptr_list->count; printf ("Gerber: %d aperture%s in %s\n", c, c == 1 ? "" : "s", filename); } if (is_drill) { /* We omit the ,TZ here because we are not omitting trailing zeros. Our format is always six-digit 0.1 mil or µm resolution (i.e. 001100 = 0.11" or 1.1mm)*/ fprintf (f, "M48\r\n"); fprintf (f, metric ? "METRIC,000.000\r\n" : "INCH\r\n"); for (search = aptr_list->data; search; search = search->next) pcb_fprintf (f, metric ? "T%02dC%.3`mm\r\n" : "T%02dC%.3`mi\r\n", search->dCode, search->width); fprintf (f, "%%\r\n"); /* FIXME */ return 1; } fprintf (f, "G04 start of page %d for group %d idx %d *\r\n", pagecount, group, idx); /* Create a portable timestamp. */ currenttime = time (NULL); { /* avoid gcc complaints */ const char *fmt = "%c UTC"; strftime (utcTime, sizeof utcTime, fmt, gmtime (¤ttime)); } /* Print a cute file header at the beginning of each file. */ fprintf (f, "G04 Title: %s, %s *\r\n", UNKNOWN (PCB->Name), UNKNOWN (name)); fprintf (f, "G04 Creator: %s " VERSION " *\r\n", Progname); fprintf (f, "G04 CreationDate: %s *\r\n", utcTime); #ifdef HAVE_GETPWUID /* ID the user. */ pwentry = getpwuid (getuid ()); fprintf (f, "G04 For: %s *\r\n", pwentry->pw_name); #endif fprintf (f, "G04 Format: Gerber/RS-274X *\r\n"); pcb_fprintf (f, metric ? "G04 PCB-Dimensions (mm): %.2mm %.2mm *\r\n" : "G04 PCB-Dimensions (mil): %.2ml %.2ml *\r\n", PCB->MaxWidth, PCB->MaxHeight); fprintf (f, "G04 PCB-Coordinate-Origin: lower left *\r\n"); /* Signal data in inches. */ fprintf (f, metric ? "%%MOMM*%%\r\n" : "%%MOIN*%%\r\n"); /* Signal Leading zero suppression, Absolute Data, 2.5 format in inch, 4.3 in mm */ fprintf (f, metric ? "%%FSLAX43Y43*%%\r\n" : "%%FSLAX25Y25*%%\r\n"); /* build a legal identifier. */ if (layername) free (layername); layername = strdup (filesuff); if (strrchr (layername, '.')) * strrchr (layername, '.') = 0; for (cp=layername; *cp; cp++) { if (isalnum((int) *cp)) *cp = toupper((int) *cp); else *cp = '_'; } fprintf (f, "%%LN%s*%%\r\n", layername); lncount = 1; for (search = aptr_list->data; search; search = search->next) fprintAperture(f, search); if (aptr_list->count == 0) /* We need to put *something* in the file to make it be parsed as RS-274X instead of RS-274D. */ fprintf (f, "%%ADD11C,0.0100*%%\r\n"); } emit_outline: /* If we're printing a copper layer other than the outline layer, and we want to "print outlines", and we have an outline layer, print the outline layer on this layer also. */ want_outline = 0; if (copy_outline_mode == COPY_OUTLINE_MASK && SL_TYPE (idx) == SL_MASK) want_outline = 1; if (copy_outline_mode == COPY_OUTLINE_SILK && SL_TYPE (idx) == SL_SILK) want_outline = 1; if (copy_outline_mode == COPY_OUTLINE_ALL && (SL_TYPE (idx) == SL_SILK || SL_TYPE (idx) == SL_MASK || SL_TYPE (idx) == SL_FAB || SL_TYPE (idx) == SL_ASSY || SL_TYPE (idx) == 0)) want_outline = 1; if (want_outline && strcmp (name, "outline") && strcmp (name, "route")) { if (outline_layer && outline_layer != PCB->Data->Layer+idx) DrawLayer (outline_layer, ®ion); else if (!outline_layer) { hidGC gc = gui->make_gc (); printf("name %s idx %d\n", name, idx); if (SL_TYPE (idx) == SL_SILK) gui->set_line_width (gc, PCB->minSlk); else if (group >= 0) gui->set_line_width (gc, PCB->minWid); else gui->set_line_width (gc, AUTO_OUTLINE_WIDTH); gui->draw_line (gc, 0, 0, PCB->MaxWidth, 0); gui->draw_line (gc, 0, 0, 0, PCB->MaxHeight); gui->draw_line (gc, PCB->MaxWidth, 0, PCB->MaxWidth, PCB->MaxHeight); gui->draw_line (gc, 0, PCB->MaxHeight, PCB->MaxWidth, PCB->MaxHeight); gui->destroy_gc (gc); } } return 1; }